From 39b0ac43fcbe35897f616a8e202ae9f3bcb1ee5c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 28 Sep 2011 04:43:23 -0500 Subject: Revamp scriptlet path formation for scriptlets in local database Expose the current static get_pkgpath() function internally to the rest of the library as _alpm_local_db_pkgpath(). This allows use of this convenience function in add.c and remove.c when forming the path to the scriptlet location. Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/libalpm/remove.c') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 7f917faa..44f3ee93 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -359,7 +359,6 @@ int _alpm_remove_single_package(alpm_handle_t *handle, const char *pkgname = oldpkg->name; const char *pkgver = oldpkg->version; alpm_filelist_t *filelist; - char scriptlet[PATH_MAX]; size_t i; if(newpkg) { @@ -370,13 +369,13 @@ int _alpm_remove_single_package(alpm_handle_t *handle, _alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n", pkgname, pkgver); - snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", - _alpm_db_path(handle->db_local), pkgname, pkgver); - /* run the pre-remove scriptlet if it exists */ if(alpm_pkg_has_scriptlet(oldpkg) && !(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { + char *scriptlet = _alpm_local_db_pkgpath(handle->db_local, + oldpkg, "install"); _alpm_runscriptlet(handle, scriptlet, "pre_remove", pkgver, NULL, 0); + free(scriptlet); } } @@ -453,7 +452,10 @@ int _alpm_remove_single_package(alpm_handle_t *handle, /* run the post-remove script if it exists */ if(alpm_pkg_has_scriptlet(oldpkg) && !(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { + char *scriptlet = _alpm_local_db_pkgpath(handle->db_local, + oldpkg, "install"); _alpm_runscriptlet(handle, scriptlet, "post_remove", pkgver, NULL, 0); + free(scriptlet); } } -- cgit v1.2.3-24-g4f1b