[Reproducible-commits] [debhelper] 01/02: dh_builddeb: fix mtimes for reproducibility

Mattia Rizzolo mattia at debian.org
Fri Jan 15 00:38:28 UTC 2016


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 eff7cb4edbfb875fc9680be8c87d13b7958cb73a
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.
    
    Niels Thykier: Use get_source_date_epoch rather than $dh{DATE}
    
    Santiago Vila: Fix typo: s/accross/across/
    
    Closes: #759886
---
 dh_builddeb | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dh_builddeb b/dh_builddeb
index a39a716..2f76791 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 across
+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 across builds of the same package.
+
 =head1 OPTIONS
 
 =over 4
@@ -120,6 +131,8 @@ sub build_and_rename_deb {
 		 "${destdir}/${desired_filename}");
 }
 
+my $source_date = get_source_date_epoch();
+
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $pid=fork();
 	if (! defined $pid) {
@@ -145,6 +158,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 $dbgsym_tmpdir) {
 		my $dbgsym_control = "${dbgsym_tmpdir}/DEBIAN/control";
 		# Only build the dbgsym package if it has a control file.
@@ -155,6 +174,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			# the dbgsym package.
 			my @args = default_compressor_args(["-z1", "-Zxz", "-Sextreme"],
 											   @{$dh{U_PARAMS}});
+			complex_doit("find $dbgsym_tmpdir -newermt '\@${source_date}' $find_options -print0",
+					"2>/dev/null | xargs -0r touch --no-dereference --date='\@${source_date}'");
+
 			doit("dpkg-deb", @args,
 				 "--build", $dbgsym_tmpdir, $dh{DESTDIR});
 		} elsif (not is_udeb($package)) {
@@ -162,6 +184,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			warning("Please use dh_gencontrol to avoid this issue");
 		}
 	}
+
+	complex_doit("find $tmp -newermt '\@${source_date}' $find_options -print0",
+		"2>/dev/null | xargs -0r touch --no-dereference --date='\@${source_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