summaryrefslogtreecommitdiff
path: root/dh_installinit
diff options
context:
space:
mode:
authorjoey <joey>2000-03-02 21:23:22 +0000
committerjoey <joey>2000-03-02 21:23:22 +0000
commit67b74298f08a3e2b30e43cbcd7cdaccc2e1b1614 (patch)
tree3ce180eedb8c91f9371456f3fb40336b4c7c34dd /dh_installinit
parentc7f541bd2bc869c366e8242baf1faa6856cd2e39 (diff)
r338: * Patch from Jorgen `forcer' Schaefer <forcer at mindless.com> (much
modified)to make dh_installwm use new window manager registration method, update-alternatives. Closes: #52156, #34684 (latter bug is obsolete) * Fixed $dh{flavor} to be upper-case. * Deprecated dh_installemavcsen --number; use --priority instead. Also, the option parser requires the parameter be a number now. And, dh_installwm now accepts --priority, and window manager packages should start using it. * dh_installwm now behaves like a proper debhelper command, and reads debian/<package>.wm too. This is a small behavior change; filenames specified on the command line no longer apply to all packages it acts on. I can't belive this program existed for 2 years with such a glaring problem; I guess most people don't need ot register 5 wm's in 3 sub-packages. Anyway, it can handle such things now. :-) * Moved Dh_*.pm to /usr/lib/perl5/Debian/Debhelper. *big* change.
Diffstat (limited to 'dh_installinit')
-rwxr-xr-xdh_installinit117
1 files changed, 66 insertions, 51 deletions
diff --git a/dh_installinit b/dh_installinit
index 2ea3440..7836a9e 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -1,58 +1,73 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
#
# Install debian/init[.d], and set up the postinst and postrm for init
# scripts.
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
-
-for PACKAGE in $DH_DOPACKAGES; do
- TMP=`tmpdir $PACKAGE`
- EXT=`pkgext $PACKAGE`
-
- if [ -e debian/${EXT}init ]; then
- if [ ! -d $TMP/etc/init.d ]; then
- doit "install -d $TMP/etc/init.d"
- fi
-
- # Figure out what filename to install it as.
- if [ "$DH_D_FLAG" ]; then
- # -d on the command line sets DH_D_FLAG. We will
- # remove a trailing 'd' from the package name and
- # use that as the name.
- script=`expr $PACKAGE : '\(.*\)d$'` || true
- if [ ! "$script" ]; then
- echo `basename $0`" warning: \"$PACKAGE\" has no final -d, but -d was specified."
- script=$PACKAGE
- fi
- else
- script=$PACKAGE
- fi
- doit "install -p -m755 debian/${EXT}init $TMP/etc/init.d/$script"
+use Debian::Debhelper::Dh_Lib;
+init();
+
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+ $TMP=tmpdir($PACKAGE);
+
+ # Figure out what filename to install it as.
+ my $script;
+ if ($dh{D_FLAG}) {
+ # -d on the command line sets D_FLAG. We will
+ # remove a trailing 'd' from the package name and
+ # use that as the name.
+ $script=$PACKAGE;
+ if ($script=~m/(.*)d$/) {
+ $script=$1;
+ }
+ else {
+ warning("\"$PACKAGE\" has no final d' in its name, but -d was specified.");
+ }
+ }
+ elsif ($dh{INIT_SCRIPT}) {
+ $script=$dh{INIT_SCRIPT};
+ }
+ else {
+ $script=$PACKAGE;
+ }
+
+ $init=pkgfile($PACKAGE,$script) || pkgfile($PACKAGE,"init") ||
+ pkgfile($PACKAGE,"init.d");
+
+ if ($init ne '') {
+ if (! -d "$TMP/etc/init.d") {
+ doit("install","-d","$TMP/etc/init.d");
+ }
+
+ doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script");
# This is set by the -u "foo" command line switch, it's
- # the parameters to pass to update-rc.d. If not set,
+ # the parameters to pass to update-rc.d. If not set,
# we have to say "defaults".
- if [ "$DH_U_PARAMS" = "" ]; then
- DH_U_PARAMS="defaults"
- fi
-
- # -r on the command line sets DH_R_FLAG. If it's set, there
- # is no restart on upgrade.
- if [ ! "$DH_NOSCRIPTS" ]; then
- if [ "$DH_R_FLAG" ]; then
- autoscript "postinst" "postinst-init-norestart" \
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
- autoscript "postrm" "postrm-init" \
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
- else
- autoscript "postinst" "postinst-init" \
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
- autoscript "postrm" "postrm-init" \
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
- autoscript "prerm" "prerm-init" \
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
- fi
- fi
- fi
-done
+ my $params='';
+ if (defined($dh{U_PARAMS})) {
+ $params=join(' ',@{$dh{U_PARAMS}});
+ }
+ if ($params eq '') {
+ $params="defaults";
+ }
+
+ if (! $dh{NOSCRIPTS}) {
+ # -r on the command line sets R_FLAG. If it's set, there
+ # is no restart on upgrade.
+ if ($dh{R_FLAG}) {
+ autoscript($PACKAGE,"postinst","postinst-init-norestart",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ autoscript($PACKAGE,"postrm","postrm-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ }
+ else {
+ autoscript($PACKAGE,"postinst","postinst-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ autoscript($PACKAGE,"postrm","postrm-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ autoscript($PACKAGE,"prerm","prerm-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ }
+ }
+ }
+}