]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdebfiles
a9954963fac0970f43f87f0140ac6147dfb1f1d1
[debhelper.git] / dh_installdebfiles
1 #!/bin/sh -e
2 #
3 # Install files from debian/ into the package's DEBIAN directory.
4 # Also generates the control file.
5
6 PATH=debian:$PATH:/usr/lib/debhelper
7 . dh_lib
8
9 for PACKAGE in $DH_DOPACKAGES; do
10         TMP=`tmpdir $PACKAGE`
11         EXT=`pkgext $PACKAGE`
12
13         if [ ! -d $TMP/DEBIAN ]; then
14                 doit "install -o root -g root -d $TMP/DEBIAN"
15         fi
16
17         # Install debian install scripts.
18         # If any .debhelper files exist, add them into the scripts.
19         for file in postinst preinst prerm postrm; do
20                 if [ -f debian/$EXT$file ]; then
21                         # Add this into the script, where it has #DEBHELPER#
22                         if [ -f debian/$EXT$file.debhelper ]; then
23                                 doit "perl -pe 's~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg' < debian/$EXT$file > $TMP/DEBIAN/$file"
24                                 doit "chown root.root $TMP/DEBIAN/$file"
25                                 doit "chmod 755 $TMP/DEBIAN/$file"
26                         else
27                                 doit "install -o root -g root -p debian/$EXT$file $TMP/DEBIAN/$file"
28                         fi
29                 else
30                         # Auto-generate script header and add .debhelper
31                         # content to it.
32                         if [ -f debian/$EXT$file.debhelper ]; then
33                                 doit "echo '#!/bin/sh -e' > $TMP/DEBIAN/$file"
34                                 doit "cat debian/$EXT$file.debhelper >> $TMP/DEBIAN/$file"
35                                 doit "chown root.root $TMP/DEBIAN/$file"
36                                 doit "chmod 755 $TMP/DEBIAN/$file"
37                         fi
38                 fi
39         done
40
41         # Install non-executable files
42         for file in shlibs conffiles; do
43                 if [ -f debian/$EXT$file ]; then
44                         doit "install -o root -g root -m 644 -p debian/$EXT$file $TMP/DEBIAN/$file"
45                 fi                                               
46         done
47
48         # Run dpkg-shlibdeps to generate dependancies.
49         filelist=""
50         for file in `find $TMP -type f \( -perm +111 -or -name "*.so*" \) | tr "\n" " "` ; do
51                 case "`file $file`" in
52                         *ELF*)
53                                 filelist="$file $filelist"
54                         ;;
55                 esac
56         done
57         if [ "$filelist" ]; then
58                 doit "dpkg-shlibdeps -Tdebian/${EXT}substvars $filelist"
59         fi
60
61         # Generate and install control file.
62         doit "dpkg-gencontrol -p$PACKAGE -Tdebian/${EXT}substvars -P$TMP"
63         doit "chown root.root $TMP/DEBIAN/control"
64 done