From e75a524ee31185db9a29980c65a39e98cee8b7d6 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 5 Jun 2012 22:54:46 +0200 Subject: [PATCH] xbps_transaction_install_pkg: on exact match properly detect if it's installed. --- include/xbps_api.h | 2 +- lib/transaction_ops.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/xbps_api.h b/include/xbps_api.h index 4ff2425e..9064b5c0 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.5" -#define XBPS_API_VERSION "20120605-2" +#define XBPS_API_VERSION "20120605-3" #define XBPS_VERSION "0.16" /** diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index b2f67c9d..155a3fa0 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -239,8 +239,9 @@ xbps_transaction_update_pkg(const char *pkgname) int xbps_transaction_install_pkg(const char *pkg, bool reinstall) { - prop_dictionary_t pkgd; + prop_dictionary_t pkgd = NULL; pkg_state_t state; + char *pkgname; bool bypattern, best, exact; int rv; @@ -248,7 +249,7 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall) bypattern = true; best = false; exact = false; - } else if (xbps_pkg_name(pkg)) { + } else if ((pkgname = xbps_pkg_name(pkg)) != NULL) { exact = true; bypattern = false; best = false; @@ -258,7 +259,13 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall) best = true; } - if ((pkgd = xbps_pkgdb_get_pkgd(pkg, bypattern)) != NULL) { + if (exact) { + pkgd = xbps_pkgdb_get_pkgd(pkgname, false); + free(pkgname); + } else + pkgd = xbps_pkgdb_get_pkgd(pkg, bypattern); + + if (pkgd) { if (xbps_pkg_state_dictionary(pkgd, &state) != 0) { prop_object_release(pkgd); return EINVAL;