debian/bin/genorig.py: Make orig tarballs reproducible
Sort the tarball contents and set their mtimes to the upstream release time. (In case we're given a tarball and patch, the release time is unknown and the result is not reproducible. So don't do that.)
This commit is contained in:
parent
52d8c20b40
commit
44ea8344d6
|
@ -8,6 +8,7 @@ import os.path
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
from debian_linux.debian import Changelog, VersionLinux
|
from debian_linux.debian import Changelog, VersionLinux
|
||||||
from debian_linux.patches import PatchSeries
|
from debian_linux.patches import PatchSeries
|
||||||
|
@ -46,8 +47,19 @@ class Main(object):
|
||||||
self.upstream_extract(self.input_files[0])
|
self.upstream_extract(self.input_files[0])
|
||||||
if len(self.input_files) > 1:
|
if len(self.input_files) > 1:
|
||||||
self.upstream_patch(self.input_files[1])
|
self.upstream_patch(self.input_files[1])
|
||||||
|
|
||||||
|
# debian_patch() will change file mtimes. Capture the
|
||||||
|
# original release time so we can apply it to the final
|
||||||
|
# tarball. Note this doesn't work in case we apply an
|
||||||
|
# upstream patch, as that doesn't carry a release time.
|
||||||
|
orig_date = time.strftime(
|
||||||
|
"%a, %d %b %Y %H:%M:%S +0000",
|
||||||
|
time.gmtime(
|
||||||
|
os.stat(os.path.join(self.dir, self.orig, 'Makefile'))
|
||||||
|
.st_mtime))
|
||||||
|
|
||||||
self.debian_patch()
|
self.debian_patch()
|
||||||
self.tar()
|
self.tar(orig_date)
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(self.dir)
|
shutil.rmtree(self.dir)
|
||||||
|
|
||||||
|
@ -105,7 +117,7 @@ class Main(object):
|
||||||
series = PatchSeries(name, "debian/patches", fp)
|
series = PatchSeries(name, "debian/patches", fp)
|
||||||
series(dir=os.path.join(self.dir, self.orig))
|
series(dir=os.path.join(self.dir, self.orig))
|
||||||
|
|
||||||
def tar(self):
|
def tar(self, orig_date):
|
||||||
out = os.path.join("../orig", self.orig_tar)
|
out = os.path.join("../orig", self.orig_tar)
|
||||||
try:
|
try:
|
||||||
os.mkdir("../orig")
|
os.mkdir("../orig")
|
||||||
|
@ -117,9 +129,12 @@ class Main(object):
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
self.log("Generate tarball %s\n" % out)
|
self.log("Generate tarball %s\n" % out)
|
||||||
cmdline = ['tar -caf', out, '-C', self.dir, self.orig]
|
cmdline = '''(cd '%s' && find '%s' -print0) |
|
||||||
|
LC_ALL=C sort -z |
|
||||||
|
tar -C '%s' --no-recursion --null -T - --mtime '%s' -caf '%s'
|
||||||
|
''' % (self.dir, self.orig, self.dir, orig_date, out)
|
||||||
try:
|
try:
|
||||||
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
|
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', cmdline]):
|
||||||
raise RuntimeError("Can't patch source")
|
raise RuntimeError("Can't patch source")
|
||||||
os.chmod(out, 0o644)
|
os.chmod(out, 0o644)
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -15,6 +15,7 @@ linux (4.2~rc8-1~exp2) UNRELEASED; urgency=medium
|
||||||
* Fix last issue that prevents a reproducible build (Closes: #769844):
|
* Fix last issue that prevents a reproducible build (Closes: #769844):
|
||||||
- DocBook: Use a fixed encoding for output
|
- DocBook: Use a fixed encoding for output
|
||||||
* debian/bin,debian/control,debian/lib/python: Use Python 3
|
* debian/bin,debian/control,debian/lib/python: Use Python 3
|
||||||
|
* debian/bin/genorig.py: Make orig tarballs reproducible
|
||||||
|
|
||||||
-- Ben Hutchings <ben@decadent.org.uk> Tue, 25 Aug 2015 18:50:57 +0100
|
-- Ben Hutchings <ben@decadent.org.uk> Tue, 25 Aug 2015 18:50:57 +0100
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue