New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create .tar.gz package deterministically using external commands #12108
Closed
+23
−4
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -13,7 +13,6 @@ | ||
| import os.path as path | ||
| import shutil | ||
| import subprocess | ||
| import tarfile | ||
|
|
||
| from mach.registrar import Registrar | ||
| from datetime import datetime | ||
| @@ -183,9 +182,29 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger= | ||
| tar_path = '/'.join(dir_to_package.split('/')[:-1]) + '/' | ||
| tar_path += datetime.utcnow().replace(microsecond=0).isoformat() | ||
| tar_path += "-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 | ||
| # See https://reproducible-builds.org/docs/archives/ | ||
| archive_root_dir = 'servo' | ||
| with cd(dir_to_package): | ||
|
||
| p1 = subprocess.Popen(['find', '.', '-print0'], | ||
| stdout=subprocess.PIPE) | ||
| p2 = subprocess.Popen(['sort', '-z'], env=dict(os.environ, LC_ALL='C'), | ||
| stdin=p1.stdout, stdout=subprocess.PIPE) | ||
| p3 = subprocess.Popen(['tar', '--null', '-T', '-', '--no-recursion', | ||
| '--mtime', '1970-01-01 00:00Z', | ||
aneeshusa
Member
|
||
| '--transform', 's,^./,{}/,'.format(archive_root_dir), | ||
|
||
| '--owner=root', '--group=root', '--numeric-owner', | ||
| '-cf', '-'], | ||
aneeshusa
Member
|
||
| stdin=p2.stdout, stdout=subprocess.PIPE) | ||
| with open(tar_path, 'wb') as tar_fh: | ||
| archive_proc = subprocess.Popen(['gzip', '-n'], | ||
| stdin=p3.stdout, stdout=tar_fh) | ||
| p1.stdout.close() | ||
| p2.stdout.close() | ||
| p3.stdout.close() | ||
| archive_proc.communicate() | ||
|
|
||
| print("Packaged Servo into " + tar_path) | ||
|
|
||
| @Command('install', | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I think it would be a good idea to hoist this into a separate function to create a tarball, deterministically. I think
python/servo/command_base.pyis a good place for this.