]> git.donarmstrong.com Git - debhelper.git/blob - dh_movefiles
r108: Initial Import
[debhelper.git] / dh_movefiles
1 #!/bin/sh -e
2 #
3 # Move files out of debian/tmp, into subpackages.
4
5 PATH=debian:$PATH:/usr/lib/debhelper
6 . dh_lib
7
8 for PACKAGE in $DH_DOPACKAGES; do
9         TMP=`tmpdir $PACKAGE`
10         files=`pkgfile $PACKAGE files`
11
12         if [ ! -d "debian/tmp" ]; then
13                 error "debian/tmp does not exist"
14         fi
15
16         tomove=""
17
18         # debian/files has a different purpose, so ignore it.
19         if [ "$files" -a "$files" != "debian/files" ]; then
20                 tomove=`cat $files`
21         fi
22         
23         if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \
24              -a "$*" ]; then
25                 tomove="$* $tomove"
26         fi
27
28         if [ "$tomove" -a "$TMP" = "debian/tmp" ]; then
29                 error "I was asked to move files from debian/tmp to debian/tmp."
30         fi
31
32         if [ "$tomove" ]; then
33                 if [ ! -d "$TMP" ]; then
34                         doit "install -d $TMP"
35                 fi
36
37                 # Order the files. First all real files, then symlinks. 
38                 # Putting symlinks last is a nice thing to do for library 
39                 # packages and doesn't affect much of anything else.
40                 #
41                 # (The echo is in here to expand wildcards. Note that 'ls'
42                 # won't work properly.)
43                 # The file list is used, so even very weird filenames can be
44                 # moved.
45                 doit "rm -f movelist"
46                 for i in `(cd debian/tmp; echo $tomove)`; do
47                         if [ ! -e "debian/tmp/$i" ]; then
48                                 fail=1
49                         fi
50                         complex_doit "(cd debian/tmp ; find $i ! -type d -and ! -type l -print || true) >> movelist"
51                 done
52                 for i in `(cd debian/tmp; echo $tomove)`; do
53                         if [ ! -e "debian/tmp/$i" ]; then
54                                 fail=1
55                         fi
56                         complex_doit "(cd debian/tmp ; find $i ! -type d -and -type l -print || true) >> movelist"
57                 done
58                 complex_doit "(cd debian/tmp;tar --create --remove-files --files-from=../../movelist --file -) | (cd $TMP;tar xpf -)"
59                 doit "rm -f movelist"
60         fi
61 done
62
63 # If fail 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 fail. 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 $fail