3 # Move files out of debian/tmp, into subpackages.
6 use Debian::Debhelper::Dh_Lib;
11 foreach my $package (@{$dh{DOPACKAGES}}) {
12 my $tmp=tmpdir($package);
13 my $files=pkgfile($package,"files");
15 my $sourcedir="debian/tmp";
17 if ($dh{SOURCEDIR}=~m:^/:) {
18 error("The sourcedir must be a relative filename, not starting with `/'.");
20 $sourcedir=$dh{SOURCEDIR};
23 if (! -d $sourcedir) {
24 error("$sourcedir does not exist.");
29 # debian/files has a different purpose, so ignore it.
30 if ($files && $files ne "debian/files" ) {
31 @tomove=filearray($files, $sourcedir);
34 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
38 if (@tomove && $tmp eq $sourcedir) {
39 error("I was asked to move files from $sourcedir to $sourcedir. Perhaps you should set DH_COMAPT=2?");
42 # Now we need to expand wildcards in @tomove.
43 # This is only necessary in pre-v3 land -- as of v3, the
44 # expension is automatically done by filearray().
45 if (@tomove && compat(2)) {
48 push @filelist, glob("$sourcedir/$_");
53 # However, filearray() does not add the sourcedir,
55 @tomove = map { "$sourcedir/$_" } @tomove;
60 doit("install","-d",$tmp);
63 doit("rm","-f","debian/movelist");
66 if (! -e $file && ! -l $file) {
68 warning("$file not found");
70 $file=~s:^\Q$sourcedir\E/+::;
71 complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -print || true) >> debian/movelist");
73 complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=../movelist --file -) | (cd $tmp >/dev/null ;tar xpf -)");
74 doit("rm","-f","debian/movelist");
78 # If $ret is set, we wern't actually able to find some
79 # files that were specified to be moved, and we should
80 # exit with the code in $ret. This program puts off
81 # exiting with an error until all files have been tried
82 # to be moved, because this makes it easier for some
83 # packages that arn't always sure exactly which files need