]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_install
r538: * Make dh_installchangelogs install debian/NEWS files as well, as
[debhelper.git] / dh_install
index b3dab4c1a7b54a07a47c0413eb64e182c59ed040..845884076cf6c4edaa9db72e046027615581d3e0 100755 (executable)
@@ -7,11 +7,12 @@ dh_install - install files into package build directories
 =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
 
@@ -30,7 +31,7 @@ the line tells the directory it should be installed in. The name of the
 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
@@ -65,6 +66,31 @@ Note that if you list only a filename on a line by itself in a
 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.
@@ -76,17 +102,20 @@ The files will be installed into the first package dh_install acts on.
 
 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];
        }
@@ -94,7 +123,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
        # Support for -X flag.
        my $exclude = '';
        if ($dh{EXCLUDE_FIND}) {
-               $exclude = ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
+               $exclude = '-and ! \( '.$dh{EXCLUDE_FIND}.' \)';
        }
        
        foreach my $set (@install) {
@@ -103,8 +132,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
                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) {
@@ -119,12 +148,21 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
                                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/");
@@ -133,6 +171,20 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
        }
 }
 
+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)>