]> git.donarmstrong.com Git - debhelper.git/blob - dh_md5sums
r496: * Man page cleanups, Closes: #119335
[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
22 All files in DEBIAN/ are omitted from the md5sums file, as are all
23 conffiles (unless you use the --include-conffiles switch).
24
25 The md5sums file is installed with proper permissions and ownerships.
26
27 =head1 OPTIONS
28
29 =over 4
30
31 =item B<-x>, B<--include-conffiles>
32
33 Include conffiles in the md5sums list. Note that this information is
34 redundant since it is included elsewhere in debian packages.
35
36 =item B<-X>I<item>, B<--exclude=>I<item>
37
38 Exclude files that contain "item" anywhere in their filename from
39 being listed in the md5sums file.
40
41 =back
42
43 =cut
44
45 init();
46
47 foreach my $package (@{$dh{DOPACKAGES}}) {
48         my $tmp=tmpdir($package);
49
50         if (! -d "$tmp/DEBIAN") {
51                 doit("install","-d","$tmp/DEBIAN");
52         }
53
54         # Check if we should exclude conffiles.
55         my $exclude="";
56         if (! $dh{INCLUDE} && -r "$tmp/DEBIAN/conffiles") {
57                 # Generate exclude regexp.
58                 open (CONFF,"$tmp/DEBIAN/conffiles");
59                 while (<CONFF>) {
60                         chomp;
61                         s/^\///;
62                         $exclude.="! -path \"$_\" ";
63                 }
64                 close CONFF;
65         }
66         
67         # See if we should exclude other files.
68         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
69                 $exclude.="! \\( $dh{EXCLUDE_FIND} \\) ";
70         }
71         
72         my $olddir=getcwd();
73         complex_doit("cd $tmp >/dev/null ; find * -type f $exclude ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums ; cd '$olddir' >/dev/null");
74         # If the file's empty, no reason to waste inodes on it.
75         if (-z "$tmp/DEBIAN/md5sums") {
76                 doit("rm","-f","$tmp/DEBIAN/md5sums");
77         }
78         else {
79                 doit("chmod",644,"$tmp/DEBIAN/md5sums");
80                 doit("chown","0.0","$tmp/DEBIAN/md5sums");
81         }
82 }
83
84 =head1 SEE ALSO
85
86 L<debhelper(1)>
87
88 This program is a part of debhelper.
89
90 =head1 AUTHOR
91
92 Joey Hess <joeyh@debian.org>
93
94 =cut