mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 09:21:53 -05:00
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>
This commit is contained in:
parent
2e51e28442
commit
006387828c
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) */
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user