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