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

Re: Bug#540215: Introduce dh_checksums



Hello,

On Mon, 2010-03-08 at 17:36 +0100, Frank Lin PIAT wrote:
> 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.


Since SHA algorithms is a family, tools and API usually implement
multiple variants. Wouter's initial email suggested to use the name
shasums. I must admit I find this quite sensible for future
improvements. People should be encourage to detect and support SHA-224
and better hash, even though we should only accept sha256 in the archive
for now.

I have still named the helper "dh_checksums", because it we ever want to
ship a different algorithm, we would probably still use the same
(updated) helper to generate that file.

Find an updated patch attached.

Regards,
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_installdeb
 	dh_gencontrol
-	dh_md5sums
+	dh_checksums
 	dh_builddeb
 };
 $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)
 
 =cut
 
@@ -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>]
 
 =head1 DESCRIPTION
 
-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.
 
 =back
 
@@ -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") {
 		doit("install","-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") {
 		doit("rm","-f","$tmp/DEBIAN/md5sums");
@@ -84,6 +102,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("chmod",644,"$tmp/DEBIAN/md5sums");
 		doit("chown","0:0","$tmp/DEBIAN/md5sums");
 	}
+	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
-- 
1.7.0


Reply to: