From 35ad10ccbd49f2dc94a75c4433b60bd47293c046 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 24 Mar 2016 10:23:20 +0100 Subject: [PATCH] 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. --- include/xbps.h.in | 1 + include/xbps_api_impl.h | 2 +- lib/initend.c | 4 ++++ lib/pkgdb.c | 2 +- lib/plist_find.c | 34 +++++++++++++++++++++++++--------- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/include/xbps.h.in b/include/xbps.h.in index 43ab1d25..6f707cb9 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -524,6 +524,7 @@ struct xbps_handle { */ xbps_dictionary_t pkgdb_revdeps; xbps_dictionary_t vpkgd; + xbps_dictionary_t vpkgd_conf; /** * @var pkgdb * diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index 39a6c93d..793fc888 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -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 *); xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *, 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 *, const char *, bool); struct xbps_repo HIDDEN *xbps_regget_repo(struct xbps_handle *, diff --git a/lib/initend.c b/lib/initend.c index a925f98d..15d7b471 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -68,6 +68,9 @@ store_vars(struct xbps_handle *xhp, xbps_dictionary_t *d, if (*d == NULL) *d = xbps_dictionary_create(); + if (xhp->vpkgd_conf) + xhp->vpkgd_conf = xbps_dictionary_create(); + /* * Parse strings delimited by ':' i.e * : @@ -85,6 +88,7 @@ store_vars(struct xbps_handle *xhp, xbps_dictionary_t *d, 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); } diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 617ada02..db974c0a 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -361,7 +361,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp) if (curpkgname == NULL) curpkgname = xbps_pkg_name(pkgdep); assert(curpkgname); - vpkgname = vpkg_user_conf(xhp, curpkgname); + vpkgname = vpkg_user_conf(xhp, curpkgname, false); if (vpkgname == NULL) vpkgname = curpkgname; diff --git a/lib/plist_find.c b/lib/plist_find.c index 6ba67141..65addf11 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -126,7 +126,7 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x, assert(xbps_object_type(a) == XBPS_TYPE_ARRAY); 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))) return pkgd; } @@ -189,20 +189,26 @@ match_pkg_by_pattern(xbps_dictionary_t repod, const char *p) } 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_iterator_t iter; const char *pkg = NULL; bool found = false; - /* init pkgdb just in case to detect vpkgs */ - (void)xbps_pkgdb_init(xhp); + if (only_conf) { + d = xhp->vpkgd_conf; + } else { + d = xhp->vpkgd; + /* init pkgdb just in case to detect vpkgs */ + (void)xbps_pkgdb_init(xhp); + } - if (xhp->vpkgd == NULL) + if (d == NULL) return NULL; - iter = xbps_dictionary_iterator(xhp->vpkgd); + iter = xbps_dictionary_iterator(d); assert(iter); while ((obj = xbps_object_iterator_next(iter))) { @@ -272,7 +278,7 @@ xbps_find_virtualpkg_in_conf(struct xbps_handle *xhp, const char *vpkg; /* Try matching vpkg from configuration files */ - vpkg = vpkg_user_conf(xhp, pkg); + vpkg = vpkg_user_conf(xhp, pkg, true); if (vpkg != NULL) { if (xbps_pkgpattern_version(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_iterator_t iter; xbps_dictionary_t pkgd = NULL; + const char *vpkg; /* Try matching vpkg from configuration files */ - if ((pkgd = xbps_find_virtualpkg_in_conf(xhp, d, pkg))) - return pkgd; + vpkg = vpkg_user_conf(xhp, pkg, false); + 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 */ iter = xbps_dictionary_iterator(d); assert(iter);