Fixed installing exact pkg versions on pkgs with hyphens, we use equal sign as delimiter now.

This commit is contained in:
Juan RP
2012-06-03 07:26:48 +02:00
parent f9c72e1d06
commit 34c1269504
3 changed files with 27 additions and 6 deletions

View File

@ -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