1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
#!/usr/bin/perl
=head1 NAME
dh_missing - check for missing files
=cut
use strict;
use warnings;
use File::Find;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<dh_missing> [B<-X>I<item>] [B<--sourcedir=>I<dir>] [S<I<debhelper options>>]
=head1 DESCRIPTION
B<dh_missing> compares the list of installed files with the files in
the source directory. If any of the files (and symlinks) in the source
directory were not installed to somewhere, it will warn on stderr
about that (B<--list-missing>) or fail (B<--fail-missing>). Please
note that without either of these options, B<dh_missing> will silently
do nothing.
This may be useful if you have a large package and want to make sure that
you don't miss installing newly added files in new upstream releases.
Remember to test different kinds of builds (dpkg-buildpackage -A/-B/...) as
you may experience varying results when only a subset of the packages are
built.
=head1 FILES
=over 4
=item debian/not-installed
List the files that are deliberately not installed in I<any> binary
package. Paths listed in this file are ignored by B<dh_missing>.
However, it is B<not> a method to exclude files from being installed
by B<dh_install>. Please use the B<--exclude> B<dh_install> option for
that.
Please keep in mind that B<dh_missing> will B<not> expand wildcards in
this file.
=back
=head1 OPTIONS
=over 4
=item B<--list-missing>
Warn on stderr about source files not installed to somewhere.
Note that files that are excluded from being moved via the B<-X> option are not
warned about.
=item B<--fail-missing>
This option is like B<--list-missing>, except if a file was missed, it will
not only list the missing files, but also fail with a nonzero exit code.
=back
=cut
init(options => {
"list-missing" => \$dh{LIST_MISSING},
"fail-missing" => \$dh{FAIL_MISSING},
"sourcedir=s" => \$dh{SOURCEDIR},
});
my (@installed, %helpers);
my $srcdir = '.';
$srcdir = $dh{SOURCEDIR} if defined $dh{SOURCEDIR};
if (!$dh{LIST_MISSING} && !$dh{FAIL_MISSING}) {
exit 0;
}
# . as srcdir makes no sense, so this is a special case.
if ($srcdir eq '.') {
$srcdir='debian/tmp';
}
if (! -d $srcdir) {
if (scalar(getpackages()) == 1 && not defined($dh{SOURCEDIR})) {
warning("$srcdir does not exist and there is only binary package.");
warning("Assuming everything is installed directly into the package directory.");
exit(0);
}
if (compat(10)) {
# Prevent "dh $@ --list-missing --destdir=..." from failing in compat 10.
warning("Cannot check if installation is missing files: $srcdir does not exist");
exit(0);
} else {
error("Cannot check if installation is missing files: $srcdir does not exist");
}
}
for my $file (<debian/.debhelper/generated/*/installed-by-*>) {
my ($target_pkg, $helper) = ('unknown', 'unknown');
my $had_files = 0;
my %seen;
if ($file =~ m@.*/([^/]+)/installed-by-(.*)@) {
($target_pkg, $helper) = ($1, $2);
}
open(my $fh, '<', $file) or die "could not open $file: $!";
while (my $line = <$fh>) {
chomp($line);
next if $line =~ m/^\s*$/;
next if $seen{$line}++; # Ignore duplicates
$had_files++;
push(@installed, $line);
}
$helpers{$helper}{$target_pkg} = $had_files;
close($fh);
}
my @missing;
if ( -f 'debian/not-installed') {
my @not_installed = filearray('debian/not-installed');
foreach (@not_installed) {
s:^\s*:debian/tmp/: unless m:^\s*debian/tmp/:;
}
# Pretend that these are also installed.
push(@installed, @not_installed);
}
my $installed=join("|", map {
# Kill any extra slashes, for robustness.
y:/:/:s;
s:/+$::;
s:^(\./)*::;
"\Q$_\E\/.*|\Q$_\E";
} @installed);
$installed=qr{^($installed)$};
find(sub {
-f || -l || return;
$_="$File::Find::dir/$_";
if (! /$installed/ && ! excludefile($_)) {
my $file=$_;
$file=~s/^\Q$srcdir\E\///;
push @missing, $file;
}
}, $srcdir);
if (@missing) {
warning "$_ exists in $srcdir but is not installed to anywhere" foreach @missing;
nonquiet_print("The following debhelper tools have reported what they installed (with files per package)");
for my $helper (sort(keys(%helpers))) {
my $pkg_info = $helpers{$helper};
my @results;
for my $pkg (sort(keys(%{$pkg_info}))) {
my $no = $pkg_info->{$pkg};
push(@results, "${pkg} (${no})")
}
nonquiet_print(" * ${helper}: " . join(', ', @results));
}
nonquiet_print("If the missing files are installed by another tool, please file a bug against it.");
nonquiet_print("Be sure to test with dpkg-buildpackage -A/-B as the results may vary when only a subset is built");
nonquiet_print("For a short-term work-around: Add the files to debian/not-installed");
if ($dh{FAIL_MISSING}) {
error("missing files, aborting");
}
}
=head1 SEE ALSO
L<debhelper(7)>
This program is a part of debhelper.
=head1 AUTHOR
Michael Stapelberg <stapelberg@debian.org>
=cut
# Local Variables:
# indent-tabs-mode: t
# tab-width: 4
# cperl-indent-level: 4
# End:
|