3 # Move files out of debian/tmp, into subpackages.
5 use Debian::Debhelper::Dh_Lib;
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11 $TMP=tmpdir($PACKAGE);
12 $files=pkgfile($PACKAGE,"files");
15 if ($dh{SOURCEDIR}=~m:^/:) {
16 error("The sourcedir must be a relative filename, not starting with `/'.");
18 $sourcedir=$dh{SOURCEDIR};
21 $sourcedir="debian/tmp";
24 if (! -d $sourcedir) {
25 error("$sourcedir does not exist.");
30 # debian/files has a different purpose, so ignore it.
31 if ( $files && $files ne "debian/files" ) {
32 @tomove=filearray($files, $sourcedir);
35 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
39 if (@tomove && $TMP eq $sourcedir) {
40 error("I was asked to move files from $sourcedir to $sourcedir. Perhaps you should set DH_COMAPT=2?");
43 # Now we need to expand wildcards in @tomove.
44 # This is only necessary in pre-v3 land -- as of v3, the
45 # expension is automatically done by filearray().
46 if (@tomove && Debian::Debhelper::Dh_Lib::compat(2)) {
49 push @filelist, glob("$sourcedir/$_");
56 doit("install","-d",$TMP);
59 doit("rm","-f","debian/movelist");
62 if (! -e $file && ! -l $file) {
64 warning("$file not found");
66 $file=~s:^\Q$sourcedir\E/+::;
67 complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -print || true) >> debian/movelist");
69 complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=../movelist --file -) | (cd $TMP >/dev/null ;tar xpf -)");
70 doit("rm","-f","debian/movelist");
74 # If $ret is set, we wern't actually able to find some
75 # files that were specified to be moved, and we should
76 # exit with the code in $ret. This program puts off
77 # exiting with an error until all files have been tried
78 # to be moved, because this makes it easier for some
79 # packages that arn't always sure exactly which files need