summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey>2004-06-29 00:03:54 +0000
committerjoey <joey>2004-06-29 00:03:54 +0000
commitad092508ea530253700749a3119bf8a24dcc162e (patch)
tree9c5bcde32f8bea565082d18d9e749c39741309b6
parent62d0cab3e04ec95e5c62a58d291018a1ebce228f (diff)
r1691: * dh_installinit: Added --error-handler option. Based on work by Thom May.
Closes: #209090
-rw-r--r--Debian/Debhelper/Dh_Getopt.pm2
-rw-r--r--Debian/Debhelper/Dh_Lib.pm6
-rw-r--r--autoscripts/postinst-init4
-rw-r--r--autoscripts/postinst-init-nostart2
-rw-r--r--autoscripts/postrm-init2
-rw-r--r--autoscripts/prerm-init4
-rw-r--r--autoscripts/prerm-init-norestart4
-rw-r--r--debian/changelog7
-rwxr-xr-xdh_installinit18
-rw-r--r--doc/PROGRAMMING1
10 files changed, 36 insertions, 14 deletions
diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm
index 1da5afd..0c807b7 100644
--- a/Debian/Debhelper/Dh_Getopt.pm
+++ b/Debian/Debhelper/Dh_Getopt.pm
@@ -162,6 +162,8 @@ sub parseopts {
"keep-debug" => \$options{KEEP_DEBUG},
+ "error-handler=s" => \$options{ERROR_HANDLER},
+
"<>" => \&NonOption,
);
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index f42f8bd..5449dca 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -100,6 +100,12 @@ sub init {
# This package gets special treatement: files and directories specified on
# the command line may affect it.
$dh{FIRSTPACKAGE}=${$dh{DOPACKAGES}}[0];
+
+ # If no error handling function was specified, just propigate
+ # errors out.
+ if (! exists $dh{ERROR_HANDLER} || ! defined $dh{ERROR_HANDLER}) {
+ $dh{ERROR_HANDLER}='exit $?';
+ }
}
# Pass it an array containing the arguments of a shell command like would
diff --git a/autoscripts/postinst-init b/autoscripts/postinst-init
index b5bd7a5..8128cd9 100644
--- a/autoscripts/postinst-init
+++ b/autoscripts/postinst-init
@@ -1,8 +1,8 @@
if [ -x "/etc/init.d/#SCRIPT#" ]; then
update-rc.d #SCRIPT# #INITPARMS# >/dev/null
if [ -x /usr/sbin/invoke-rc.d ]; then
- invoke-rc.d #SCRIPT# start
+ invoke-rc.d #SCRIPT# start || #ERROR_HANDLER#
else
- /etc/init.d/#SCRIPT# start
+ /etc/init.d/#SCRIPT# start || #ERROR_HANDLER#
fi
fi
diff --git a/autoscripts/postinst-init-nostart b/autoscripts/postinst-init-nostart
index 5d882b6..7a1bd5e 100644
--- a/autoscripts/postinst-init-nostart
+++ b/autoscripts/postinst-init-nostart
@@ -1,3 +1,3 @@
if [ -x "/etc/init.d/#SCRIPT#" ]; then
- update-rc.d #SCRIPT# #INITPARMS# >/dev/null
+ update-rc.d #SCRIPT# #INITPARMS# >/dev/null || #ERROR_HANDLER#
fi
diff --git a/autoscripts/postrm-init b/autoscripts/postrm-init
index 1c29298..628ece6 100644
--- a/autoscripts/postrm-init
+++ b/autoscripts/postrm-init
@@ -1,3 +1,3 @@
if [ "$1" = "purge" ] ; then
- update-rc.d #SCRIPT# remove >/dev/null
+ update-rc.d #SCRIPT# remove >/dev/null || #ERROR_HANDLER#
fi
diff --git a/autoscripts/prerm-init b/autoscripts/prerm-init
index eab98c7..014fa9a 100644
--- a/autoscripts/prerm-init
+++ b/autoscripts/prerm-init
@@ -1,7 +1,7 @@
if [ -x "/etc/init.d/#SCRIPT#" ]; then
if [ -x /usr/sbin/invoke-rc.d ] ; then
- invoke-rc.d #SCRIPT# stop
+ invoke-rc.d #SCRIPT# stop || #ERROR_HANDLER#
else
- /etc/init.d/#SCRIPT# stop
+ /etc/init.d/#SCRIPT# stop || #ERROR_HANDLER#
fi
fi
diff --git a/autoscripts/prerm-init-norestart b/autoscripts/prerm-init-norestart
index fb99152..0f64c45 100644
--- a/autoscripts/prerm-init-norestart
+++ b/autoscripts/prerm-init-norestart
@@ -1,7 +1,7 @@
if [ -x "/etc/init.d/#SCRIPT#" ] && [ "$1" = remove ]; then
if [ -x /usr/sbin/invoke-rc.d ] ; then
- invoke-rc.d #SCRIPT# stop
+ invoke-rc.d #SCRIPT# stop || #ERROR_HANDLER#
else
- /etc/init.d/#SCRIPT# stop
+ /etc/init.d/#SCRIPT# stop || #ERROR_HANDLER#
fi
fi
diff --git a/debian/changelog b/debian/changelog
index 8220aba..1bad9dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+debhelper (4.2.12) UNRELEASED; urgency=low
+
+ * dh_installinit: Added --error-handler option. Based on work by Thom May.
+ Closes: #209090
+
+ -- Joey Hess <joeyh@debian.org> Mon, 28 Jun 2004 19:49:15 -0400
+
debhelper (4.2.11) unstable; urgency=low
* dh_installmodules: Look for .ko files too. Closes: #248624
diff --git a/dh_installinit b/dh_installinit
index 360f378..aba32b8 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -81,6 +81,12 @@ preference to the files it normally installs.
This parameter is deprecated, use the --name parameter instead.
+=item B<--error-handler=>I<function>
+
+Call the named shell function if running the init script fails. The
+function should be provided in the prerm and postinst scripts, before the
+#DEBHELPER# token.
+
=back
=head1 NOTES
@@ -148,33 +154,33 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if ($params eq '') {
$params="defaults";
}
-
+
if (! $dh{NOSCRIPTS}) {
if (! $dh{NO_START}) {
# update-rc.d, and start script
autoscript($package,"postinst", "postinst-init",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
if ($dh{R_FLAG}) {
# stops script only on remove
autoscript($package,"prerm","prerm-init-norestart",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
}
else {
# always stops script
autoscript($package,"prerm","prerm-init",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
}
}
else {
# just update-rc.d
autoscript($package,"postinst", "postinst-init-nostart",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
}
# removes rc.d links
autoscript($package,"postrm","postrm-init",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/;s/#ERROR_HANDLER#/$dh{ERROR_HANDLER}/");
}
}
}
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 5a3156e..92c532c 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -138,6 +138,7 @@ switch variable description
--priority PRIORITY will be set to a number
--name NAME a name to use for installed files, instead of
the package name
+--error-handler ERROR_HANDLER a function to call on error
Any additional command line parameters that do not start with "-" will be
ignored, and you can access them later just as you normally would.