3 # Install debian/init[.d], and set up the postinst and postrm for init
6 use Debian::Debhelper::Dh_Lib;
9 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
10 $TMP=tmpdir($PACKAGE);
12 # Figure out what filename to install it as.
15 # -d on the command line sets D_FLAG. We will
16 # remove a trailing 'd' from the package name and
17 # use that as the name.
19 if ($script=~m/(.*)d$/) {
23 warning("\"$PACKAGE\" has no final d' in its name, but -d was specified.");
26 elsif ($dh{INIT_SCRIPT}) {
27 $script=$dh{INIT_SCRIPT};
33 $init=pkgfile($PACKAGE,$script) || pkgfile($PACKAGE,"init") ||
34 pkgfile($PACKAGE,"init.d");
37 if (! -d "$TMP/etc/init.d") {
38 doit("install","-d","$TMP/etc/init.d");
41 doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script");
43 # This is set by the -u "foo" command line switch, it's
44 # the parameters to pass to update-rc.d. If not set,
45 # we have to say "defaults".
47 if (defined($dh{U_PARAMS})) {
48 $params=join(' ',@{$dh{U_PARAMS}});
54 if (! $dh{NOSCRIPTS}) {
55 # -r on the command line sets R_FLAG. If it's set, there
56 # is no restart on upgrade.
58 autoscript($PACKAGE,"postinst", "postinst-init-norestart",
59 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
60 autoscript($PACKAGE,"postrm","postrm-init",
61 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
62 autoscript($PACKAGE,"prerm","prerm-init-norestart",
63 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
66 autoscript($PACKAGE,"postinst","postinst-init",
67 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
68 autoscript($PACKAGE,"postrm","postrm-init",
69 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
70 autoscript($PACKAGE,"prerm","prerm-init",
71 "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");