]> git.donarmstrong.com Git - debhelper.git/blob - dh_debstd
r84: Initial revision
[debhelper.git] / dh_debstd
1 #!/bin/sh -e
2 #
3 # Script to be called from debian/rules to setup all the debian specifc
4 # required files
5 # Christoph Lameter, <clameter@debian.org> October 10, 1996
6 #
7 # All the parameters are documentation files to be installed.
8 # (but doc files can also be listed in debian/docs)
9 #
10 # This has been gutted and extensively rewritten to function as a debhelper
11 # command by Joey Hess.
12
13 # Pre-parse command line before we load dh_lib, becuase we use a
14 # different style of arguments.
15 for i;do
16   case "$i" in
17   -p) PERMS=1
18     ;;
19   -u) UNDOC=1
20     ;;
21   -s) SUMS=1
22     ;;
23   -m) NOAUTOMAN=1
24     ;;
25   -c) NOCOMPRESS=1
26     ;;
27   *) collect="$collect$i "
28     ;;
29   esac
30 done
31 set -- $collect
32
33 PATH=debian:$PATH:/usr/lib/debhelper
34 . dh_lib
35
36 # Tolerate old style debstd invocations
37 if [ "$DH_FIRSTPACKAGE" = "$1" ]; then
38         shift
39 fi
40
41 # Subroutines
42
43 # debinit handles the installation of an init.d script
44 # Parameters:
45 # $1= name in /etc/init.d
46 # $2 = scriptname
47 # $3 = package name
48 # $4 = extra params for debhelper
49 debinit() {
50         PPACKAGE=$3
51         SCRIPT=$1
52
53         INITPARAMS=`grep "^FLAGS=" $2` || true
54         if [ "$INITPARAMS" != "" ]; then
55                 INITPARAMS=`expr "$INITPARAMS" : 'FLAGS="\(.*\)"'` || true
56                 if [ "$INITPARAMS" ]; then
57                         INITPARAMS="--update-rcd-params='$INITPARAMS'"
58                 fi
59         fi
60
61         if grep -q NO_RESTART_ON_UPGRADE $2; then
62                 doit "dh_installinit --no-restart-on-upgrade -p$PPACKAGE $INITPARAMS --init-script=$SCRIPT $4"
63           else
64                 doit "dh_installinit -p$PPACKAGE $INITPARAMS --init-script=$SCRIPT $4"
65         fi
66 }
67
68 # Package specific things
69 #
70 # The first parameter is the package name
71 # The second parameter is the directory name of the temp directory
72 # The third parameter is the prefix for all configuration files to be processed
73 package()
74 {
75         local i
76         local X Y
77         CPACKAGE=$1
78         CTEMP=$2
79
80         # Deal with scripts in etc directories
81         if [ -f $3/rc.boot ]; then
82                 warning "file $3/rc.boot was ignored."
83         fi
84
85         # etc files that could need some tweaking
86         for i in services inittab crontab protocols profile shells rpc shells \
87                 syslog.conf conf.modules modules aliases diversions inetd.conf \
88                 X11/Xresources X11/config X11/window-managers X11/xinit purge ; do
89                 if [ -f $3$i ]; then
90                         warning "file $3$i was ignored."
91                 fi
92         done
93
94         if [ -f $3init.d ]; then
95                 debinit $1 $3init.d $1 ""
96         fi
97
98         # The case of a daemon without the final d
99         if [ -f $3init ]; then
100                 X=`expr $1 : '\(.*\)d$'` || true  
101                 if [ "$X" ]; then
102                         debinit $X $3init $1 "--remove-d"
103                 fi
104         fi
105
106         if [ -f $3info ]; then
107                 warning "debhelper does not yet support info files, so $3info was ignored."
108         fi
109
110         X=`find $2 -type f -perm +111 2>/dev/null | tr "\n" " "`
111         for i in $X; do
112                 BINPATH="`expr "$i" : "$2/\(.*\)/.*"`"
113                 BINNAME="`expr "$i" : "$2/.*/\(.*\)"`"
114
115                 # Check if manpages exist
116                 case "$BINPATH" in
117                         DEBIAN|etc/rc.boot|usr/lib/cgi-bin|etc/init.d|etc/cron.*|usr/lib/lib*|usr/lib/*) SECTION=""
118                                 ;;
119                         sbin|usr/sbin) SECTION="8"
120                                 ;;
121                         usr/X11R6/bin) SECTION="1x"
122                                 ;;
123                         bin|usr/bin) SECTION="1"
124                                 ;;
125                         usr/games) SECTION="6"
126                                 ;;
127                         *)  SECTION=""
128                                 ;;
129                 esac
130                 if [ "$SECTION" ]; then
131                         Y=`find $2/usr/man $2/usr/X11R6/man -name "$BINNAME.*" 2>/dev/null` || true
132                         if [ "$Y" = "" ]; then
133                                 if [ "$UNDOC" ]; then
134                                         doit "dh_undocumented -p$CPACKAGE $BINNAME.$SECTION"
135                                 fi
136                         fi
137                 fi
138         done
139 }
140
141 packages() {
142         local i
143         BASE=$1
144         shift
145         for i in $*; do
146                 package $i debian/$i "debian/$i."
147                 if [ -x debian/$i.prebuild ]; then
148                         warning "file debian/$i.prebuild ignored"
149                 fi
150         done
151
152         if [ -f debian/clean ]; then
153                 warning "file debian/clean ignored"
154         fi
155         package $BASE debian/tmp "debian/"
156 }
157
158 # Special case of changelog
159 if [ "$1" ]; then
160         if echo "$1" | egrep -qi "change|news|history" ; then
161                 changelogfile=$1
162                 shift
163         fi
164 fi
165
166 doit "dh_installdirs" # here just to make the debian/tmp, etc directories.
167 doit "dh_installdocs $*"
168 doit "dh_installexamples"
169 doit "dh_installchangelogs $changelogfile"
170 doit "dh_installmenu"
171 doit "dh_installcron"
172
173 # Manpage scan
174 if [ "$NOAUTOMAN" = "" ]; then
175         doit "dh_installmanpages -p$DH_FIRSTPACKAGE"
176 fi
177
178 packages $DH_DOPACKAGES
179
180 doit "dh_movefiles"
181 doit "dh_strip"
182
183 if [ ! "$nocompress" ]; then
184         doit "dh_compress"
185 fi
186
187 doit "dh_fixperms"
188 doit "dh_suidregister"
189 doit "dh_shlibdeps"
190 doit "dh_gencontrol"
191 doit "dh_makeshlibs"
192
193 # Check to see if the install scripts have #DEBHELPER# in them, if not,
194 # warn.
195 for PACKAGE in $DH_DOPACKAGES; do
196         for file in postinst postrm preinst prerm; do
197                 f="`pkgfile $PACKAGE $file`"
198                 if [ "$f" ]; then
199                         filelist="$filelist$f "
200                 fi
201         done
202 done
203 if [ "$filelist" ]; then
204         warning "The following scripts do not contain \"#DEBHELPER#\" in them,"
205         warning "and so debhelper will not automatically add commands to them:"
206         warning "$filelist"
207 fi
208
209 doit "dh_installdeb"
210
211 if [ "$SUMS" = "" ]; then
212         doit "dh_md5sums"
213 fi
214
215 # This causes the main binary package to be built, which
216 # real debstd does not do. Shouldn't be a problem though,
217 # if that package gets built twice.
218 doit "dh_builddeb"