]> git.donarmstrong.com Git - debhelper.git/blob - dh_movefiles
r140: Initial Import
[debhelper.git] / dh_movefiles
1 #!/usr/bin/perl -w
2 #
3 # Move files out of debian/tmp, into subpackages.
4
5 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
6 use Dh_Lib;
7 init();
8
9 $ret=0;
10
11 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
12         $TMP=tmpdir($PACKAGE);
13         $files=pkgfile($PACKAGE,"files");
14
15         if (! -d "debian/tmp") {
16                 error("debian/tmp does not exist.");
17         }
18
19         @tomove=();
20
21         # debian/files has a different purpose, so ignore it.
22         if ( $files && $files ne "debian/files" ) {
23                 @tomove=filearray($files);
24         }
25         
26         if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
27                 push @tomove, @ARGV;
28         }
29
30         if (@tomove && $TMP eq "debian/tmp") {
31                 error("I was asked to move files from debian/tmp to debian/tmp.");
32         }
33
34         if (@tomove) {
35                 if (! -d $TMP) {
36                         doit("install","-d",$TMP);
37                 }
38                 # Now we need to expand wildcards in @tomove.
39                 @filelist=();
40                 foreach (@tomove) {
41                         push @filelist, glob("debian/tmp/$_");
42                 }
43                 
44                 # Order the files. First all real files, then symlinks. 
45                 # Putting symlinks last is a nice thing to do for library 
46                 # packages and doesn't affect much of anything else.
47                 doit("rm","-f","movelist");
48                 foreach (@filelist) {
49                         $ret=1 if (! -e $_ && ! -l $_);
50                         s:^debian/tmp/*::;
51                         complex_doit("(cd debian/tmp ; find $_ ! -type d -and ! -type l -print || true) >> movelist");
52                 }
53                 foreach (@filelist) {
54                         $ret=1 if (! -e $_ && ! -l $_);
55                         s:^debian/tmp/*::;
56                         complex_doit("(cd debian/tmp ; find $_ ! -type d -and -type l -print || true) >> movelist");
57                 }
58                 complex_doit("(cd debian/tmp;tar --create --remove-files --files-from=../../movelist --file -) | (cd $TMP;tar xpf -)");
59                 doit("rm","-f","movelist");
60         }
61 }
62
63 # If $ret is set, we wern't actually able to find some 
64 # files that were specified to be moved, and we should
65 # exit with the code in $ret. This program puts off 
66 # exiting with an error until all files have been tried
67 # to be moved, because this makes it easier for some 
68 # packages that arn't always sure exactly which files need
69 # to be moved.
70 exit $ret;