[debhelper-devel] [RFC PATCH 2/3] Temporarily define a deb helper dh_sha256sums

Mimi Zohar zohar at linux.vnet.ibm.com
Tue Aug 12 14:17:15 UTC 2014


The dh_sha256sums helper is included in this patch set for convience,
as it duplicates, with minimal changes to support sha256 hashes, the
existing dh_md5sums helper.  Subsequent posts should address this
duplication.
---
 dh            |   1 +
 dh_sha256sums | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+)
 create mode 100755 dh_sha256sums

diff --git a/dh b/dh
index 4f80f75..360cae0 100755
--- a/dh
+++ b/dh
@@ -409,6 +409,7 @@ my @b=qw{
 	dh_installdeb
 	dh_gencontrol
 	dh_md5sums
+	dh_sha256sums
 	dh_builddeb
 };
 $sequences{clean} = [qw{
diff --git a/dh_sha256sums b/dh_sha256sums
new file mode 100755
index 0000000..6d1607f
--- /dev/null
+++ b/dh_sha256sums
@@ -0,0 +1,101 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_sha256sums - generate DEBIAN/sha256sums file
+
+=cut
+
+use strict;
+use Cwd;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_sha256sums> [S<I<debhelper options>>] [B<-x>] [B<-X>I<item>] [B<--include-conffiles>]
+
+=head1 DESCRIPTION
+
+B<dh_sha256sums> is a debhelper program that is responsible for generating
+a F<DEBIAN/sha256sums> file, which lists the sha256sums of each file in the package.
+These files are used by the B<debsums> package.
+
+All files in F<DEBIAN/> are omitted from the F<sha256sums> file, as are all
+conffiles (unless you use the B<--include-conffiles> switch).
+
+The sha256sums file is installed with proper permissions and ownerships.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-x>, B<--include-conffiles>
+
+Include conffiles in the sha256sums list. Note that this information is
+redundant since it is included elsewhere in Debian packages.
+
+=item B<-X>I<item>, B<--exclude=>I<item>
+
+Exclude files that contain I<item> anywhere in their filename from
+being listed in the sha256sums file.
+
+=back
+
+=cut
+
+init(options => {
+	"x" => \$dh{INCLUDE_CONFFILES}, # is -x for some unknown historical reason..
+	"include-conffiles" => \$dh{INCLUDE_CONFFILES},
+});
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+
+	my $tmp=tmpdir($package);
+
+	if (! -d "$tmp/DEBIAN") {
+		doit("install","-d","$tmp/DEBIAN");
+	}
+
+	# Check if we should exclude conffiles.
+	my $exclude="";
+	if (! $dh{INCLUDE_CONFFILES} && -r "$tmp/DEBIAN/conffiles") {
+		# Generate exclude regexp.
+		open (CONFF,"$tmp/DEBIAN/conffiles");
+		while (<CONFF>) {
+			chomp;
+			s/^\///;
+			$exclude.="! -path \"./$_\" ";
+		}
+		close CONFF;
+	}
+
+	# See if we should exclude other files.
+	if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
+		$exclude.="! \\( $dh{EXCLUDE_FIND} \\) ";
+	}
+
+	my $find="find . -type f $exclude ! -regex './DEBIAN/.*' -printf '%P\\0'";
+	complex_doit("(cd $tmp >/dev/null ; $find | LC_ALL=C sort -z | xargs -r0 sha256sum > DEBIAN/sha256sums) >/dev/null");
+	# If the file's empty, no reason to waste inodes on it.
+	if (-z "$tmp/DEBIAN/sha256sums") {
+		doit("rm","-f","$tmp/DEBIAN/sha256sums");
+	}
+	else {
+		doit("chmod",644,"$tmp/DEBIAN/sha256sums");
+		doit("chown","0:0","$tmp/DEBIAN/sha256sums");
+	}
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Joey Hess <joeyh at debian.org>
+(Modified by Mimi Zohar <zohar at linux.vnet.ibm.com> to support sha256)
+
+=cut
-- 
1.8.1.4




More information about the debhelper-devel mailing list