From 9cfb380cc4529ea6b9314cc67819069c8e9c1a23 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 3 Oct 2008 12:04:19 +0300 Subject: [PATCH] Filter out error exit codes from non-pre scriptlets (rhbz#216221, #rhbz465409) - typos and thinkos in scriptlets often cause duplicates to be left around for no good reason - treat non-zero exit codes from scriptlets as just warnings instead of errors - ... except that %pre and %preun are sometimes used for preventing install/uninstall of a package, preserve the traditional behavior for them - abuse rpmtsNotify() "total" value for signaling warning/error to callback --- lib/psm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/psm.c b/lib/psm.c index 0afa47e..d401366 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -703,6 +703,7 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, FD_t scriptFd; FD_t out = NULL; rpmRC rc = RPMRC_FAIL; /* assume failure */ + int warn_only = 0; char *nevra, *sname = NULL; struct rpmtd_s prefixes; @@ -832,7 +833,12 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, rpmlog(RPMLOG_ERR, _("%s scriptlet failed, signal %d\n"), sname, WTERMSIG(psm->sq.status)); } else { - rpmlog(RPMLOG_ERR, _("%s scriptlet failed, exit status %d\n"), + /* filter out "regular" error exits from non-pre scriptlets */ + if ((stag != RPMTAG_PREIN && stag != RPMTAG_PREUN)) { + warn_only = 1; + } + rpmlog(warn_only ? RPMLOG_WARNING : RPMLOG_ERR, + _("%s scriptlet failed, exit status %d\n"), sname, WEXITSTATUS(psm->sq.status)); } } else { @@ -843,7 +849,11 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, exit: rpmtdFreeData(&prefixes); + /* notify callback for all errors, "total" abused for warning/error */ if (rc != RPMRC_OK) { + if (warn_only) { + rc = RPMRC_OK; + } (void) rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, stag, rc); } -- 2.7.4