diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-12-07 16:19:21 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-12-07 16:19:21 +0200 |
commit | 179ebc1745b51eb9821dd783c9df475ac539532d (patch) | |
tree | ff7a07d51a77a89482863c5b77b2f209c78655c6 | |
parent | b67d678e2af33ef9b2b43b7692322fd2898df1aa (diff) | |
download | librpm-tizen-179ebc1745b51eb9821dd783c9df475ac539532d.tar.gz librpm-tizen-179ebc1745b51eb9821dd783c9df475ac539532d.tar.bz2 librpm-tizen-179ebc1745b51eb9821dd783c9df475ac539532d.zip |
Add RPMCALLBACK_SCRIPT_ERROR callback type
- TS callback has a better chance at doing something semi-intelligent
on scriptlet failure than rpmlog callback
- Hijack "amount" for script tag that failed, "total" for exit code
which might be pretty much anything: waitpid child, actual exit status or
lua error... not probably very useful in the callback but...
- Notify before logging so users can catch the actual error message
on next rpmlog callback.. or something
-rw-r--r-- | lib/psm.c | 12 | ||||
-rw-r--r-- | lib/rpmcallback.h | 3 | ||||
-rw-r--r-- | lib/rpminstall.c | 2 |
3 files changed, 15 insertions, 2 deletions
@@ -525,8 +525,11 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, { char buf[BUFSIZ]; xx = snprintf(buf, BUFSIZ, "%s(%s-%s-%s)", sln, n, v, r); - if (rpmluaRunScript(lua, script, buf) == -1) + if (rpmluaRunScript(lua, script, buf) == -1) { + void *ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, + stag, 1); rc = RPMRC_FAIL; + } } rpmluaDelVar(lua, "arg"); @@ -853,7 +856,10 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, /* XXX filter order dependent multilib "other" arch helper error. */ if (!(psm->sq.reaped >= 0 && !strcmp(argv[0], "/usr/sbin/glibc_post_upgrade") && WEXITSTATUS(psm->sq.status) == 110)) { + void *ptr = NULL; if (psm->sq.reaped < 0) { + ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, + stag, WTERMSIG(psm->sq.child)); rpmlog(RPMLOG_ERR, _("%s(%s-%s-%s.%s) scriptlet failed, waitpid(%d) rc %d: %s\n"), sln, n, v, r, a, psm->sq.child, psm->sq.reaped, strerror(errno)); @@ -861,10 +867,14 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, } else if (!WIFEXITED(psm->sq.status) || WEXITSTATUS(psm->sq.status)) { if (WIFSIGNALED(psm->sq.status)) { + ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, + stag, WTERMSIG(psm->sq.status)); rpmlog(RPMLOG_ERR, _("%s(%s-%s-%s.%s) scriptlet failed, signal %d\n"), sln, n, v, r, a, WTERMSIG(psm->sq.status)); } else { + ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, + stag, WEXITSTATUS(psm->sq.status)); rpmlog(RPMLOG_ERR, _("%s(%s-%s-%s.%s) scriptlet failed, exit status %d\n"), sln, n, v, r, a, WEXITSTATUS(psm->sq.status)); diff --git a/lib/rpmcallback.h b/lib/rpmcallback.h index 444fa48b3..eda212af5 100644 --- a/lib/rpmcallback.h +++ b/lib/rpmcallback.h @@ -26,7 +26,8 @@ typedef enum rpmCallbackType_e { RPMCALLBACK_REPACKAGE_START = (1 << 11), RPMCALLBACK_REPACKAGE_STOP = (1 << 12), RPMCALLBACK_UNPACK_ERROR = (1 << 13), - RPMCALLBACK_CPIO_ERROR = (1 << 14) + RPMCALLBACK_CPIO_ERROR = (1 << 14), + RPMCALLBACK_SCRIPT_ERROR = (1 << 15) } rpmCallbackType; /** diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 885f666cc..586849d23 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -211,6 +211,8 @@ void * rpmShowProgress(const void * arg, break; case RPMCALLBACK_CPIO_ERROR: break; + case RPMCALLBACK_SCRIPT_ERROR: + break; case RPMCALLBACK_UNKNOWN: default: break; |