]> git.donarmstrong.com Git - debhelper.git/blob - dh_md5sums
r420: big monsta changes
[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 strict;
7 use Cwd;
8 use Debian::Debhelper::Dh_Lib;
9 init();
10
11 foreach my $package (@{$dh{DOPACKAGES}}) {
12         my $tmp=tmpdir($package);
13
14         if (! -d "$tmp/DEBIAN") {
15                 doit("install","-d","$tmp/DEBIAN");
16         }
17
18         # Check if we should exclude conffiles.
19         my $exclude="";
20         if (! $dh{INCLUDE} && -r "$tmp/DEBIAN/conffiles") {
21                 # Generate exclude regexp.
22                 open (CONFF,"$tmp/DEBIAN/conffiles");
23                 while (<CONFF>) {
24                         chomp;
25                         s/^\///;
26                         $exclude.="! -path \"$_\" ";
27                 }
28                 close CONFF;
29         }
30         
31         # See if we should exclude other files.
32         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
33                 $exclude.="! \\( $dh{EXCLUDE_FIND} \\) ";
34         }
35         
36         my $olddir=getcwd();
37         complex_doit("cd $tmp >/dev/null ; find * -type f $exclude ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums ; cd $olddir >/dev/null");
38         # If the file's empty, no reason to waste inodes on it.
39         if (-z "$tmp/DEBIAN/md5sums") {
40                 doit("rm","-f","$tmp/DEBIAN/md5sums");
41         }
42         else {
43                 doit("chmod",644,"$tmp/DEBIAN/md5sums");
44                 doit("chown","0.0","$tmp/DEBIAN/md5sums");
45         }
46 }