diff options
author | Dan McGee <dan@archlinux.org> | 2007-11-04 09:47:21 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-11-04 11:27:41 -0600 |
commit | 006387828cbdd11e6307879ad27e9bb9409ca193 (patch) | |
tree | 1ec5af2ff1bb195684fe03f57d92ff96e897509b /lib/libalpm/trans.c | |
parent | 2e51e28442e5af84d6e121acf3445f7d34c098be (diff) | |
download | pacman-006387828cbdd11e6307879ad27e9bb9409ca193.tar.xz |
Readd scriptlet logging that got lost in an earlier commit
I broke scriptlet logging with ad691001e20272b794d2ed574b556f520e3555c0.
Readd more or less what was there before, although it still needs a lot of
work including hopefully rewriting it to a new event subsystem and having
it log to a seperate file.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r-- | lib/libalpm/trans.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 1f9f225a..a5033dee 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -530,7 +530,7 @@ static int grep(const char *fn, const char *needle) int _alpm_runscriptlet(const char *root, const char *installfn, const char *script, const char *ver, - const char *oldver) + const char *oldver, pmtrans_t *trans) { char scriptfn[PATH_MAX]; char cmdline[PATH_MAX]; @@ -624,6 +624,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } if(pid == 0) { + FILE *pipe; /* this code runs for the child only (the actual chroot/exec) */ _alpm_log(PM_LOG_DEBUG, "chrooting in %s\n", root); if(chroot(root) != 0) { @@ -638,7 +639,21 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } umask(0022); _alpm_log(PM_LOG_DEBUG, "executing \"%s\"\n", cmdline); - execl("/bin/sh", "sh", "-c", cmdline, (char *)NULL); + /* execl("/bin/sh", "sh", "-c", cmdline, (char *)NULL); */ + pipe = popen(cmdline, "r"); + if(!pipe) { + _alpm_log(PM_LOG_ERROR, _("call to popen failed (%s)"), + strerror(errno)); + retval = 1; + goto cleanup; + } + while(!feof(pipe)) { + char line[PATH_MAX]; + if(fgets(line, PATH_MAX, pipe) == NULL) + break; + alpm_logaction("%s", line); + EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL); + } exit(0); } else { /* this code runs for the parent only (wait on the child) */ |