[pacman-dev] CVS update of pacman-lib/lib/libalpm (add.c remove.c util.c)
Date: Thursday, March 22, 2007 @ 04:22:49 Author: aaron Path: /home/cvs-pacman/pacman-lib/lib/libalpm Modified: add.c (1.127 -> 1.128) remove.c (1.75 -> 1.76) util.c (1.50 -> 1.51) * Correct install scriptlet usage (reuse of handle->root when not needed) * Skip running scriptlet when chroot fails - to prevent issues in the host filesystem ----------+ add.c | 15 ++++++++------- remove.c | 12 +++++------- util.c | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) Index: pacman-lib/lib/libalpm/add.c diff -u pacman-lib/lib/libalpm/add.c:1.127 pacman-lib/lib/libalpm/add.c:1.128 --- pacman-lib/lib/libalpm/add.c:1.127 Sun Mar 11 17:10:03 2007 +++ pacman-lib/lib/libalpm/add.c Thu Mar 22 04:22:48 2007 @@ -318,6 +318,7 @@ pkg_count = alpm_list_count(trans->targets); for(targ = trans->packages; targ; targ = targ->next) { + char scriptlet[PATH_MAX+1]; int targ_count = 0, is_upgrade = 0, use_md5 = 0; double percent = 0.0; pmpkg_t *newpkg = (pmpkg_t *)targ->data; @@ -328,6 +329,9 @@ break; } + snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", db->path, + alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); + /* check if we have a valid sha1sum, if not, use MD5 */ if(strlen(newpkg->sha1sum) == 0) { use_md5 = 1; @@ -357,7 +361,7 @@ /* pre_upgrade scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, newpkg->data, "pre_upgrade", newpkg->version, oldpkg->version, trans); + _alpm_runscriptlet(handle->root, scriptlet, "pre_upgrade", newpkg->version, oldpkg->version, trans); } } else { is_upgrade = 0; @@ -367,7 +371,7 @@ /* pre_install scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, newpkg->data, "pre_install", newpkg->version, NULL, trans); + _alpm_runscriptlet(handle->root, scriptlet, "pre_install", newpkg->version, NULL, trans); } } @@ -817,15 +821,12 @@ /* run the post-install script if it exists */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - char pm_install[PATH_MAX]; - snprintf(pm_install, PATH_MAX, "%s%s%s-%s/install", handle->root, db->path, - alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg)); if(is_upgrade) { - _alpm_runscriptlet(handle->root, pm_install, "post_upgrade", + _alpm_runscriptlet(handle->root, scriptlet, "post_upgrade", alpm_pkg_get_version(newpkg), oldpkg ? alpm_pkg_get_version(oldpkg) : NULL, trans); } else { - _alpm_runscriptlet(handle->root, pm_install, "post_install", + _alpm_runscriptlet(handle->root, scriptlet, "post_install", alpm_pkg_get_version(newpkg), NULL, trans); } } Index: pacman-lib/lib/libalpm/remove.c diff -u pacman-lib/lib/libalpm/remove.c:1.75 pacman-lib/lib/libalpm/remove.c:1.76 --- pacman-lib/lib/libalpm/remove.c:1.75 Fri Mar 9 00:33:06 2007 +++ pacman-lib/lib/libalpm/remove.c Thu Mar 22 04:22:48 2007 @@ -275,7 +275,7 @@ for(targ = trans->packages; targ; targ = targ->next) { int position = 0; - char pm_install[PATH_MAX]; + char scriptlet[PATH_MAX]; alpm_list_t *files; info = (pmpkg_t*)targ->data; const char *pkgname = NULL; @@ -284,6 +284,8 @@ break; } + snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", db->path, + pkgname, alpm_pkg_get_version(info)); /* get the name now so we can use it after package is removed */ pkgname = alpm_pkg_get_name(info); @@ -294,9 +296,7 @@ /* run the pre-remove scriptlet if it exists */ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - snprintf(pm_install, PATH_MAX, "%s/%s-%s/install", db->path, - pkgname, alpm_pkg_get_version(info)); - _alpm_runscriptlet(handle->root, pm_install, "pre_remove", + _alpm_runscriptlet(handle->root, scriptlet, "pre_remove", alpm_pkg_get_version(info), NULL, trans); } } @@ -324,9 +324,7 @@ if(trans->type != PM_TRANS_TYPE_UPGRADE) { /* run the post-remove script if it exists */ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - snprintf(pm_install, PATH_MAX, "%s/%s-%s/install", db->path, - pkgname, alpm_pkg_get_version(info)); - _alpm_runscriptlet(handle->root, pm_install, "post_remove", + _alpm_runscriptlet(handle->root, scriptlet, "post_remove", alpm_pkg_get_version(info), NULL, trans); } } Index: pacman-lib/lib/libalpm/util.c diff -u pacman-lib/lib/libalpm/util.c:1.50 pacman-lib/lib/libalpm/util.c:1.51 --- pacman-lib/lib/libalpm/util.c:1.50 Mon Mar 19 00:49:28 2007 +++ pacman-lib/lib/libalpm/util.c Thu Mar 22 04:22:48 2007 @@ -431,6 +431,7 @@ if(stat(installfn, &buf)) { /* not found */ + _alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found", installfn); return(0); } @@ -469,6 +470,7 @@ /* just in case our cwd was removed in the upgrade operation */ if(chdir(root) != 0) { _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)"), root, strerror(errno)); + goto cleanup; } _alpm_log(PM_LOG_DEBUG, _("executing %s script..."), script);
participants (1)
-
Aaron Griffin