=cut
use strict;
+use File::Find;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
-B<dh_install> [B<-X>I<item>] [S<I<debhelper options>>] [S<I<file [...] dest>>]
+B<dh_install> [B<-X>I<item>] [B<--sutodest>] [B<--list-missing>] [S<I<debhelper options>>] [S<I<file [...] dest>>]
=head1 DESCRIPTION
files (or directories) to install should be given relative to the current
directory, while the installation directory is given relative to the
package build directory. You may use wildcards in the names of the files to
-install.
+install (in v3 mode and above).
This program may be used in one of two ways. If you just have a file or two
that the upstream Makefile does not install for you, you can run dh_install
debian/package.install file, with no explicit destination, then dh_install
will automatically guess the destination even if this flag is not set.
+=item B<--list-missing>
+
+This option makes dh_install keep track of the files it installs, and then at
+the end, compare that list with the files in debian/tmp. If any of the files
+(and symlinks) in debian/tmp were not installed to somewhere, it will
+warn on stderr about that.
+
+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.
+
+Note that files that are excluded from being moved via the -X option are not
+warned about.
+
+=item B<--sourcedir=dir>
+
+Makes all source files relative to "dir". If this is specified, it is akin
+to all the source files having "dir" prepended to them. By default, "dir"
+is '.'.
+
+To make dh_install behave like the old dh_movefiles, move your
+package.files file to package.install and call dh_install with
+"--sourcedir=debian/tmp" appended to the command. This will
+approximate dh_movefiles behaviour, except it will copy files instead
+of moving them.
+
=item I<file [...] dest>
Lists files (or directories) to install and where to install them to.
init();
-my $ret=0;
+my @installed;
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmp=tmpdir($package);
my $file=pkgfile($package,"install");
+ my $srcdir = '.';
my @install;
if ($file) {
- @install=filedoublearray($file, ".");
+ @install=filedoublearray($file); # no globbing yet
}
+ $srcdir = $dh{SOURCEDIR}."/" if defined $dh{SOURCEDIR};
+
if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
push @install, [@ARGV];
}
# Support for -X flag.
my $exclude = '';
if ($dh{EXCLUDE_FIND}) {
- $exclude = ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
+ $exclude = '-and ! \( '.$dh{EXCLUDE_FIND}.' \)';
}
foreach my $set (@install) {
if (! defined $dh{AUTODEST} && @$set > 1) {
$dest=pop @$set;
}
-
- foreach my $src (@$set) {
+ # glob now, relative to srcdir
+ foreach my $src (map { glob "$srcdir/$_" } @$set) {
next if excludefile($src);
if (! defined $dest) {
doit("install","-d","$tmp/$dest");
}
+ # Keep track of what's installed.
+ if ($dh{LIST_MISSING}) {
+ # Kill any extra slashes. Makes the
+ # @installed stuff more robust.
+ $src=~y:/:/:s;
+ $src=~s:/+$::;
+ push @installed, "\Q$src\E\/.*|\Q$src\E";
+ }
+
if (-d $src && $exclude) {
my ($dir_basename) = basename($src);
# Pity there's no cp --exclude ..
my $pwd=`pwd`;
chomp $pwd;
- complex_doit("cd $src/.. && find $dir_basename -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/$dest/ \\;");
+ complex_doit("cd $src/.. && find $dir_basename \\( -type f -or -type l \\) $exclude -exec cp --parents -dp {} $pwd/$tmp/$dest/ \\;");
}
else {
doit("cp", "-a", $src, "$tmp/$dest/");
}
}
+if ($dh{LIST_MISSING}) {
+ my @missing;
+ my $installed=join("|", @installed);
+ $installed=qr{^$installed$};
+ find(sub {
+ -f || -l || return;
+ $_="$File::Find::dir/$_";
+ push @missing, $_ unless /$installed/;
+ }, './debian/tmp');
+ if (@missing) {
+ warning "$_ not installed" foreach @missing;
+ }
+}
+
=head1 SEE ALSO
L<debhelper(1)>