Skip to content

Commit 354b94b

Browse files
committed
Build reproducible tarballs from git
1 parent 1422be6 commit 354b94b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

easybuild/tools/filetools.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,11 +2707,16 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
27072707
for cmd in cmds:
27082708
run.run_cmd(cmd, log_all=True, simple=True, regexp=False, path=repo_name)
27092709

2710-
# create an archive and delete the git repo directory
2711-
if keep_git_dir:
2712-
tar_cmd = ['tar', 'cfvz', targetpath, repo_name]
2713-
else:
2714-
tar_cmd = ['tar', 'cfvz', targetpath, '--exclude', '.git', repo_name]
2710+
# When CentOS 7 is phased out and tar>1.28 is everywhere, replace find-sort-pipe with tar-flag
2711+
# '--sort=name' and place LC_ALL in front of tar. Also remove flags --null, --no-recursion, and
2712+
# --files-from - from the flags to tar. See https://reproducible-builds.org/docs/archives/
2713+
tar_cmd = ['find', repo_name, '-print0', '|',
2714+
'LC_ALL=C', 'sort', '--zero-terminated', '|',
2715+
'GZIP=--no-name', 'tar', '--create', '--file', targetpath, '--gzip',
2716+
'--mtime="1970-01-01 00:00Z"', '--owner=0', '--group=0', '--numeric-owner',
2717+
'--format=gnu', '--null',
2718+
'--exclude=.git' if not keep_git_dir else '',
2719+
'--no-recursion', '--files-from -',]
27152720
run.run_cmd(' '.join(tar_cmd), log_all=True, simple=True, regexp=False)
27162721

27172722
# cleanup (repo_name dir does not exist in dry run mode)

0 commit comments

Comments
 (0)