Fix 29765271e correctly.

xbps_find_virtualpkg_in_conf() needs to look at the vpkgs set up in
configuration files, not from those set by pkgdb.

As a result of this the two test cases that were failing yesterday are now
fixed.
This commit is contained in:
Juan RP 2016-03-24 10:23:20 +01:00
parent fa635399f0
commit 35ad10ccbd
5 changed files with 32 additions and 11 deletions

View File

@ -524,6 +524,7 @@ struct xbps_handle {
*/ */
xbps_dictionary_t pkgdb_revdeps; xbps_dictionary_t pkgdb_revdeps;
xbps_dictionary_t vpkgd; xbps_dictionary_t vpkgd;
xbps_dictionary_t vpkgd_conf;
/** /**
* @var pkgdb * @var pkgdb
* *

View File

@ -149,7 +149,7 @@ void HIDDEN xbps_transaction_conflicts(struct xbps_handle *, xbps_array_t);
char HIDDEN *xbps_archive_get_file(struct archive *, struct archive_entry *); char HIDDEN *xbps_archive_get_file(struct archive *, struct archive_entry *);
xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *, xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *,
struct archive_entry *); struct archive_entry *);
const char HIDDEN *vpkg_user_conf(struct xbps_handle *, const char *); const char HIDDEN *vpkg_user_conf(struct xbps_handle *, const char *, bool);
xbps_array_t HIDDEN xbps_get_pkg_fulldeptree(struct xbps_handle *, xbps_array_t HIDDEN xbps_get_pkg_fulldeptree(struct xbps_handle *,
const char *, bool); const char *, bool);
struct xbps_repo HIDDEN *xbps_regget_repo(struct xbps_handle *, struct xbps_repo HIDDEN *xbps_regget_repo(struct xbps_handle *,

View File

@ -68,6 +68,9 @@ store_vars(struct xbps_handle *xhp, xbps_dictionary_t *d,
if (*d == NULL) if (*d == NULL)
*d = xbps_dictionary_create(); *d = xbps_dictionary_create();
if (xhp->vpkgd_conf)
xhp->vpkgd_conf = xbps_dictionary_create();
/* /*
* Parse strings delimited by ':' i.e * Parse strings delimited by ':' i.e
* <left>:<right> * <left>:<right>
@ -85,6 +88,7 @@ store_vars(struct xbps_handle *xhp, xbps_dictionary_t *d,
rp++; rp++;
xbps_dictionary_set_cstring(*d, lp, rp); xbps_dictionary_set_cstring(*d, lp, rp);
xbps_dictionary_set_cstring(xhp->vpkgd_conf, lp, rp);
xbps_dbg_printf(xhp, "%s: added %s %s for %s\n", path, key, lp, rp); xbps_dbg_printf(xhp, "%s: added %s %s for %s\n", path, key, lp, rp);
} }

View File

@ -361,7 +361,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (curpkgname == NULL) if (curpkgname == NULL)
curpkgname = xbps_pkg_name(pkgdep); curpkgname = xbps_pkg_name(pkgdep);
assert(curpkgname); assert(curpkgname);
vpkgname = vpkg_user_conf(xhp, curpkgname); vpkgname = vpkg_user_conf(xhp, curpkgname, false);
if (vpkgname == NULL) if (vpkgname == NULL)
vpkgname = curpkgname; vpkgname = curpkgname;

View File

@ -126,7 +126,7 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
assert(xbps_object_type(a) == XBPS_TYPE_ARRAY); assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s); assert(s);
if ((vpkg = vpkg_user_conf(x, s))) { if ((vpkg = vpkg_user_conf(x, s, false))) {
if ((pkgd = get_pkg_in_array(a, vpkg, trans, true))) if ((pkgd = get_pkg_in_array(a, vpkg, trans, true)))
return pkgd; return pkgd;
} }
@ -189,20 +189,26 @@ match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
} }
const char HIDDEN * const char HIDDEN *
vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg) vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg, bool only_conf)
{ {
xbps_dictionary_t d;
xbps_object_t obj; xbps_object_t obj;
xbps_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkg = NULL; const char *pkg = NULL;
bool found = false; bool found = false;
if (only_conf) {
d = xhp->vpkgd_conf;
} else {
d = xhp->vpkgd;
/* init pkgdb just in case to detect vpkgs */ /* init pkgdb just in case to detect vpkgs */
(void)xbps_pkgdb_init(xhp); (void)xbps_pkgdb_init(xhp);
}
if (xhp->vpkgd == NULL) if (d == NULL)
return NULL; return NULL;
iter = xbps_dictionary_iterator(xhp->vpkgd); iter = xbps_dictionary_iterator(d);
assert(iter); assert(iter);
while ((obj = xbps_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
@ -272,7 +278,7 @@ xbps_find_virtualpkg_in_conf(struct xbps_handle *xhp,
const char *vpkg; const char *vpkg;
/* Try matching vpkg from configuration files */ /* Try matching vpkg from configuration files */
vpkg = vpkg_user_conf(xhp, pkg); vpkg = vpkg_user_conf(xhp, pkg, true);
if (vpkg != NULL) { if (vpkg != NULL) {
if (xbps_pkgpattern_version(vpkg)) if (xbps_pkgpattern_version(vpkg))
pkgd = match_pkg_by_pattern(d, vpkg); pkgd = match_pkg_by_pattern(d, vpkg);
@ -296,11 +302,21 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
xbps_object_t obj; xbps_object_t obj;
xbps_object_iterator_t iter; xbps_object_iterator_t iter;
xbps_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
const char *vpkg;
/* Try matching vpkg from configuration files */ /* Try matching vpkg from configuration files */
if ((pkgd = xbps_find_virtualpkg_in_conf(xhp, d, pkg))) vpkg = vpkg_user_conf(xhp, pkg, false);
return pkgd; if (vpkg != NULL) {
if (xbps_pkgpattern_version(vpkg))
pkgd = match_pkg_by_pattern(d, vpkg);
else if (xbps_pkg_version(vpkg))
pkgd = match_pkg_by_pkgver(d, vpkg);
else
pkgd = xbps_dictionary_get(d, vpkg);
if (pkgd)
return pkgd;
}
/* ... otherwise match the first one in dictionary */ /* ... otherwise match the first one in dictionary */
iter = xbps_dictionary_iterator(d); iter = xbps_dictionary_iterator(d);
assert(iter); assert(iter);