[Reproducible-commits] [debhelper] 20/61: Add install_dh_config_file and exec lintian-overrides (compat 9)

Mattia Rizzolo mattia at mapreri.org
Sat Apr 4 18:37:28 UTC 2015


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

mapreri-guest pushed a commit to branch pu/reproducible_builds
in repository debhelper.

commit 84c0a76c7d528873f1c8e7c800e026bfdfc8def2
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Jan 3 12:49:00 2015 +0100

    Add install_dh_config_file and exec lintian-overrides (compat 9)
    
    Add a install_dh_config_file to install or execute and create a file
    from the output of a debhelper config file
    (e.g. debian/lintian-overrides).  Use this subroutine in dh_lintian
    to install the lintian-overrides.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 35 ++++++++++++++++++++++++++++++++++-
 debian/changelog           |  7 +++++++
 dh_lintian                 |  2 +-
 doc/PROGRAMMING            |  5 +++++
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 3b94a05..57caa3c 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -19,7 +19,9 @@ use vars qw(@ISA @EXPORT %dh);
 	    &inhibit_log &load_log &write_log &commit_override_log
 	    &dpkg_architecture_value &sourcepackage &make_symlink
 	    &is_make_jobserver_unavailable &clean_jobserver_makeflags
-	    &cross_command &set_buildflags &get_buildoption);
+	    &cross_command &set_buildflags &get_buildoption
+	    &install_dh_config_file
+);
 
 my $max_compat=10;
 
@@ -1106,6 +1108,37 @@ sub get_buildoption {
 	}
 }
 
+# install a dh config file (e.g. debian/<pkg>.lintian-overrides) into
+# the package.  Under compat 9+ it may execute the file and use its
+# output instead.
+#
+# install_dh_config_file(SOURCE, TARGET[, MODE])
+sub install_dh_config_file {
+	my ($source, $target, $mode) = @_;
+	$mode = 0644 if not defined($mode);
+
+	if (!compat(8) and -x $source) {
+		my @sstat = stat($source) || error("cannot stat $file: $!");
+		open(my $tfd, '>', $target) || error("cannot open $file: $!");
+		chmod($mode, $tfd) || error("cannot chmod $file: $!");
+		open(my $sfd, '-|', $source) || error("cannot run $file: $!");
+		while (my $line = <$sfd>) {
+			print ${tfd} $line;
+		}
+		if (!close($sfd)) {
+			error("cannot close handle from $file: $!") if $!;
+			_error_exitcode($source);
+		}
+		close($tfd) || error("cannot close $file: $!");
+		# Set the mtime (and atime) to ensure reproducibility.
+		utime($sstat[9], $sstat[9], $target);
+	} else {
+		my $str_mode = sprintf('%#4o', $mode);
+		doit('install', '-p', "-m${str_mode}", $source, $target);
+	}
+	return 1;
+}
+
 1
 
 # Local Variables:
diff --git a/debian/changelog b/debian/changelog
index 9620d63..da19adb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,6 +33,13 @@ debhelper (9.20150101.1) UNRELEASED; urgency=medium
   * The "ant" build system now loads debian/ant.properties
     automatically before build and clean (like CDBS).  Thanks to
     Thomas Koch for the report.  (Closes: #563909)
+  * Dh_lib: Add install_dh_config_file to install a file either by
+    copying the source file or (with an executable file under compat
+    9) execute the file and use its output to generate the
+    destination.
+  * dh_lintian: Under compat 9, the debian/lintian-overrides are now
+    executed if they have the exec-bit set like the debian/install
+    files.  Thanks to Axel Beckert for the report.  (Closes: #698500)
 
   [ Bernhard R. Link ]
   * Dh_lib: apply patch from Guillem Jover to support case-insensitive
diff --git a/dh_lintian b/dh_lintian
index ba47ea0..e8f9d72 100755
--- a/dh_lintian
+++ b/dh_lintian
@@ -52,7 +52,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		if (! -d "$or_dir") {
 			 doit("install","-d","$or_dir");
 		}
-		doit("install","-p","-m644",$overrides,"$or_dir/$package");
+		install_dh_config_file($overrides, "$or_dir/$package");
 	}
 }
 
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 8723e4f..6ba207f 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -267,6 +267,11 @@ make_symlink($src, $dest, $tmp)
 	Creates a Policy compliant sytem link called $dest pointing to
 	$src. If $tmp is given, then $tmp will be prefixed to $dest when
 	creating the actual symlink.
+install_dh_config_file($src, $dest[, $mode])
+	Installs $src into $dest with $mode (defaults to 0644).  If
+	compat is 9 (or later) and $src is executable, $src will be
+	executed instead and its output will be used to generate the
+	$dest file.
 
 Sequence Addons:
 ---------------

-- 
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