[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#540215: Introduce dh_checksums

retitle 540215 Introduce dh_checksums
tag 540215 +patch

On Thu, 2010-03-04 at 20:08 +0100, Tollef Fog Heen wrote:
>  Frank Lin PIAT wrote:
> > What about a transitional dh_md5sums that would produce md5sum AND
> > invoke dh_sha ?
> Or call it dh_checksums or something so we don't have to change the tool
> name each time we decide to change the algorithm.


Find a patch attached, for a smooth transition from DEBIAN/md5sums to a
recent checksum.

The way it is implemented, is that the dh_md5sums is a symlink to the
new dh_checksums. The new helper computes both md5sum (for
compatibility/transition) and a new checksum (SHA256, which was already
chosen by FTP-masters as a remplacement for md5sum for signed files)

Note regarding the patch:
  I have tried to make the patch so it isn't too intrusive (for
  instance, dh_checksums is a symlink to dh_md5sums even though it
  should be the other way around).
  Your comments on the patch are obviously welcome (feel free to hack
  it your self if you want)

Any chance to merge it before squeeze Freeze?

>From 69799a95b470c19cd395c532356eeaa64bc1bac8 Mon Sep 17 00:00:00 2001
From: Frank Lin PIAT <fpiat@klabs.be>
Date: Mon, 8 Mar 2010 16:35:39 +0100
Subject: [PATCH] Implement dh_checksums.

 debian/copyright |    2 +-
 debian/links     |    3 +++
 dh               |    2 +-
 dh_md5sums       |   41 +++++++++++++++++++++++++++++++++--------
 4 files changed, 38 insertions(+), 10 deletions(-)
 create mode 100644 debian/links

diff --git a/debian/copyright b/debian/copyright
index a9f950d..162bfc0 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -48,7 +48,7 @@ Copyright: Steve Robbins <smr@debian.org>
 License: GPL-2+
 Files: dh_md5sums
-Copyright: Charles Briscoe-Smith <cpb4@ukc.ac.uk>
+Copyright: Charles Briscoe-Smith <cpb4@ukc.ac.uk>, Frank Lin PIAT <fpiat@klabs.be>
 License: GPL-2+
 Files: dh_bugfiles
diff --git a/debian/links b/debian/links
new file mode 100644
index 0000000..3e7d603
--- /dev/null
+++ b/debian/links
@@ -0,0 +1,3 @@
+usr/share/man/man1/dh_md5sums.1.gz usr/share/man/man1/dh_checksums.1.gz
+usr/bin/dh_md5sums usr/bin/dh_checksums
diff --git a/dh b/dh
index bcac8da..0aa9bc3 100755
--- a/dh
+++ b/dh
@@ -322,7 +322,7 @@ $sequences{install} = [@{$sequences{build}}, qw{
 my @b=qw{
-	dh_md5sums
+	dh_checksums
 $sequences{'binary-indep'} = [@{$sequences{install}}, @b];
diff --git a/dh_md5sums b/dh_md5sums
index da00090..33bf561 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -2,7 +2,7 @@
 =head1 NAME
-dh_md5sums - generate DEBIAN/md5sums file
+dh_checksums - generate DEBIAN/*sums files (md5, sha256)
@@ -12,18 +12,24 @@ use Debian::Debhelper::Dh_Lib;
 =head1 SYNOPSIS
+B<dh_checksums> [S<I<debhelper options>>] [B<-x>] [B<-X>I<item>] [B<--include-conffiles>]
 B<dh_md5sums> [S<I<debhelper options>>] [B<-x>] [B<-X>I<item>] [B<--include-conffiles>]
-dh_md5sums is a debhelper program that is responsible for generating
-a DEBIAN/md5sums file, which lists the md5sums of each file in the package.
-These files are used by the debsums package.
+dh_checksums is a debhelper program that is responsible for generating
+a DEBIAN/md5sums and DEBIAN/sha256sums files, which respectively lists the
+md5sums and sha256sums of each file in the package. These files are used
+by the debsums package.
-All files in DEBIAN/ are omitted from the md5sums file, as are all
+All files in DEBIAN/ are omitted from the checksums files, as are all
 conffiles (unless you use the --include-conffiles switch).
-The md5sums file is installed with proper permissions and ownerships.
+The checksums files are installed with proper permissions and ownerships.
+dh_md5sums is deprecated, you should use dh_checksums instead, which generates the
+type of checksums files recommended by the Debian policy.
 =head1 OPTIONS
@@ -37,7 +43,7 @@ redundant since it is included elsewhere in debian packages.
 =item B<-X>I<item>, B<--exclude=>I<item>
 Exclude files that contain "item" anywhere in their filename from
-being listed in the md5sums file.
+being listed in the checkums file.
@@ -48,15 +54,26 @@ init(options => {
 	"include-conffiles" => \$dh{INCLUDE_CONFFILES},
+my ($basename) = $0=~m:.*/(.+):;
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	next if is_udeb($package);
+	if (basename($0) == 'dh_md5sums') {
+		warning("This program should no longer be used. Please read the dh_checksums(1) man page.");
+	}
 	my $tmp=tmpdir($package);
 	if (! -d "$tmp/DEBIAN") {
+	# Detect if this is run multiple times (calling both dh_md5sums and dh_checksums?)
+	if (-f "$tmp/DEBIAN/md5sums" or -f "$tmp/DEBIAN/sha256sums") {
+		warning("Re-computing checksum file (even though md5sums and/or sha256sums exists)");
+	}
 	# Check if we should exclude conffiles.
 	my $exclude="";
 	if (! $dh{INCLUDE_CONFFILES} && -r "$tmp/DEBIAN/conffiles") {
@@ -76,6 +93,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	complex_doit("(cd $tmp >/dev/null ; find . -type f $exclude ! -regex '.*/DEBIAN/.*' -printf '%P\\0' | xargs -r0 md5sum > DEBIAN/md5sums) >/dev/null");
+	complex_doit("(cd $tmp >/dev/null ; find . -type f $exclude ! -regex '.*/DEBIAN/.*' -printf '%P\\0' | xargs -r0 sha256sum > DEBIAN/sha256sums) >/dev/null");
 	# If the file's empty, no reason to waste inodes on it.
 	if (-z "$tmp/DEBIAN/md5sums") {
@@ -84,6 +102,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
+	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

Reply to: