diff --git a/include/xbps_api.h b/include/xbps_api.h index b0564c4c..7846fe80 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -53,7 +53,7 @@ * @def XBPS_RELVER * Current library release date. */ -#define XBPS_RELVER "20110127" +#define XBPS_RELVER "20110128" /** * @def XBPS_META_PATH @@ -460,6 +460,22 @@ prop_dictionary_t xbps_find_pkg_dict_from_plist_by_name(const char *plist, prop_dictionary_t xbps_find_pkg_dict_installed(const char *str, bool bypattern); +/** + * Finds a virtual package by looking at package's dictionary by + * using a package name or a package pattern. + * + * @param[in] pkgd Package dictionary. + * @param[in] str Virtual package name or package pattern. + * @param[in] bypattern If true, \a str should be a package name, + * otherwise it should be a package pattern. + * + * @return True if package dictionary matches the virtual package + * name or pattern, false otherwise. + */ +bool xbps_find_virtual_pkg_in_dict(prop_dictionary_t pkgd, + const char *str, + bool bypattern); + /** * Finds a package name matching an string object in a proplib array. * diff --git a/lib/plist.c b/lib/plist.c index 0ea9426d..db2abf1e 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -233,10 +233,10 @@ out: return rpkgd; } -static bool -find_virtual_pkg_in_dict(prop_dictionary_t d, - const char *str, - bool bypattern) +bool +xbps_find_virtual_pkg_in_dict(prop_dictionary_t d, + const char *str, + bool bypattern) { prop_array_t provides; bool found = false; @@ -273,14 +273,14 @@ find_pkg_in_dict(prop_dictionary_t d, "pkgver", &pkgver); if (xbps_pkgpattern_match(pkgver, __UNCONST(str))) break; - if (find_virtual_pkg_in_dict(obj, str, true)) + if (xbps_find_virtual_pkg_in_dict(obj, str, true)) break; } else { prop_dictionary_get_cstring_nocopy(obj, "pkgname", &dpkgn); if (strcmp(dpkgn, str) == 0) break; - if (find_virtual_pkg_in_dict(obj, str, false)) + if (xbps_find_virtual_pkg_in_dict(obj, str, false)) break; } } diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index 20f30eaa..92a48d81 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -63,9 +63,14 @@ pkgdep_find(const char *name) { struct pkgdep *pd = NULL; - TAILQ_FOREACH(pd, &pkgdep_list, pkgdep_entries) + TAILQ_FOREACH(pd, &pkgdep_list, pkgdep_entries) { if (strcmp(pd->name, name) == 0) return pd; + if (pd->d == NULL) + continue; + if (xbps_find_virtual_pkg_in_dict(pd->d, name, false)) + return pd; + } /* not found */ return NULL; @@ -80,6 +85,10 @@ pkgdep_find_idx(const char *name) TAILQ_FOREACH(pd, &pkgdep_list, pkgdep_entries) { if (strcmp(pd->name, name) == 0) return idx; + if (pd->d == NULL) + continue; + if (xbps_find_virtual_pkg_in_dict(pd->d, name, false)) + return idx; idx++; }