diff --git a/bin/xbps-bin/check_pkg_requiredby.c b/bin/xbps-bin/check_pkg_requiredby.c index b6c1140f..07577b19 100644 --- a/bin/xbps-bin/check_pkg_requiredby.c +++ b/bin/xbps-bin/check_pkg_requiredby.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011 Juan Romero Pardines. + * Copyright (c) 2011-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,7 +87,7 @@ check_pkg_requiredby(const char *pkgname, void *arg) /* * Check for pkgpattern match with real packages... */ - if (!xbps_match_pkgpattern_in_array(curpkg_rdeps, pkgver)) { + if (!xbps_match_pkgdep_in_array(curpkg_rdeps, pkgver)) { /* * ... otherwise check if package provides any virtual * package and is matched against any object in diff --git a/include/xbps_api.h b/include/xbps_api.h index fce62fcb..4234ec43 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.3" -#define XBPS_API_VERSION "20120116" +#define XBPS_API_VERSION "20120116-1" #define XBPS_VERSION "0.12" /** @@ -1043,6 +1043,17 @@ bool xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname); */ bool xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern); +/** + * Match a package dependency against any package pattern in the specified + * array of strings. + * + * @param[in] array The proplib array where to look for. + * @param[in] pkgver The package name-version tuple to match. + * + * @return true on success, false otherwise and errno is set appropiately. + */ +bool xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver); + /** * Match a string (exact match) in the specified array of strings. * diff --git a/lib/plist_match.c b/lib/plist_match.c index 57b2d4e7..3c74641e 100644 --- a/lib/plist_match.c +++ b/lib/plist_match.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2011 Juan Romero Pardines. + * Copyright (c) 2008-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -118,7 +118,14 @@ match_string_in_array(prop_array_t array, const char *str, int mode) } free(curpkgname); } else if (mode == 2) { - /* match by pkgpattern */ + /* match pkgpattern against pkgdep */ + pkgdep = prop_string_cstring_nocopy(obj); + if (xbps_pkgpattern_match(pkgdep, str)) { + found = true; + break; + } + } else if (mode == 3) { + /* match pkgdep against pkgpattern */ pkgdep = prop_string_cstring_nocopy(obj); if (xbps_pkgpattern_match(str, pkgdep)) { found = true; @@ -148,3 +155,9 @@ xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern) { return match_string_in_array(array, pattern, 2); } + +bool +xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver) +{ + return match_string_in_array(array, pkgver, 3); +}