5 dh_movefiles - move files out of debian/tmp into subpackages
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_movefiles> [S<I<debhelper options>>] [B<--sourcedir=>I<dir>] [S<I<file ...>>]
18 dh_movefiles is a debhelper program that is responsible for moving files
19 out of debian/tmp or some other directory and into other package build
20 directories. This may be useful if your package has a Makefile that installs
21 everything into debian/tmp, and you need to break that up into subpackages.
23 Files named debian/package.files list the files to be moved, separated by
24 whitespace. The filenames listed should be relative to debian/tmp/. You can
25 also list directory names, and the whole directory will be moved. If you
26 prefer, you can list the files to move on the command line and this will
27 apply to the first package dh_movefiles is told to act on.
29 Note: dh_install is a much better program that can do everything this one can,
36 =item B<--sourcedir=>I<dir>
38 Instead of moving files out of debian/tmp (the default), this option makes
39 it move files out of some other directory. Since the entire contents of
40 the sourcedir is moved, specifiying something like --sourcedir=/ is very
41 unsafe, so to prevent mistakes, the sourcedir must be a relative filename;
42 it cannot begin with a `/'.
46 Lists files to move. The filenames listed should be relative to
47 debian/tmp/. You can also list directory names, and the whole directory will
48 be moved. It is an error to list files here unless you use -p, -i, or -a to
49 tell dh_movefiles which subpackage to put them in.
55 Note that files are always moved out of debian/tmp by default (even if you
56 have instructed debhelper to use a compatibility level higher than one,
57 which does not otherwise use debian/tmp for anything at all). The idea
58 behind this is that the package that is being built can be told to install
59 into debian/tmp, and then files can be moved by dh_movefiles from that
60 directory. Any files or directories that remain are ignored, and get
61 deleted by dh_clean later.
69 foreach my $package (@{$dh{DOPACKAGES}}) {
70 my $tmp=tmpdir($package);
71 my $files=pkgfile($package,"files");
73 my $sourcedir="debian/tmp";
75 if ($dh{SOURCEDIR}=~m:^/:) {
76 error("The sourcedir must be a relative filename, not starting with `/'.");
78 $sourcedir=$dh{SOURCEDIR};
81 if (! -d $sourcedir) {
82 error("$sourcedir does not exist.");
87 # debian/files has a different purpose, so ignore it.
88 if ($files && $files ne "debian/files" ) {
89 @tomove=filearray($files, $sourcedir);
92 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
96 if (@tomove && $tmp eq $sourcedir) {
97 error("I was asked to move files from $sourcedir to $sourcedir. Perhaps you should set DH_COMPAT=2?");
100 # Now we need to expand wildcards in @tomove.
101 # This is only necessary in pre-v3 land -- as of v3, the
102 # expension is automatically done by filearray().
103 if (@tomove && compat(2)) {
106 push @filelist, glob("$sourcedir/$_");
111 # However, filearray() does not add the sourcedir,
113 @tomove = map { "$sourcedir/$_" } @tomove;
118 doit("install","-d",$tmp);
121 doit("rm","-f","debian/movelist");
124 if (! -e $file && ! -l $file) {
126 warning("$file not found (supposed to put it in $package)");
128 $file=~s:^\Q$sourcedir\E/+::;
129 complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -print || true) >> debian/movelist");
133 complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=$pwd/debian/movelist --file -) | (cd $tmp >/dev/null ;tar xpf -)");
134 doit("rm","-f","debian/movelist");
138 # If $ret is set, we wern't actually able to find some
139 # files that were specified to be moved, and we should
140 # exit with the code in $ret. This program puts off
141 # exiting with an error until all files have been tried
142 # to be moved, because this makes it easier for some
143 # packages that arn't always sure exactly which files need
151 This program is a part of debhelper.
155 Joey Hess <joeyh@debian.org>