mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use a temp folder when packaging on Linux
The purpose of the code is to make a new temporary folder with the necessary resources used to package Linux. Before this, the package was built based on a modified target directory. By using a temporary folder, it removes the need to rebuild Servo every time it gets packaged for Linux.
This commit is contained in:
parent
5b0a1990d5
commit
d672750ca4
1 changed files with 18 additions and 18 deletions
|
@ -287,24 +287,22 @@ class PackageCommands(CommandBase):
|
|||
msi_path = path.join(dir_to_msi, "Servo.msi")
|
||||
print("Packaged Servo into {}".format(msi_path))
|
||||
else:
|
||||
dir_to_package = '/'.join(binary_path.split('/')[:-1])
|
||||
dir_to_root = '/'.join(binary_path.split('/')[:-3])
|
||||
resources_dir = dir_to_package + '/resources'
|
||||
if os.path.exists(resources_dir):
|
||||
delete(resources_dir)
|
||||
shutil.copytree(dir_to_root + '/resources', resources_dir)
|
||||
dir_to_temp = path.join(os.path.dirname(binary_path), 'packaging-temp')
|
||||
browserhtml_path = find_dep_path_newest('browserhtml', binary_path)
|
||||
if browserhtml_path is None:
|
||||
print("Could not find browserhtml package; perhaps you haven't built Servo.")
|
||||
return 1
|
||||
print("Deleting unused files")
|
||||
keep = ['servo', 'resources', 'build']
|
||||
for f in os.listdir(dir_to_package + '/'):
|
||||
if f not in keep:
|
||||
delete(dir_to_package + '/' + f)
|
||||
for f in os.listdir(dir_to_package + '/build/'):
|
||||
if 'browserhtml' not in f:
|
||||
delete(dir_to_package + '/build/' + f)
|
||||
if path.exists(dir_to_temp):
|
||||
# TODO(aneeshusa): lock dir_to_temp to prevent simultaneous builds
|
||||
print("Cleaning up from previous packaging")
|
||||
delete(dir_to_temp)
|
||||
|
||||
print("Copying files")
|
||||
dir_to_resources = path.join(dir_to_temp, 'resources')
|
||||
shutil.copytree(path.join(self.get_top_dir(), 'resources'), dir_to_resources)
|
||||
shutil.copytree(browserhtml_path, path.join(dir_to_temp, 'build'))
|
||||
shutil.copy(binary_path, dir_to_temp)
|
||||
|
||||
print("Writing runservo.sh")
|
||||
# TODO: deduplicate this arg list from post_build_commands
|
||||
servo_args = ['-w', '-b',
|
||||
|
@ -313,17 +311,19 @@ class PackageCommands(CommandBase):
|
|||
'--pref', 'shell.builtin-key-shortcuts.enabled=false',
|
||||
path.join('./build/' + browserhtml_path.split('/')[-1], 'out', 'index.html')]
|
||||
|
||||
runservo = os.open(dir_to_package + '/runservo.sh', os.O_WRONLY | os.O_CREAT, int("0755", 8))
|
||||
runservo = os.open(dir_to_temp + '/runservo.sh', os.O_WRONLY | os.O_CREAT, int("0755", 8))
|
||||
os.write(runservo, "#!/usr/bin/env sh\n./servo " + ' '.join(servo_args))
|
||||
os.close(runservo)
|
||||
|
||||
print("Creating tarball")
|
||||
tar_path = '/'.join(dir_to_package.split('/')[:-1]) + '/'
|
||||
time = datetime.utcnow().replace(microsecond=0).isoformat()
|
||||
time = time.replace(':', "-")
|
||||
tar_path += time + "-servo-tech-demo.tar.gz"
|
||||
tar_path = path.join(self.get_target_dir(), time + '-servo-tech-demo.tar.gz')
|
||||
|
||||
archive_deterministically(dir_to_package, tar_path, prepend_path='servo/')
|
||||
archive_deterministically(dir_to_temp, tar_path, prepend_path='servo/')
|
||||
|
||||
print("Cleaning up")
|
||||
delete(dir_to_temp)
|
||||
print("Packaged Servo into " + tar_path)
|
||||
|
||||
@Command('install',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue