diff --git a/include/xbps_api.h b/include/xbps_api.h index f4934aab..51a0077b 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -55,7 +55,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.2" -#define XBPS_API_VERSION "20111027" +#define XBPS_API_VERSION "20111027-1" #define XBPS_VERSION "0.10.2" /** @@ -856,6 +856,19 @@ bool xbps_match_virtual_pkg_in_dict(prop_dictionary_t pkgd, const char *str, bool bypattern); +/** + * Match any virtual package from array \a provides in they array \a rundeps + * with dependencies. + * + * @param[in] rundeps Proplib array with dependencies as strings, i.e foo>=2.0. + * @param[in] provides Proplib array of strings with virtual pkgdeps, i.e + * foo-1.0 blah-2.0. + * + * @return True if \a any virtualpkg has been matched, false otherwise. + */ +bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, + prop_array_t provides); + /** * Finds a package dictionary in a proplib array by matching a package name. * diff --git a/lib/plist_match.c b/lib/plist_match.c index 6cc03397..2f08ca36 100644 --- a/lib/plist_match.c +++ b/lib/plist_match.c @@ -58,6 +58,29 @@ xbps_match_virtual_pkg_in_dict(prop_dictionary_t d, return found; } +bool +xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, + prop_array_t provides) +{ + const char *vpkgver, *pkgpattern; + size_t i, x; + bool found = false; + + for (i = 0; i < prop_array_count(provides); i++) { + prop_array_get_cstring_nocopy(provides, i, &vpkgver); + for (x = 0; x < prop_array_count(rundeps); x++) { + prop_array_get_cstring_nocopy(rundeps, x, &pkgpattern); + if (xbps_pkgpattern_match(vpkgver, pkgpattern)) { + found = true; + break; + } + if (found) + break; + } + } + return found; +} + static bool match_string_in_array(prop_array_t array, const char *str, int mode) {