]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_md5sums
r338: * Patch from Jorgen `forcer' Schaefer <forcer at mindless.com> (much
[debhelper.git] / dh_md5sums
index 634e2fd6c0bf8c4faa93b1deb279999db9b62e61..9a3354de0d30d1767d297d73d224e19bc17e0013 100755 (executable)
@@ -1,22 +1,45 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
-# Generate a DEBIAN/md5sums file, that lists the md5sums of all
-# non-conffiles in the package
+# Generate a DEBIAN/md5sums file, that lists the md5sums of all files in the
+# package.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+use Cwd;
+use Debian::Debhelper::Dh_Lib;
+init();
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
 
-       if [ ! -d "debian/$TMP/DEBIAN" ]; then
-               doit "install -d debian/$TMP/DEBIAN"
-       fi
+       if (! -d "$TMP/DEBIAN") {
+               doit("install","-d","$TMP/DEBIAN");
+       }
 
-       doit "pushd debian/$TMP" >/dev/null
-       # Doit isn't smart enough to hande this next command so echo by hand. (sigh)
-       verbose_echo 'md5sum `find * -type f ! -regex "^DEBIAN/.*"` > DEBIAN/md5sums </dev/null'
-       md5sum `find * -type f ! -regex "^DEBIAN/.*"` >DEBIAN/md5sums </dev/null
-       doit "chown root.root DEBIAN/md5sums"
-       doit "popd 2>/dev/null" >/dev/null 
-done
+       # Check if we should exclude conffiles.
+       my $exclude="";
+       if (! $dh{INCLUDE} && -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} \\) ";
+       }
+       
+       $olddir=getcwd();
+       complex_doit("cd $TMP >/dev/null ; find * -type f $exclude ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums ; cd $olddir >/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");
+       }
+       else {
+               doit("chmod",644,"$TMP/DEBIAN/md5sums");
+               doit("chown","root.root","$TMP/DEBIAN/md5sums");
+       }
+}