From 10531d7d452da33f3deecd712e36e0d9f5e3227f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 25 Aug 2009 06:03:02 +0200 Subject: [PATCH] Fix xbps_configure_pkg() reporting old version when upgrading packages. --HG-- extra : convert_revision : xtraeme%40gmail.com-20090825040302-azurxpyalot07j81 --- bin/xbps-bin/install.c | 3 ++- bin/xbps-bin/main.c | 2 +- include/xbps_api.h | 2 +- lib/configure.c | 27 +++++++++++++++------------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 164cb675..64825b78 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -415,7 +415,8 @@ exec_transaction(struct transaction *trans) */ while ((obj = prop_object_iterator_next(trans->iter)) != NULL) { prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - if ((rv = xbps_configure_pkg(pkgname, false)) != 0) { + prop_dictionary_get_cstring_nocopy(obj, "version", &version); + if ((rv = xbps_configure_pkg(pkgname, version, false)) != 0) { printf("Error configuring package %s (%s)\n", pkgname, strerror(rv)); return rv; diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 78c54fb1..f89208b0 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -238,7 +238,7 @@ main(int argc, char **argv) if (strcasecmp(argv[1], "all") == 0) rv = xbps_configure_all_pkgs(); else - rv = xbps_configure_pkg(argv[1], true); + rv = xbps_configure_pkg(argv[1], NULL, true); } else if (strcasecmp(argv[0], "show-deps") == 0) { /* diff --git a/include/xbps_api.h b/include/xbps_api.h index 78ba5d68..3afe1bdd 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -68,7 +68,7 @@ #endif /* From lib/configure.c */ -int xbps_configure_pkg(const char *, bool); +int xbps_configure_pkg(const char *, const char *, bool); int xbps_configure_all_pkgs(void); /* from lib/cmpver.c */ diff --git a/lib/configure.c b/lib/configure.c index dcb5b4ad..0fff3107 100644 --- a/lib/configure.c +++ b/lib/configure.c @@ -39,7 +39,7 @@ xbps_configure_all_pkgs(void) prop_dictionary_t d; prop_object_t obj; prop_object_iterator_t iter; - const char *pkgname; + const char *pkgname, *version; int rv = 0; pkg_state_t state = 0; @@ -53,11 +53,12 @@ xbps_configure_all_pkgs(void) while ((obj = prop_object_iterator_next(iter)) != NULL) { prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); + prop_dictionary_get_cstring_nocopy(obj, "version", &version); if ((rv = xbps_get_pkg_state_dictionary(obj, &state)) != 0) break; if (state != XBPS_PKG_STATE_UNPACKED) continue; - if ((rv = xbps_configure_pkg(pkgname, false)) != 0) + if ((rv = xbps_configure_pkg(pkgname, version, false)) != 0) break; } prop_object_iterator_release(iter); @@ -71,10 +72,10 @@ xbps_configure_all_pkgs(void) * to installed. */ int -xbps_configure_pkg(const char *pkgname, bool check_state) +xbps_configure_pkg(const char *pkgname, const char *version, bool check_state) { prop_dictionary_t pkgd; - const char *rootdir, *version; + const char *rootdir, *lver; char *buf; int rv = 0, flags = 0; pkg_state_t state = 0; @@ -96,17 +97,19 @@ xbps_configure_pkg(const char *pkgname, bool check_state) reconfigure = true; } else if (state != XBPS_PKG_STATE_UNPACKED) return EINVAL; + + pkgd = xbps_find_pkg_installed_from_plist(pkgname); + if (pkgd == NULL) + return ENOENT; + + prop_dictionary_get_cstring_nocopy(pkgd, "version", &lver); + prop_object_release(pkgd); + } else { + lver = version; } - pkgd = xbps_find_pkg_installed_from_plist(pkgname); - if (pkgd == NULL) - return ENOENT; - - prop_dictionary_get_cstring_nocopy(pkgd, "version", &version); - prop_object_release(pkgd); - printf("%sonfiguring package %s-%s...\n", - reconfigure ? "Rec" : "C", pkgname, version); + reconfigure ? "Rec" : "C", pkgname, lver); buf = xbps_xasprintf(".%s/metadata/%s/INSTALL", XBPS_META_PATH, pkgname);