]> git.donarmstrong.com Git - debhelper.git/commitdiff
r1691: * dh_installinit: Added --error-handler option. Based on work by Thom May.
authorjoey <joey>
Tue, 29 Jun 2004 00:03:54 +0000 (00:03 +0000)
committerjoey <joey>
Tue, 29 Jun 2004 00:03:54 +0000 (00:03 +0000)
Closes: #209090
Debian/Debhelper/Dh_Getopt.pm
Debian/Debhelper/Dh_Lib.pm
autoscripts/postinst-init
autoscripts/postinst-init-nostart
autoscripts/postrm-init
autoscripts/prerm-init
autoscripts/prerm-init-norestart
debian/changelog
dh_installinit
doc/PROGRAMMING

index 1da5afd2727a8ba8252150cfe8edb89334fa41d0..0c807b729adb2432d5bee2a8b74967d41bf61d3c 100644 (file)
@@ -162,6 +162,8 @@ sub parseopts {
                
                "keep-debug" => \$options{KEEP_DEBUG},
                
+               "error-handler=s" => \$options{ERROR_HANDLER},
+
                "<>" => \&NonOption,
        );
 
index f42f8bd2820c172a473d9bcb570152adec60d725..5449dcaa7d3b1b86fd6acdbd2ea4451ccdd8b0f7 100644 (file)
@@ -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
index b5bd7a5798870f5e7d311e1ed3f5867852b9df6c..8128cd96fcc641b7d959e6df26422334d36deb60 100644 (file)
@@ -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
index 5d882b6f6d3dfa8d440e9cc52e35d7ff67f97d5a..7a1bd5e849e5e20a1143df02e0ea6002b31efb65 100644 (file)
@@ -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
index 1c29298256bdcf9ca800b7214520cdf058a1d95d..628ece6e8804ed4bc549ef085f1434d5f08cbfd2 100644 (file)
@@ -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
index eab98c72f385f26e0707b191f2b89a13cec7c61a..014fa9a082834de74e3abc5287b61c28567b93e1 100644 (file)
@@ -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
index fb99152472bd99c18cf29003b9fac868112c0a55..0f64c45eb69e9cfa496f54d13907205f73be1c8c 100644 (file)
@@ -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
index 8220abab65012892229e196e12b9fa8ca89e16cf..1bad9dc1717c071c589a3b705c0b197c9e072a03 100644 (file)
@@ -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
index 360f378397176f34fe749c94b351ce8a41e2edc7..aba32b8498892477003ea109a555476773ab70f3 100755 (executable)
@@ -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}/");
                }
        }
 }
index 5a3156e185f1bef5d868480cea2e51fd8c966c82..92c532c18e528e8f70dba904e533604d030b3442 100644 (file)
@@ -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.