"keep-debug" => \$options{KEEP_DEBUG},
+ "error-handler=s" => \$options{ERROR_HANDLER},
+
"<>" => \&NonOption,
);
# 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
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
if [ -x "/etc/init.d/#SCRIPT#" ]; then
- update-rc.d #SCRIPT# #INITPARMS# >/dev/null
+ update-rc.d #SCRIPT# #INITPARMS# >/dev/null || #ERROR_HANDLER#
fi
if [ "$1" = "purge" ] ; then
- update-rc.d #SCRIPT# remove >/dev/null
+ update-rc.d #SCRIPT# remove >/dev/null || #ERROR_HANDLER#
fi
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
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
+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
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
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}/");
}
}
}
--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.