[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] display %post scriplets failues



We have many post scripts that we run during an install, and if one fails it is difficult to tell how or why.  I patched Anaconda to display the output of the log file if a post script fails.

To enable this functionality, add --log, and --erroronfail to your post script.

%post --interpreter /bin/sh --erroronfail --log=/tmp/foo.log
if [ ! -f /tmp/check ] ;
	echo "/tmp/check does not exist"
        exit 1
fi

exit 0

With this patch you can quickly see the error message in the GUI/console without having to do any postmortem work.


diff -r 695707da1b0b -r 0aff5ad26f74 kickstart.py
--- a/kickstart.py	Thu Sep 20 13:59:34 2007 -0400
+++ b/kickstart.py	Thu Sep 20 14:02:11 2007 -0400
@@ -70,13 +70,16 @@ class AnacondaKSScript(Script):
 
             if self.errorOnFail:
                 if intf != None:
-                    intf.messageWindow(_("Scriptlet Failure"),
-                                       _("There was an error running the "
-                                         "scriptlet.  You may examine the "
-                                         "output in %s.  This is a fatal error "
-                                         "and your install will be aborted.\n\n"
-                                         "Press the OK button to reboot your "
-                                         "system.") % (messages,))
+                    if self.logfile is not None and os.path.isfile(messages):
+                        intf.messageWindow(_("Scriptlet Failure"), open(messages).read())
+                    else:
+                        intf.messageWindow(_("Scriptlet Failure"),
+                                           _("There was an error running the "
+                                             "scriptlet.  You may examine the "
+                                             "output in %s.  This is a fatal error "
+                                             "and your install will be aborted.\n\n"
+                                             "Press the OK button to reboot your "
+                                             "system.") % (messages,))
                 sys.exit(0)
 
         os.unlink(path)

diff -r 695707da1b0b -r 0aff5ad26f74 kickstart.py
--- a/kickstart.py	Thu Sep 20 13:59:34 2007 -0400
+++ b/kickstart.py	Thu Sep 20 14:02:11 2007 -0400
@@ -70,13 +70,16 @@ class AnacondaKSScript(Script):
 
             if self.errorOnFail:
                 if intf != None:
-                    intf.messageWindow(_("Scriptlet Failure"),
-                                       _("There was an error running the "
-                                         "scriptlet.  You may examine the "
-                                         "output in %s.  This is a fatal error "
-                                         "and your install will be aborted.\n\n"
-                                         "Press the OK button to reboot your "
-                                         "system.") % (messages,))
+                    if self.logfile is not None and os.path.isfile(messages):
+                        intf.messageWindow(_("Scriptlet Failure"), open(messages).read())
+                    else:
+                        intf.messageWindow(_("Scriptlet Failure"),
+                                           _("There was an error running the "
+                                             "scriptlet.  You may examine the "
+                                             "output in %s.  This is a fatal error "
+                                             "and your install will be aborted.\n\n"
+                                             "Press the OK button to reboot your "
+                                             "system.") % (messages,))
                 sys.exit(0)
 
         os.unlink(path)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]