3 # Move files out of debian/tmp, into subpackages.
5 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
11 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
12 $TMP=tmpdir($PACKAGE);
13 $files=pkgfile($PACKAGE,"files");
16 if ($dh{SOURCEDIR}=~m:^/:) {
17 error("The sourcedir must be a relative filename, not starting with `/'.");
19 $sourcedir=$dh{SOURCEDIR};
22 $sourcedir="debian/tmp";
25 if (! -d $sourcedir) {
26 error("$sourcedir does not exist.");
31 # debian/files has a different purpose, so ignore it.
32 if ( $files && $files ne "debian/files" ) {
33 @tomove=filearray($files);
36 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
40 if (@tomove && $TMP eq $sourcedir) {
41 error("I was asked to move files from $sourcedir to $sourcedir.");
46 doit("install","-d",$TMP);
48 # Now we need to expand wildcards in @tomove.
51 push @filelist, glob("$sourcedir/$_");
54 # Order the files. First all real files, then symlinks.
55 # Putting symlinks last is a nice thing to do for library
56 # packages and doesn't affect much of anything else.
57 doit("rm","-f","movelist");
60 $ret=1 if (! -e $file && ! -l $file);
61 $file=~s:^$sourcedir/+::;
62 complex_doit("(cd $sourcedir ; find $file ! -type d -and ! -type l -print || true) >> movelist");
66 $ret=1 if (! -e $file && ! -l $file);
67 $file=~s:^$sourcedir/+::;
68 complex_doit("(cd $sourcedir ; find $file ! -type d -and -type l -print || true) >> movelist");
70 complex_doit("(cd $sourcedir;tar --create --remove-files --files-from=../../movelist --file -) | (cd $TMP;tar xpf -)");
71 doit("rm","-f","movelist");
75 # If $ret is set, we wern't actually able to find some
76 # files that were specified to be moved, and we should
77 # exit with the code in $ret. This program puts off
78 # exiting with an error until all files have been tried
79 # to be moved, because this makes it easier for some
80 # packages that arn't always sure exactly which files need