diff options
Diffstat (limited to 'dh_md5sums')
-rwxr-xr-x | dh_md5sums | 57 |
1 files changed, 40 insertions, 17 deletions
@@ -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"); + } +} |