summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-04 09:47:21 -0600
committerDan McGee <dan@archlinux.org>2007-11-04 11:27:41 -0600
commit006387828cbdd11e6307879ad27e9bb9409ca193 (patch)
tree1ec5af2ff1bb195684fe03f57d92ff96e897509b
parent2e51e28442e5af84d6e121acf3445f7d34c098be (diff)
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>
-rw-r--r--lib/libalpm/add.c8
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/remove.c4
-rw-r--r--lib/libalpm/trans.c19
-rw-r--r--lib/libalpm/trans.h2
-rw-r--r--src/pacman/callback.c3
6 files changed, 28 insertions, 9 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index a5885064..a10b20d1 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -696,7 +696,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
/* pre_upgrade scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle->root, newpkg->origin_data.file,
- "pre_upgrade", newpkg->version, oldpkg->version);
+ "pre_upgrade", newpkg->version, oldpkg->version, trans);
}
} else {
is_upgrade = 0;
@@ -708,7 +708,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
/* pre_install scriptlet */
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle->root, newpkg->origin_data.file,
- "pre_install", newpkg->version, NULL);
+ "pre_install", newpkg->version, NULL, trans);
}
}
@@ -845,10 +845,10 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
if(is_upgrade) {
_alpm_runscriptlet(handle->root, scriptlet, "post_upgrade",
alpm_pkg_get_version(newpkg),
- oldpkg ? alpm_pkg_get_version(oldpkg) : NULL);
+ oldpkg ? alpm_pkg_get_version(oldpkg) : NULL, trans);
} else {
_alpm_runscriptlet(handle->root, scriptlet, "post_install",
- alpm_pkg_get_version(newpkg), NULL);
+ alpm_pkg_get_version(newpkg), NULL, trans);
}
}
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index d1de5eda..20d77876 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -304,6 +304,7 @@ typedef enum _pmtransevt_t {
PM_TRANS_EVT_DELTA_PATCH_START,
PM_TRANS_EVT_DELTA_PATCH_DONE,
PM_TRANS_EVT_DELTA_PATCH_FAILED,
+ PM_TRANS_EVT_SCRIPTLET_INFO,
PM_TRANS_EVT_PRINTURI,
PM_TRANS_EVT_RETRIEVE_START,
} pmtransevt_t;
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 0ed4dd0a..2c8bdc49 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -284,7 +284,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
/* run the pre-remove scriptlet if it exists */
if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle->root, scriptlet, "pre_remove",
- alpm_pkg_get_version(info), NULL);
+ alpm_pkg_get_version(info), NULL, trans);
}
}
@@ -324,7 +324,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
/* run the post-remove script if it exists */
if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle->root, scriptlet, "post_remove",
- alpm_pkg_get_version(info), NULL);
+ alpm_pkg_get_version(info), NULL, trans);
}
}
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) */
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index f88c61e1..f3575895 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -81,7 +81,7 @@ int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
int _alpm_trans_update_depends(pmtrans_t *trans, pmpkg_t *pkg);
int _alpm_runscriptlet(const char *root, const char *installfn,
const char *script, const char *ver,
- const char *oldver);
+ const char *oldver, pmtrans_t *trans);
#endif /* _ALPM_TRANS_H */
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 9b855e5e..ccc482f8 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -256,6 +256,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
case PM_TRANS_EVT_DELTA_PATCH_FAILED:
printf(_("failed.\n"));
break;
+ case PM_TRANS_EVT_SCRIPTLET_INFO:
+ printf("%s", (char*)data1);
+ break;
case PM_TRANS_EVT_PRINTURI:
printf("%s/%s\n", (char*)data1, (char*)data2);
break;