]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_md5sums
r775: This commit was manufactured by cvs2svn to create tag
[debhelper.git] / dh_md5sums
index ae4709265a5766f59d7440abd278f4558ffa666e..80b5f4794f9f3014af5d4621a40c2722f931ba61 100755 (executable)
@@ -1,26 +1,46 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # 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;
+BEGIN { push @INC, "debian", "/usr/share/debhelper" }
+use Dh_Lib;
+init();
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
 
-       if [ ! -d "$TMP/DEBIAN" ]; then
-               doit "install -d $TMP/DEBIAN"
-       fi
+       if (! -d "$TMP/DEBIAN") {
+               doit("install","-d","$TMP/DEBIAN");
+       }
 
-       complex_doit "find $TMP/* -type f ! -regex '^$TMP/DEBIAN/.*' | sed s:$TMP:: | sort > $TMP/DEBIAN/allfiles"
        # Check if we should exclude conffiles.
-       if [ ! "$DH_EXCLUDE" -a -r $TMP/DEBIAN/conffiles ]; then
-               complex_doit "sort $TMP/DEBIAN/conffiles | comm -13 - $TMP/DEBIAN/allfiles > $TMP/DEBIAN/allfiles.new"
-               doit "mv $TMP/DEBIAN/allfiles.new $TMP/DEBIAN/allfiles"
-       fi
-       olddir=`pwd`
-       complex_doit "cd $TMP ; sed 's:^/::' < DEBIAN/allfiles | xargs md5sum > DEBIAN/md5sums ; cd $olddir"
-       doit "chown root.root $TMP/DEBIAN/md5sums"
-       doit "rm -f $TMP/DEBIAN/allfiles"
-done
+       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");
+       }
+}