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>] [B<-X>I<item>] 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 `/'.
44 =item B<-Xitem>, B<--exclude=item>
46 Exclude files that contain "item" anywhere in their filename from
51 Lists files to move. The filenames listed should be relative to
52 debian/tmp/. You can also list directory names, and the whole directory will
53 be moved. It is an error to list files here unless you use -p, -i, or -a to
54 tell dh_movefiles which subpackage to put them in.
60 Note that files are always moved out of debian/tmp by default (even if you
61 have instructed debhelper to use a compatibility level higher than one,
62 which does not otherwise use debian/tmp for anything at all). The idea
63 behind this is that the package that is being built can be told to install
64 into debian/tmp, and then files can be moved by dh_movefiles from that
65 directory. Any files or directories that remain are ignored, and get
66 deleted by dh_clean later.
74 foreach my $package (@{$dh{DOPACKAGES}}) {
75 my $tmp=tmpdir($package);
76 my $files=pkgfile($package,"files");
78 my $sourcedir="debian/tmp";
80 if ($dh{SOURCEDIR}=~m:^/:) {
81 error("The sourcedir must be a relative filename, not starting with `/'.");
83 $sourcedir=$dh{SOURCEDIR};
86 if (! -d $sourcedir) {
87 error("$sourcedir does not exist.");
92 # debian/files has a different purpose, so ignore it.
93 if ($files && $files ne "debian/files" ) {
94 @tomove=filearray($files, $sourcedir);
97 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
101 if (@tomove && $tmp eq $sourcedir) {
102 error("I was asked to move files from $sourcedir to $sourcedir. Perhaps you should set DH_COMPAT=2?");
105 # Now we need to expand wildcards in @tomove.
106 # This is only necessary in pre-v3 land -- as of v3, the
107 # expension is automatically done by filearray().
108 if (@tomove && compat(2)) {
111 push @filelist, glob("$sourcedir/$_");
116 # However, filearray() does not add the sourcedir,
118 @tomove = map { "$sourcedir/$_" } @tomove;
123 doit("install","-d",$tmp);
126 doit("rm","-f","debian/movelist");
129 if (! -e $file && ! -l $file && ! $dh{NO_ACT}) {
131 warning("$file not found (supposed to put it in $package)");
133 $file=~s:^\Q$sourcedir\E/+::;
134 my $cmd="(cd $sourcedir >/dev/null ; find $file ! -type d ";
135 if ($dh{EXCLUDE_FIND}) {
136 $cmd.="-a ! \\( $dh{EXCLUDE_FIND} \\) ";
138 $cmd.="-print || true) >> debian/movelist";
143 complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=$pwd/debian/movelist --file -) | (cd $tmp >/dev/null ;tar xpf -)");
144 doit("rm","-f","debian/movelist");
148 # If $ret is set, we wern't actually able to find some
149 # files that were specified to be moved, and we should
150 # exit with the code in $ret. This program puts off
151 # exiting with an error until all files have been tried
152 # to be moved, because this makes it easier for some
153 # packages that arn't always sure exactly which files need
161 This program is a part of debhelper.
165 Joey Hess <joeyh@debian.org>