diff options
author | Patrick Trottier <patrick.arrow206@outlook.com> | 2016-09-13 00:05:22 +0000 |
---|---|---|
committer | Patrick Trottier <patrick.arrow206@outlook.com> | 2016-09-30 22:56:55 +0000 |
commit | d672750ca4f702857466728a38831fe57a955d52 (patch) | |
tree | 02a1d28f13609f09cc7dd8b955a6fa6e787cf5be /python/servo/package_commands.py | |
parent | 5b0a1990d5fff645811f4c70d2a515e85fc2fd20 (diff) | |
download | servo-d672750ca4f702857466728a38831fe57a955d52.tar.gz servo-d672750ca4f702857466728a38831fe57a955d52.zip |
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.
Diffstat (limited to 'python/servo/package_commands.py')
-rw-r--r-- | python/servo/package_commands.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index fbc659d5696..03dd93b3ef5 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -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', |