From 6e50919d2b3744d5fe63490fb529bad51e6c57da Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 16 Feb 2012 08:55:07 +0100 Subject: [PATCH] xbps_repository_pool_dictionary_metadata_plist: make it accept a pkgpattern. --- include/xbps_api.h | 18 ++++++++---------- lib/repository_pool_find.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/xbps_api.h b/include/xbps_api.h index 12d8234c..c0578e4c 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.4" -#define XBPS_API_VERSION "20120214" +#define XBPS_API_VERSION "20120214-1" #define XBPS_VERSION "0.12" /** @@ -1524,16 +1524,14 @@ prop_dictionary_t /** * Iterate over the the repository pool and search for a metadata plist - * file in a binary package named 'pkgname'. If a package is matched by - * \a pkgname, the plist file \a plistf will be internalized into a - * proplib dictionary. + * file in a binary package matching `pattern'. If a package is matched + * the plist file \a plistf will be internalized into a proplib dictionary. * - * The first repository that has it wins and the loop is stopped. - * This will work locally and remotely, thanks to libarchive and - * libfetch! + * When \a pattern is a pkgname, the newest package available in repositories + * will be used. Otherwise the first repository matching \a pattern. * - * @param[in] pkgname Package name to match. - * @param[in] plistf Plist file name to match. + * @param[in] pattern Package name or package pattern to match, i.e `foo>=1.0'. + * @param[in] plistf Plist file name to match, i.e XBPS_PKGPROPS or XBPS_PKGFILES. * * @return An internalized proplib dictionary of \a plistf, otherwise NULL * and errno is set appropiately. @@ -1543,7 +1541,7 @@ prop_dictionary_t * be found. */ prop_dictionary_t - xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, + xbps_repository_pool_dictionary_metadata_plist(const char *pattern, const char *plistf); /*@}*/ diff --git a/lib/repository_pool_find.c b/lib/repository_pool_find.c index d69a11dc..ff643cff 100644 --- a/lib/repository_pool_find.c +++ b/lib/repository_pool_find.c @@ -282,26 +282,29 @@ xbps_repository_pool_find_pkg_exact(const char *pkgver) } prop_dictionary_t -xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, +xbps_repository_pool_dictionary_metadata_plist(const char *pattern, const char *plistf) { prop_dictionary_t pkgd = NULL, plistd = NULL; const char *repoloc; char *url; - assert(pkgname != NULL); + assert(pattern != NULL); assert(plistf != NULL); - /* * Iterate over the the repository pool and search for a plist file - * in the binary package named 'pkgname'. The plist file will be + * in the binary package matching `pattern'. The plist file will be * internalized to a proplib dictionary. * * The first repository that has it wins and the loop is stopped. * This will work locally and remotely, thanks to libarchive and * libfetch! */ - pkgd = xbps_repository_pool_find_pkg(pkgname, false, false); + if (xbps_pkgpattern_version(pattern)) + pkgd = xbps_repository_pool_find_pkg(pattern, true, false); + else + pkgd = xbps_repository_pool_find_pkg(pattern, false, true); + if (pkgd == NULL) goto out;