summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 1da5afd2..0c807b72 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 f42f8bd2..5449dcaa 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 b5bd7a57..8128cd96 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 5d882b6f..7a1bd5e8 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 1c292982..628ece6e 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 eab98c72..014fa9a0 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 fb991524..0f64c45e 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 8220abab..1bad9dc1 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 360f3783..aba32b84 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 5a3156e1..92c532c1 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.