From 3abe48b68aa6c3e6d3e947c084cc4da5f84940b9 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 14 Jun 2013 10:22:10 +0200 Subject: [PATCH] Introduce xbps_repo_get_pkg_plist() and use it in xbps-query -R. --- bin/xbps-query/show-info-files.c | 2 +- include/xbps_api.h.in | 16 +++++++++++++++- lib/repo.c | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/bin/xbps-query/show-info-files.c b/bin/xbps-query/show-info-files.c index 51f5342d..e4d3a360 100644 --- a/bin/xbps-query/show-info-files.c +++ b/bin/xbps-query/show-info-files.c @@ -299,7 +299,7 @@ repo_show_pkg_info(struct xbps_handle *xhp, ((ipkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL)) return errno; - if ((bpkgd = xbps_rpool_get_pkg_plist(xhp, pattern, "./props.plist")) == NULL) + if ((bpkgd = xbps_repo_get_pkg_plist(xhp, ipkgd, "./props.plist")) == NULL) return errno; prop_dictionary_set(bpkgd, "filename-sha256", diff --git a/include/xbps_api.h.in b/include/xbps_api.h.in index d9e693b3..83dfe143 100644 --- a/include/xbps_api.h.in +++ b/include/xbps_api.h.in @@ -41,7 +41,7 @@ * * This header documents the full API for the XBPS Library. */ -#define XBPS_API_VERSION "20130614" +#define XBPS_API_VERSION "20130614-1" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" @@ -1322,6 +1322,20 @@ prop_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg); prop_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg); +/** + * Returns a pkg dictionary of the matching \a plist file from a binary package, + * by looking at its package dictionary (\a pkgd) returned by a repository or rpool. + * + * @param[in] xhp Pointer to the xbps_handle struct. + * @param[in] pkgd Package dictionary returned by xbps_{repo,rpool}_get_xxxpkg(). + * @param[in] plist Plist filename to internalize from matching binary package. + * + * @return The pkg dictionary on success, NULL otherwise. + */ +prop_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp, + prop_dictionary_t pkgd, + const char *plist); + /** * Returns a proplib array of strings with reverse dependencies from * repository \a repo matching the expression \a pkg. diff --git a/lib/repo.c b/lib/repo.c index 15469dac..701fda97 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -190,6 +190,22 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) return NULL; } +prop_dictionary_t +xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd, + const char *plist) +{ + prop_dictionary_t bpkgd; + char *url; + + url = xbps_repository_pkg_path(xhp, pkgd); + if (url == NULL) + return NULL; + + bpkgd = xbps_get_pkg_plist_from_binpkg(url, plist); + free(url); + return bpkgd; +} + static prop_array_t revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str) {