Walk file tree in order for deterministic builds

Python's `os.walk` does not order the lists of files and directories it returns, so in order to produce a consistent build context tarfile, they should be ordered.
This commit is contained in:
Marcus Cobden 2014-11-04 10:02:24 +00:00
parent 00e3ff9574
commit dacaa583fb
1 changed files with 2 additions and 1 deletions

View File

@ -72,7 +72,8 @@ def tar(path, exclude=None):
fnames = [name for name in filenames
if not fnmatch_any(os.path.join(relpath, name),
exclude)]
for name in fnames:
dirnames.sort()
for name in sorted(fnames):
arcname = os.path.join(relpath, name)
t.add(os.path.join(path, arcname), arcname=arcname)
for name in dirnames: