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);
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?");
45 doit("install","-d",$TMP);
47 # Now we need to expand wildcards in @tomove.
50 push @filelist, glob("$sourcedir/$_");
53 # If the globs expended to nothing, we are done.
54 next unless @filelist;
56 # Order the files. First all real files, then symlinks.
57 # Putting symlinks last is a nice thing to do for library
58 # packages and doesn't affect much of anything else.
59 doit("rm","-f","debian/movelist");
62 $ret=1 if (! -e $file && ! -l $file);
63 $file=~s:^\Q$sourcedir\E/+::;
64 complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -and ! -type l -print || true) >> debian/movelist");
68 $ret=1 if (! -e $file && ! -l $file);
69 $file=~s:^\Q$sourcedir\E/+::;
70 complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -and -type l -print || true) >> debian/movelist");
72 complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=../movelist --file -) | (cd $TMP >/dev/null ;tar xpf -)");
73 doit("rm","-f","debian/movelist");
77 # If $ret is set, we wern't actually able to find some
78 # files that were specified to be moved, and we should
79 # exit with the code in $ret. This program puts off
80 # exiting with an error until all files have been tried
81 # to be moved, because this makes it easier for some
82 # packages that arn't always sure exactly which files need