~ubuntu-branches/ubuntu/hardy/debhelper/hardy-backports

« back to all changes in this revision

Viewing changes to dh_installinit

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2005-03-27 11:29:01 UTC
  • Revision ID: james.westby@ubuntu.com-20050327112901-ariyj35hc24kpq7w
Tags: 4.2.32
* Patch from Fabio Tranchitella to add support for #DEBHELPER# substitutions
  in config files, although nothing in debhelper itself uses such
  substitutions, third-party addons may. Closes: #301657
* Factor out a debhelper_script_subst from dh_installdeb and
  dh_installdebconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
=head1 SYNOPSIS
13
13
 
14
 
B<dh_installinit> [S<I<debhelper options>>] [B<--init-script=>I<scriptname>] [B<-n>] [B<-r>] [B<-d>] [S<B<--> I<params>>]
 
14
B<dh_installinit> [S<I<debhelper options>>] [B<--name=>I<name>] [B<-n>] [B<-r>] [B<-d>] [S<B<--> I<params>>]
15
15
 
16
16
=head1 DESCRIPTION
17
17
 
30
30
etc/default/package in the package build directory, with "package" replaced
31
31
by the package name.
32
32
 
33
 
Historically this program generates postrm and prerm commands that run the
34
 
init scripts by hand. In V4 mode, it uses the invoke-rc.d program instead.
35
 
See L<debhelper(1)> for details about V4 mode. If you decide to use this, you
36
 
should make your package depend on sysvinit (>= 2.80-1) (this dependency is
37
 
added to ${misc:Depends} by this program in V4 mode).
38
 
 
39
33
=head1 OPTIONS
40
34
 
41
35
=over 4
46
40
 
47
41
=item B<-r>, B<--no-restart-on-upgrade>
48
42
 
49
 
Do not restart daemon on upgrade.
 
43
Do not restart init script on upgrade.
 
44
 
 
45
=item B<--no-start>
 
46
 
 
47
Do not start the init script on install or upgrade, or stop it on removal.
 
48
Only call update-rc.d. Useful for rcS scripts.
50
49
 
51
50
=item B<-d>, B<--remove-d>
52
51
 
63
62
Pass "params" to L<update-rc.d(8)>. If not specified, "defaults" will be
64
63
passed to L<update-rc.d(8)>.
65
64
 
 
65
=item B<--name=>I<name>
 
66
 
 
67
Install the init script (and default file) using the filename I<name>
 
68
instead of the default filename, which is the package name. When this
 
69
parameter is used, dh_installinit looks for and installs files named
 
70
debian/package.name.init and debian/package.name.default, instead of the
 
71
usual debian/package.init and debian/package.default.
 
72
 
66
73
=item B<--init-script=>I<scriptname>
67
74
 
68
 
Use "scriptname" as for the filename the init script is installed as in
 
75
Use "scriptname" as the filename the init script is installed as in
69
76
etc/init.d/ (and also use it as the filename for the defaults file, if it
70
 
is installed). This is useful if you need to have an init script with a name
71
 
different from the package's name. Note that if you use this parameter,
72
 
dh_installinit will look to see if a file in the debian/ directory exists
73
 
that looks like "package.scriptname" and if so will install it as the init
74
 
script in preference to the files it normally installs. This feature is really
75
 
only useful if you need a single package to install more than one init script.
 
77
is installed). If you use this parameter, dh_installinit will look to see
 
78
if a file in the debian/ directory exists that looks like
 
79
"package.scriptname" and if so will install it as the init script in
 
80
preference to the files it normally installs.
 
81
 
 
82
This parameter is deprecated, use the --name parameter instead.
 
83
 
 
84
=item B<--error-handler=>I<function>
 
85
 
 
86
Call the named shell function if running the init script fails. The
 
87
function should be provided in the prerm and postinst scripts, before the
 
88
#DEBHELPER# token.
76
89
 
77
90
=back
78
91
 
91
104
 
92
105
        # Figure out what filename to install it as.
93
106
        my $script;
94
 
        if ($dh{D_FLAG}) {
 
107
        if (defined $dh{NAME}) {
 
108
                $script=$dh{NAME};
 
109
        }
 
110
        elsif ($dh{D_FLAG}) {
95
111
                # -d on the command line sets D_FLAG. We will 
96
112
                # remove a trailing 'd' from the package name and 
97
113
                # use that as the name.
109
125
        else {
110
126
                $script=$package;
111
127
        }       
112
 
 
 
128
        
113
129
        my $init=pkgfile($package,$script) || pkgfile($package,"init") ||
114
130
              pkgfile($package,"init.d");
115
131
        my $default=pkgfile($package,'default');
138
154
                if ($params eq '') {
139
155
                        $params="defaults";
140
156
                }
141
 
 
142
 
                my $substvaradded=0;
 
157
                
143
158
                if (! $dh{NOSCRIPTS}) {
144
 
                        # In v4 mode, use invoke-rc.d versions of the
145
 
                        # autoscripts; prior to that use the old,
146
 
                        # manual-invoking versions.
147
 
                        my $tailstr="";
148
 
                        if (! compat(3)) {
149
 
                                $tailstr="-invoke";
150
 
                                addsubstvar($package, "misc:Depends", "sysvinit", ">= 2.80-1");
151
 
                                $substvaradded=1;
152
 
                        }
153
 
                        # -r on the command line sets R_FLAG. If it's set,
154
 
                        # there  is no restart on upgrade.
155
 
                        if ($dh{R_FLAG}) {
156
 
                                autoscript($package,"postinst", "postinst-init-norestart$tailstr",
157
 
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
158
 
                                autoscript($package,"prerm","prerm-init-norestart$tailstr",
159
 
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
 
159
                        if (! $dh{NO_START}) {
 
160
                                # update-rc.d, and start script
 
161
                                autoscript($package,"postinst", "postinst-init",
 
162
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
 
163
                        
 
164
                                if ($dh{R_FLAG}) {
 
165
                                        # stops script only on remove
 
166
                                        autoscript($package,"prerm","prerm-init-norestart",
 
167
                                                "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
 
168
                                }
 
169
                                else {
 
170
                                        # always stops script
 
171
                                        autoscript($package,"prerm","prerm-init",
 
172
                                                "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
 
173
                                }
160
174
                        }
161
175
                        else {
162
 
                                autoscript($package,"postinst","postinst-init$tailstr",
163
 
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
164
 
                                autoscript($package,"prerm","prerm-init$tailstr",
165
 
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
 
176
                                # just update-rc.d
 
177
                                autoscript($package,"postinst", "postinst-init-nostart",
 
178
                                        "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
166
179
                        }
167
 
                        # This script just removes the links, so it's the
168
 
                        # same for all varients.
 
180
 
 
181
                        # removes rc.d links
169
182
                        autoscript($package,"postrm","postrm-init",
170
 
                                "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
171
 
                }
172
 
 
173
 
                if (! $substvaradded) {
174
 
                        # Remove it, for idemotency's sake.
175
 
                        addsubstvar($package, "misc:Depends", "sysvinit", ">= 2.80-1", 1);
 
183
                                "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
176
184
                }
177
185
        }
178
186
}
179
187
 
180
188
=head1 SEE ALSO
181
189
 
182
 
L<debhelper(1)>
 
190
L<debhelper(7)>
183
191
 
184
192
This program is a part of debhelper.
185
193