aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/package_commands.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-04 18:15:49 -0500
committerGitHub <noreply@github.com>2016-08-04 18:15:49 -0500
commit1086df67e04ce97fed080ba7c79ed8e1615202eb (patch)
tree091b5114925d6fd666bf52c2275fb75750ca9407 /python/servo/package_commands.py
parent3dce4c62ca55409dfac9dea6ecc674c0020eab6c (diff)
parent0a056a9b31e21c468bcbc97eaea5a0a62fa9cb46 (diff)
downloadservo-1086df67e04ce97fed080ba7c79ed8e1615202eb.tar.gz
servo-1086df67e04ce97fed080ba7c79ed8e1615202eb.zip
Auto merge of #12244 - rev112:package-repro-pure, r=aneeshusa
Create .tar.gz package deterministically using Python's "tarfile" <!-- Please describe your changes on the following line: --> A development of #12108, creates a .tar.gz package using the `tarfile` and `gzip` modules, without external dependencies. Fixes #11981. Also this fixes the issue when the existing `resources/` directory didn't allow to create a new package and failed with "File exists" error. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11981 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because "more general approach to reproducibility testing is needed" <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12244) <!-- Reviewable:end -->
Diffstat (limited to 'python/servo/package_commands.py')
-rw-r--r--python/servo/package_commands.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 2513b2b5ad1..3e959399748 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -16,7 +16,6 @@ sys.path.append(path.join(path.dirname(sys.argv[0]), "components", "style", "pro
import os
import shutil
import subprocess
-import tarfile
from mach.registrar import Registrar
from datetime import datetime
@@ -29,7 +28,14 @@ from mach.decorators import (
from mako.template import Template
-from servo.command_base import CommandBase, cd, BuildNotFound, is_macosx, is_windows
+from servo.command_base import (
+ archive_deterministically,
+ BuildNotFound,
+ cd,
+ CommandBase,
+ is_macosx,
+ is_windows,
+)
from servo.post_build_commands import find_dep_path_newest
@@ -205,7 +211,10 @@ class PackageCommands(CommandBase):
else:
dir_to_package = '/'.join(binary_path.split('/')[:-1])
dir_to_root = '/'.join(binary_path.split('/')[:-3])
- shutil.copytree(dir_to_root + '/resources', dir_to_package + '/resources')
+ resources_dir = dir_to_package + '/resources'
+ if os.path.exists(resources_dir):
+ delete(resources_dir)
+ shutil.copytree(dir_to_root + '/resources', resources_dir)
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.")
@@ -234,9 +243,9 @@ class PackageCommands(CommandBase):
time = datetime.utcnow().replace(microsecond=0).isoformat()
time = time.replace(':', "-")
tar_path += time + "-servo-tech-demo.tar.gz"
- with tarfile.open(tar_path, "w:gz") as tar:
- # arcname is to add by relative rather than absolute path
- tar.add(dir_to_package, arcname='servo/')
+
+ archive_deterministically(dir_to_package, tar_path, prepend_path='servo/')
+
print("Packaged Servo into " + tar_path)
@Command('install',