[PATCH] Implement %post --erroronfail

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Implement %post --erroronfail

Daniel Drake-5
I was a bit surprised to find that this flag is documented and parsed, but
not acted upon. Am I missing anything?
---
 imgcreate/creator.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 909f616..3324520 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -23,6 +23,7 @@ import sys
 import tempfile
 import shutil
 import logging
+import subprocess
 
 import selinux
 import yum
@@ -702,11 +703,16 @@ class ImageCreator(object):
                 script = "/tmp/" + os.path.basename(path)
 
             try:
-                subprocess.call([s.interp, script],
-                                preexec_fn = preexec, env = env)
+                subprocess.check_call([s.interp, script],
+                                      preexec_fn = preexec, env = env)
             except OSError, (err, msg):
                 raise CreatorError("Failed to execute %%post script "
                                    "with '%s' : %s" % (s.interp, msg))
+            except subprocess.CalledProcessError, err:
+                if not s.errorOnFail:
+                    pass
+                raise CreatorError("%%post script failed with code %d "
+                                   % err.returncode)
             finally:
                 os.unlink(path)
 
--
1.6.2.5

--
Fedora-livecd-list mailing list
[hidden email]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Implement %post --erroronfail

Jeremy Katz-3
On Sat, Dec 19, 2009 at 3:27 PM, Daniel Drake <[hidden email]> wrote:
> I was a bit surprised to find that this flag is documented and parsed, but
> not acted upon. Am I missing anything?

No one ever asked for it :-)  Patch looks correct enough, although if
we're going to check, it's probably worth at least logging a warning
on scriptlet errors if they haven't asked for fail on error.

- Jeremy

--
Fedora-livecd-list mailing list
[hidden email]
https://www.redhat.com/mailman/listinfo/fedora-livecd-list