diff --git a/NEWS b/NEWS index b6f558e4..985807a4 100644 --- a/NEWS +++ b/NEWS @@ -3,9 +3,10 @@ xbps-0.16 (???): * xbps-bin(8): the 'install' target now can (re)install an exact package version as specified on its arguments, i.e: - $ xbps-bin install foo-1.0 + $ xbps-bin install foo=1.0 If that version is not available no other version will be installed. + The equal sign must be used to specify exact versions. * xbps-repo(8): 'genindex' target is now able to remove binary packages when a greater version exists on the index. diff --git a/include/xbps_api.h b/include/xbps_api.h index c5d5c1da..806052cc 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 "20120602" +#define XBPS_API_VERSION "20120603" #define XBPS_VERSION "0.16" /** diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index e919b2c4..c0f6f5dd 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -243,14 +243,16 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall) { prop_dictionary_t pkgd; pkg_state_t state; - char *pkgname; + size_t len, i; + char *pkgname, *pkgstr = NULL; bool bypattern, best, exact; + int rv; if (xbps_pkgpattern_version(pkg)) { bypattern = true; best = false; exact = false; - } else if (xbps_pkg_version(pkg)) { + } else if (strchr(pkg, '=')) { exact = true; bypattern = false; best = false; @@ -261,10 +263,23 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall) } if (exact) { - pkgname = xbps_pkg_name(pkg); + /* find out pkgname */ + pkgname = strdup(pkg); assert(pkgname != NULL); + len = strcspn(pkg, "="); + for (i = 0; i < len; i++) + pkgname[i] = pkg[i]; + pkgname[i] = '\0'; pkgd = xbps_pkgdb_get_pkgd(pkgname, false); free(pkgname); + /* replace equal with an hyphen */ + pkgstr = strdup(pkg); + for (i = 0; i < strlen(pkgstr); i++) { + if (pkgstr[i] == '=') { + pkgstr[i] = '-'; + break; + } + } } else { pkgd = xbps_pkgdb_get_pkgd(pkg, bypattern); } @@ -280,7 +295,12 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall) return EEXIST; } } - return transaction_find_pkg(pkg, bypattern, best, exact, TRANS_INSTALL); + rv = transaction_find_pkg(pkgstr ? pkgstr : pkg, bypattern, + best, exact, TRANS_INSTALL); + if (pkgstr != NULL) + free(pkgstr); + + return rv; } int