xbps_repository_pool_dictionary_metadata_plist: make it accept a pkgpattern.

This commit is contained in:
Juan RP 2012-02-16 08:55:07 +01:00
parent a5c0513686
commit 6e50919d2b
2 changed files with 16 additions and 15 deletions

View File

@ -56,7 +56,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.4" #define XBPS_PKGINDEX_VERSION "1.4"
#define XBPS_API_VERSION "20120214" #define XBPS_API_VERSION "20120214-1"
#define XBPS_VERSION "0.12" #define XBPS_VERSION "0.12"
/** /**
@ -1524,16 +1524,14 @@ prop_dictionary_t
/** /**
* Iterate over the the repository pool and search for a metadata plist * 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 * file in a binary package matching `pattern'. If a package is matched
* \a pkgname, the plist file \a plistf will be internalized into a * the plist file \a plistf will be internalized into a proplib dictionary.
* proplib dictionary.
* *
* The first repository that has it wins and the loop is stopped. * When \a pattern is a pkgname, the newest package available in repositories
* This will work locally and remotely, thanks to libarchive and * will be used. Otherwise the first repository matching \a pattern.
* libfetch!
* *
* @param[in] pkgname Package 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. * @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 * @return An internalized proplib dictionary of \a plistf, otherwise NULL
* and errno is set appropiately. * and errno is set appropiately.
@ -1543,7 +1541,7 @@ prop_dictionary_t
* be found. * be found.
*/ */
prop_dictionary_t prop_dictionary_t
xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, xbps_repository_pool_dictionary_metadata_plist(const char *pattern,
const char *plistf); const char *plistf);
/*@}*/ /*@}*/

View File

@ -282,26 +282,29 @@ xbps_repository_pool_find_pkg_exact(const char *pkgver)
} }
prop_dictionary_t prop_dictionary_t
xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, xbps_repository_pool_dictionary_metadata_plist(const char *pattern,
const char *plistf) const char *plistf)
{ {
prop_dictionary_t pkgd = NULL, plistd = NULL; prop_dictionary_t pkgd = NULL, plistd = NULL;
const char *repoloc; const char *repoloc;
char *url; char *url;
assert(pkgname != NULL); assert(pattern != NULL);
assert(plistf != NULL); assert(plistf != NULL);
/* /*
* Iterate over the the repository pool and search for a plist file * 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. * internalized to a proplib dictionary.
* *
* The first repository that has it wins and the loop is stopped. * The first repository that has it wins and the loop is stopped.
* This will work locally and remotely, thanks to libarchive and * This will work locally and remotely, thanks to libarchive and
* libfetch! * 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) if (pkgd == NULL)
goto out; goto out;