libxbps: extend the API, new func: xbps_repository_pool_find_pkg.

prop_dictionary_t xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best)

This function iterates over the repository pool and returns a pkg
dictionary matching its pkgname if "bypattern" is false, otherwise
if "pkg" matches the pkgdep pattern. If "best" is true, it will look
in all repos and will return the newer version, otherwise the first one
that matches the arguments specified.

With this addition supporting many small registered repos is cheap, because
it checks by-package rather than by-package-list. This also helped to removed
some duplicated code and fix some rare bugs.

Bump XBPS_RELVER to 20110118.
This commit is contained in:
Juan RP
2011-01-18 14:44:39 +01:00
parent 1125963da8
commit 503afdd48d
5 changed files with 260 additions and 326 deletions

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2008-2010 Juan Romero Pardines.
* Copyright (c) 2008-2011 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,7 +51,7 @@
* @def XBPS_RELVER
* Current library release date.
*/
#define XBPS_RELVER "20101118"
#define XBPS_RELVER "20110118"
/**
* @def XBPS_META_PATH
@ -763,9 +763,9 @@ void xbps_repository_pool_release(void);
* set to true, otherwise it will only be stopped if it returns a
* non-zero value.
*
* @param fn Function callback to execute for every repository registered in
* @param[in] fn Function callback to execute for every repository registered in
* the pool.
* @param arg Opaque data passed in to the \a fn function callback for
* @param[in] arg Opaque data passed in to the \a fn function callback for
* client data.
*
* @return 0 on success, otherwise an errno value.
@ -774,6 +774,20 @@ int xbps_repository_pool_foreach(
int (*fn)(struct repository_pool_index *, void *, bool *),
void *arg);
/**
* Finds a package dictionary in the repository pool by specifying a
* package pattern or a package name.
*
* @param[in] pkg Package pattern or name.
* @param[in] bypattern True if \a pkg is a pattern, false if it is a pkgname.
* @param[in] best True to find the best version available in repo, false to
* fetch the first package found matching its pkgname.
*
* @return The package dictionary if found, NULL otherwise.
*/
prop_dictionary_t
xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best);
/*@}*/
/** @addtogroup reposync */