genorig.py: Make orig tarballs really reproducible

- Override umask while extracting/exporting files
- Override user and group names in tarball
This commit is contained in:
Ben Hutchings 2016-01-08 19:31:40 +00:00
parent db948006fc
commit 0c23e53745
2 changed files with 7 additions and 1 deletions

View File

@ -40,6 +40,7 @@ class Main(object):
def __call__(self):
import tempfile
self.dir = tempfile.mkdtemp(prefix='genorig', dir='debian')
old_umask = os.umask(0o022)
try:
if os.path.isdir(self.input_files[0]):
self.upstream_export(self.input_files[0])
@ -59,8 +60,10 @@ class Main(object):
.st_mtime))
self.debian_patch()
os.umask(old_umask)
self.tar(orig_date)
finally:
os.umask(old_umask)
shutil.rmtree(self.dir)
def upstream_export(self, input_repo):
@ -131,7 +134,7 @@ class Main(object):
self.log("Generate tarball %s\n" % out)
cmdline = '''(cd '%s' && find '%s' -print0) |
LC_ALL=C sort -z |
tar -C '%s' --no-recursion --null -T - --mtime '%s' -caf '%s'
tar -C '%s' --no-recursion --null -T - --mtime '%s' --owner root --group root -caf '%s'
''' % (self.dir, self.orig, self.dir, orig_date, out)
try:
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', cmdline]):

3
debian/changelog vendored
View File

@ -2,6 +2,9 @@ linux (4.3.3-6) UNRELEASED; urgency=medium
* debian.py: Implement stable order of fields in debian/tests/control
* debian.py: Implement stable order of fields not in the predefined order
* genorig.py: Make orig tarballs really reproducible:
- Override umask while extracting/exporting files
- Override user and group names in tarball
-- Ben Hutchings <ben@decadent.org.uk> Fri, 08 Jan 2016 12:08:13 +0000