[Reproducible-commits] [debhelper] 09/14: dh_builddeb: fix mtimes for reproducibility

Johannes Schauer josch at moszumanska.debian.org
Fri May 8 06:15:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

josch pushed a commit to branch pu/reproducible_builds
in repository debhelper.

commit da9ad4aa63da99757398cf05738136742f47d945
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.
    
    Conflicts:
    	dh_builddeb
    Closes: #759886
---
 Debian/Debhelper/Dh_Lib.pm |  4 +++-
 dh_builddeb                | 24 +++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index c0da230..3909485 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -526,7 +526,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;
@@ -548,6 +549,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 c827f2f..b6ae2ef 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -15,12 +15,23 @@ B<dh_builddeb> [S<I<debhelper options>>] [B<--destdir=>I<directory>] [B<--filena
 
 =head1 DESCRIPTION
 
-B<dh_builddeb> simply calls L<dpkg-deb(1)> to build a Debian package or
+B<dh_builddeb> calls L<dpkg-deb(1)> to build a Debian package or
 packages.
 
 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
@@ -92,6 +103,9 @@ sub default_compressor_args {
 }
 
 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! $!");
@@ -126,6 +140,14 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("dpkg-deb", @args,
 			 "--build", $ddeb_tmpdir, $dh{DESTDIR}.$ddeb_filename);
 	}
+
+	my $find_options='';
+	if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
+		$find_options="! \\( $dh{EXCLUDE_FIND} \\)";
+	}
+	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