]> git.donarmstrong.com Git - debhelper.git/blob - dh_md5sums
r1590: * Converted several chown 0.0 to chown 0:0 for POSIX 200112.
[debhelper.git] / dh_md5sums
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_md5sums - generate DEBIAN/md5sums file
6
7 =cut
8
9 use strict;
10 use Cwd;
11 use Debian::Debhelper::Dh_Lib;
12
13 =head1 SYNOPSIS
14
15 B<dh_md5sums> [S<I<debhelper options>>] [B<-x>] [B<-X>I<item>] [B<--include-conffiles>]
16
17 =head1 DESCRIPTION
18
19 dh_md5sums is a debhelper program that is responsible for generating
20 a DEBIAN/md5sums file, which lists the md5sums of each file in the package.
21 These files are used by the debsums package.
22
23 All files in DEBIAN/ are omitted from the md5sums file, as are all
24 conffiles (unless you use the --include-conffiles switch).
25
26 The md5sums file is installed with proper permissions and ownerships.
27
28 =head1 OPTIONS
29
30 =over 4
31
32 =item B<-x>, B<--include-conffiles>
33
34 Include conffiles in the md5sums list. Note that this information is
35 redundant since it is included elsewhere in debian packages.
36
37 =item B<-X>I<item>, B<--exclude=>I<item>
38
39 Exclude files that contain "item" anywhere in their filename from
40 being listed in the md5sums file.
41
42 =back
43
44 =cut
45
46 init();
47
48 foreach my $package (@{$dh{DOPACKAGES}}) {
49         my $tmp=tmpdir($package);
50
51         if (! -d "$tmp/DEBIAN") {
52                 doit("install","-d","$tmp/DEBIAN");
53         }
54
55         # Check if we should exclude conffiles.
56         my $exclude="";
57         if (! $dh{INCLUDE_CONFFILES} && -r "$tmp/DEBIAN/conffiles") {
58                 # Generate exclude regexp.
59                 open (CONFF,"$tmp/DEBIAN/conffiles");
60                 while (<CONFF>) {
61                         chomp;
62                         s/^\///;
63                         $exclude.="! -path \"$_\" ";
64                 }
65                 close CONFF;
66         }
67         
68         # See if we should exclude other files.
69         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
70                 $exclude.="! \\( $dh{EXCLUDE_FIND} \\) ";
71         }
72         
73         my $olddir=getcwd();
74         complex_doit("cd $tmp >/dev/null ; find . -type f $exclude ! -regex '.*/DEBIAN/.*' -printf '%P\\0' | xargs -r0 md5sum > DEBIAN/md5sums ; cd '$olddir' >/dev/null");
75         # If the file's empty, no reason to waste inodes on it.
76         if (-z "$tmp/DEBIAN/md5sums") {
77                 doit("rm","-f","$tmp/DEBIAN/md5sums");
78         }
79         else {
80                 doit("chmod",644,"$tmp/DEBIAN/md5sums");
81                 doit("chown","0:0","$tmp/DEBIAN/md5sums");
82         }
83 }
84
85 =head1 SEE ALSO
86
87 L<debhelper(7)>
88
89 This program is a part of debhelper.
90
91 =head1 AUTHOR
92
93 Joey Hess <joeyh@debian.org>
94
95 =cut