Introduce xbps_pkgdb_get_virtualpkgd() and use in xbps_metadir_get_pkgd().
This commit is contained in:
parent
78cd625c28
commit
bdd93b7aa7
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20121119-2"
|
#define XBPS_API_VERSION "20121119-3"
|
||||||
|
|
||||||
#ifndef XBPS_VERSION
|
#ifndef XBPS_VERSION
|
||||||
#define XBPS_VERSION "UNSET"
|
#define XBPS_VERSION "UNSET"
|
||||||
@ -749,6 +749,21 @@ prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp,
|
|||||||
const char *pkg,
|
const char *pkg,
|
||||||
bool bypattern);
|
bool bypattern);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||||
|
* matching virtual pkgname or pkgver object in \a pkg.
|
||||||
|
*
|
||||||
|
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||||
|
* @param[in] pkg Package name or name-version to match.
|
||||||
|
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||||
|
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||||
|
*
|
||||||
|
* @return The matching proplib package dictionary, NULL otherwise.
|
||||||
|
*/
|
||||||
|
prop_dictionary_t xbps_pkgdb_get_virtualpkgd(struct xbps_handle *xhp,
|
||||||
|
const char *pkg,
|
||||||
|
bool bypattern);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a package dictionary from master package database (pkgdb) plist,
|
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||||
* matching the pkgver object in \a pkg dictionary.
|
* matching the pkgver object in \a pkg dictionary.
|
||||||
|
@ -83,9 +83,9 @@ xbps_metadir_get_pkgd(struct xbps_handle *xhp, const char *name)
|
|||||||
plistf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, name);
|
plistf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, name);
|
||||||
|
|
||||||
if (access(plistf, R_OK) == -1) {
|
if (access(plistf, R_OK) == -1) {
|
||||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, name, false);
|
pkgd = xbps_pkgdb_get_virtualpkgd(xhp, name, false);
|
||||||
if (pkgd == NULL)
|
if (pkgd == NULL)
|
||||||
pkgd = xbps_find_pkg_dict_installed(xhp, name, false);
|
pkgd = xbps_pkgdb_get_pkgd(xhp, name, false);
|
||||||
|
|
||||||
if (pkgd != NULL) {
|
if (pkgd != NULL) {
|
||||||
free(plistf);
|
free(plistf);
|
||||||
|
34
lib/pkgdb.c
34
lib/pkgdb.c
@ -181,6 +181,40 @@ xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, bool bypattern)
|
|||||||
return pkgd;
|
return pkgd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_dictionary_t
|
||||||
|
xbps_pkgdb_get_virtualpkgd(struct xbps_handle *xhp,
|
||||||
|
const char *vpkg,
|
||||||
|
bool bypattern)
|
||||||
|
{
|
||||||
|
prop_dictionary_t pkgd = NULL;
|
||||||
|
|
||||||
|
if (xbps_pkgdb_init(xhp) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (bypattern) {
|
||||||
|
/* first return vpkg from matching a conf file */
|
||||||
|
pkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp,
|
||||||
|
xhp->pkgdb, vpkg);
|
||||||
|
if (pkgd != NULL)
|
||||||
|
return pkgd;
|
||||||
|
|
||||||
|
/* ... otherwise the first one in array */
|
||||||
|
pkgd = xbps_find_virtualpkg_in_array_by_pattern(xhp,
|
||||||
|
xhp->pkgdb, vpkg);
|
||||||
|
} else {
|
||||||
|
/* first return vpkg from matching a conf file */
|
||||||
|
pkgd = xbps_find_virtualpkg_conf_in_array_by_name(xhp,
|
||||||
|
xhp->pkgdb, vpkg);
|
||||||
|
if (pkgd != NULL)
|
||||||
|
return pkgd;
|
||||||
|
|
||||||
|
pkgd = xbps_find_virtualpkg_in_array_by_name(xhp,
|
||||||
|
xhp->pkgdb, vpkg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkgd;
|
||||||
|
}
|
||||||
|
|
||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver)
|
xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user