[Reproducible-commits] [debhelper] 06/09: dh_builddeb: fix mtimes for reproducibility
Mattia Rizzolo
mattia at mapreri.org
Sun Dec 20 13:14:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch pu/reproducible_builds
in repository debhelper.
commit 32de720aa602bc6b5db322c9a87dfcf3800793ef
Author: Jérémy Bobbio <lunar at debian.org>
Date: Fri Aug 29 03:46:09 2014 +0000
dh_builddeb: fix mtimes for reproducibility
To enable reproducible builds, file modification times written in binary
packages should be the same accross multiple builds of the same source
package. dh_builddeb will now change the modification time of any file that
has been created later than the time of the latest debian/changelog
entry to the time of the latest debian/changelog entry.
See https://wiki.debian.org/ReproducibleBuilds for more information on
reproducible builds in Debian.
Closes: #759886
---
Debian/Debhelper/Dh_Lib.pm | 4 +++-
dh_builddeb | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index ab3d6b2..a92ef56 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -543,7 +543,8 @@ sub pkgfilename {
}
# Returns 1 if the package is a native debian package, null otherwise.
-# As a side effect, sets $dh{VERSION} to the version of this package.
+# As a side effect, sets $dh{VERSION} to the version of this package,
+# and $dh{DATE} to the date of the latest changelog entry.
{
# Caches return code so it only needs to run dpkg-parsechangelog once.
my %isnative_cache;
@@ -565,6 +566,7 @@ sub pkgfilename {
if (! defined $dh{VERSION}) {
error("changelog parse failure");
}
+ ($dh{DATE})=$version=~m/Date:\s*(.*)/m;
# Is this a native Debian package?
if ($dh{VERSION}=~m/.*-/) {
diff --git a/dh_builddeb b/dh_builddeb
index f314e5a..33592a9 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -23,6 +23,17 @@ and L<dh_gencontrol(1)> have prepared them.
It supports building multiple binary packages in parallel, when enabled by
DEB_BUILD_OPTIONS.
+Before building the package, it will reset the modification times of files and
+directories in package build directories to a state easily reproducible accross
+multiple builds.
+
+It will examine the modification time of all files in the package
+build directory. If the file is newer than the date of the latest
+debian/changelog entry, we assume the file is a result of a build, and its
+modification time will be set to the date of the latest debian/changelog entry.
+
+This removes unneeded variations accross builds of the same package.
+
=head1 OPTIONS
=over 4
@@ -121,6 +132,9 @@ sub build_and_rename_deb {
}
foreach my $package (@{$dh{DOPACKAGES}}) {
+ # XXX: not nice, we only run this for the side effect of getting $dh{DATE} set
+ isnative($package);
+
my $pid=fork();
if (! defined $pid) {
error("fork failed! $!");
@@ -145,6 +159,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
foreach split(":", $ENV{DH_ALWAYS_EXCLUDE});
}
}
+
+ my $find_options='';
+ if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
+ $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
+ }
+
if ( -d $ddeb_tmpdir) {
my $ddeb_control = "${ddeb_tmpdir}/DEBIAN/control";
# Only build the ddeb if it has a control file. People might
@@ -155,6 +175,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# the ddeb.
my @args = default_compressor_args(["-z1", "-Zxz", "-Sextreme"],
@{$dh{U_PARAMS}});
+ complex_doit("find $ddeb_tmpdir -newermt '$dh{DATE}' $find_options -print0",
+ "2>/dev/null | xargs -0r touch --no-dereference --date='$dh{DATE}'");
+
doit("dpkg-deb", @args,
"--build", $ddeb_tmpdir, $dh{DESTDIR});
} elsif (not is_udeb($package)) {
@@ -162,6 +185,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
warning("Please use dh_gencontrol to avoid this issue");
}
}
+
+ complex_doit("find $tmp -newermt '$dh{DATE}' $find_options -print0",
+ "2>/dev/null | xargs -0r touch --no-dereference --date='$dh{DATE}'");
+
if (! is_udeb($package)) {
doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debhelper.git
More information about the Reproducible-commits
mailing list