5 dh_install - install files into package build directories
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_install> [B<-X>I<item>] [S<I<debhelper options>>] [S<I<file [...] dest>>]
18 dh_install is a debhelper program that handles installing files into package
19 build directories. There are many dh_install* commands that handle installing
20 specific types of files such as documentation, examples, man pages, and so on,
21 and they should be used when possible as they often have extra intelligence for
22 those particular tasks. dh_install, then, is useful for installing everything
23 else, for which no particular intelligence is needed. It is a replacement for
24 the old dh_movefiles command.
26 Files named debian/package.install list the files to install into each
27 package and where they should be installed to. The format is a set of
28 lines, where each line lists a file or files to install, and at the end of
29 the line tells the directory it should be installed in. The name of the
30 files (or directories) to install should be given relative to the current
31 directory, while the installation directory is given relative to the
32 package build directory. You may use wildcards in the names of the files to
33 install (in v3 mode and above).
35 This program may be used in one of two ways. If you just have a file or two
36 that the upstream Makefile does not install for you, you can run dh_install
37 on them to move them into place. On the other hand, maybe you have a large
38 package that builds multiple binary packages. You can use the upstream Makefile
39 to install it all into debian/tmp, and then use dh_install to copy
40 directories and files from there into the proper package build directories.
46 =item B<-Xitem>, B<--exclude=item>
48 Exclude files that contain "item" anywhere in their filename from
53 Guess as the destination directory to install things to. If this is
54 specified, you should not list destination directories in
55 debian/package.install files or on the command line. Instead, dh_install
56 will guess as follows:
58 Strip off debian/tmp from the front of the filename, of it is present, and
59 install into the dirname of the filename. So if the filename is
60 debian/tmp/usr/bin, then that directory will be copied to
61 debian/package/usr/. If the filename is debian/tmp/etc/passwd, it will be
62 copied to debian/package/etc/.
64 Note that if you list only a filename on a line by itself in a
65 debian/package.install file, with no explicit destination, then dh_install
66 will automatically guess the destination even if this flag is not set.
68 =item B<--sourcedir=dir>
70 Makes all source files relative to "dir". If this is specified, it is akin
71 to all the source files having "dir" prepended to them. By default, "dir"
74 To make dh_install behave like the old dh_movefiles, move your
75 package.files file to package.install and call dh_install with
76 "--sourcedir=debian/tmp" appended to the command. This will
77 approximate dh_movefiles behaviour, except it will copy files instead
80 =item I<file [...] dest>
82 Lists files (or directories) to install and where to install them to.
83 The files will be installed into the first package dh_install acts on.
93 foreach my $package (@{$dh{DOPACKAGES}}) {
94 my $tmp=tmpdir($package);
95 my $file=pkgfile($package,"install");
100 @install=filedoublearray($file); # no globbing yet
103 $srcdir = $dh{SOURCEDIR}."/" if defined $dh{SOURCEDIR};
105 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
106 push @install, [@ARGV];
109 # Support for -X flag.
111 if ($dh{EXCLUDE_FIND}) {
112 $exclude = ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
115 foreach my $set (@install) {
118 if (! defined $dh{AUTODEST} && @$set > 1) {
121 # glob now, relative to srcdir
122 foreach my $src (map { glob "$srcdir/$_" } @$set) {
123 next if excludefile($src);
125 if (! defined $dest) {
126 # Guess at destination directory.
128 $dest=~s/^(.*\/)?debian\/tmp//;
129 $dest=dirname($dest);
132 # Make sure the destination directory exists.
133 if (! -e "$tmp/$dest") {
134 doit("install","-d","$tmp/$dest");
137 if (-d $src && $exclude) {
138 my ($dir_basename) = basename($src);
139 # Pity there's no cp --exclude ..
142 complex_doit("cd $src/.. && find $dir_basename -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/$dest/ \\;");
145 doit("cp", "-a", $src, "$tmp/$dest/");
155 This program is a part of debhelper.
159 Joey Hess <joeyh@debian.org>