]> git.donarmstrong.com Git - debhelper.git/blob - dh_md5sums
r338: * Patch from Jorgen `forcer' Schaefer <forcer at mindless.com> (much
[debhelper.git] / dh_md5sums
1 #!/usr/bin/perl -w
2 #
3 # Generate a DEBIAN/md5sums file, that lists the md5sums of all files in the
4 # package.
5
6 use Cwd;
7 use Debian::Debhelper::Dh_Lib;
8 init();
9
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11         $TMP=tmpdir($PACKAGE);
12
13         if (! -d "$TMP/DEBIAN") {
14                 doit("install","-d","$TMP/DEBIAN");
15         }
16
17         # Check if we should exclude conffiles.
18         my $exclude="";
19         if (! $dh{INCLUDE} && -r "$TMP/DEBIAN/conffiles") {
20                 # Generate exclude regexp.
21                 open (CONFF,"$TMP/DEBIAN/conffiles");
22                 while (<CONFF>) {
23                         chomp;
24                         s/^\///;
25                         $exclude.="! -path \"$_\" ";
26                 }
27                 close CONFF;
28         }
29         
30         # See if we should exclude other files.
31         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
32                 $exclude.="! \\( $dh{EXCLUDE_FIND} \\) ";
33         }
34         
35         $olddir=getcwd();
36         complex_doit("cd $TMP >/dev/null ; find * -type f $exclude ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums ; cd $olddir >/dev/null");
37         # If the file's empty, no reason to waste inodes on it.
38         if (-z "$TMP/DEBIAN/md5sums") {
39                 doit("rm","-f","$TMP/DEBIAN/md5sums");
40         }
41         else {
42                 doit("chmod",644,"$TMP/DEBIAN/md5sums");
43                 doit("chown","root.root","$TMP/DEBIAN/md5sums");
44         }
45 }