]> git.donarmstrong.com Git - debhelper.git/blob
r784: This commit was manufactured by cvs2svn to create tag
[debhelper.git] /
1 #!/usr/bin/perl -w
2 #
3 # Install debian/init[.d], and set up the postinst and postrm for init
4 # scripts.
5
6 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
7 use Dh_Lib;
8 init();
9
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11         $TMP=tmpdir($PACKAGE);
12
13         # Figure out what filename to install it as.
14         my $script;
15         if ($dh{D_FLAG}) {
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.
19                 $script=$PACKAGE;
20                 if ($script=~m/(.*)d$/) {
21                         $script=$1;
22                 }
23                 else {
24                         warning("\"$PACKAGE\" has no final d' in its name, but -d was specified.");
25                 }
26         }       
27         elsif ($dh{INIT_SCRIPT}) {
28                 $script=$dh{INIT_SCRIPT};
29         }
30         else {
31                 $script=$PACKAGE;
32         }       
33
34         $init=pkgfile($PACKAGE,$script) || pkgfile($PACKAGE,"init") ||
35               pkgfile($PACKAGE,"init.d");
36
37         if ($init ne '') {
38                 if (! -d "$TMP/etc/init.d") {
39                         doit("install","-d","$TMP/etc/init.d");
40                 }
41
42                 doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script");
43
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".
47                 my $params='';
48                 if (defined($dh{U_PARAMS})) {
49                         $params=join(' ',@{$dh{U_PARAMS}});
50                 }       
51                 if ($params eq '') {
52                         $params="defaults";
53                 }
54
55                 if (! $dh{NOSCRIPTS}) {
56                         # -r on the command line sets R_FLAG. If it's set, there
57                         # is no restart on upgrade.
58                         if ($dh{R_FLAG}) {
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                         }
64                         else {
65                                 autoscript($PACKAGE,"postinst","postinst-init",
66                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
67                                 autoscript($PACKAGE,"postrm","postrm-init",
68                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
69                                 autoscript($PACKAGE,"prerm","prerm-init",
70                                         "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
71                         }
72                 }
73         }
74 }