From 29765271e966071485bc2fe3a5d0cf3df3461709 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 23 Mar 2016 12:46:52 +0100 Subject: [PATCH] xbps.d(5): 'virtualpkg' can now be used to map any pkg to another. See NEWS for more information. --- NEWS | 10 +++++++++- include/xbps_api_impl.h | 2 ++ lib/plist_find.c | 32 +++++++++++++++++++++++--------- lib/repo.c | 5 +++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index bb38547c..1d73deb5 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,16 @@ xbps-0.52 (???): + * xbps.d(5): the 'virtualpkg' keyword can now be used to map any pkg + to another, even if there's an existing real package. Example: + + virtualpkg=wifi-firmware:base-system + + Any request to the `wifi-firmware` pkg will be resolved to the + `base-system` pkg. + * libxbps: fixed some missing or incorrect printf format arguments found by using __attribute__((format,printf). Patch provided by - Michael Ghering in #148. See https://github.com/voidlinux/xbps/issues/148 + Michael Gehring in #148. See https://github.com/voidlinux/xbps/issues/148 * libxbps: ignore updates for packages that have held dependencies. Fixes #143. See https://github.com/voidlinux/xbps/issues/143 diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index f7146f23..39a6c93d 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -117,6 +117,8 @@ int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *, xbps_dictionary_t, const char *); int HIDDEN xbps_repository_find_deps(struct xbps_handle *, xbps_array_t, xbps_dictionary_t); +xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_conf(struct xbps_handle *, + xbps_dictionary_t, const char *); xbps_dictionary_t HIDDEN xbps_find_pkg_in_dict(xbps_dictionary_t, const char *); xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, xbps_dictionary_t, const char *); diff --git a/lib/plist_find.c b/lib/plist_find.c index 72b536d0..6ba67141 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2014 Juan Romero Pardines. + * Copyright (c) 2008-2016 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -263,14 +263,12 @@ vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg) return found ? pkg : NULL; } -xbps_dictionary_t -xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, - xbps_dictionary_t d, - const char *pkg) +xbps_dictionary_t HIDDEN +xbps_find_virtualpkg_in_conf(struct xbps_handle *xhp, + xbps_dictionary_t d, + const char *pkg) { - xbps_object_t obj; - xbps_object_iterator_t iter; - xbps_dictionary_t pkgd = NULL; + xbps_dictionary_t pkgd; const char *vpkg; /* Try matching vpkg from configuration files */ @@ -287,6 +285,22 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, return pkgd; } + return NULL; +} + +xbps_dictionary_t HIDDEN +xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, + xbps_dictionary_t d, + const char *pkg) +{ + xbps_object_t obj; + xbps_object_iterator_t iter; + xbps_dictionary_t pkgd = NULL; + + /* Try matching vpkg from configuration files */ + if ((pkgd = xbps_find_virtualpkg_in_conf(xhp, d, pkg))) + return pkgd; + /* ... otherwise match the first one in dictionary */ iter = xbps_dictionary_iterator(d); assert(iter); @@ -303,7 +317,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, return NULL; } -xbps_dictionary_t +xbps_dictionary_t HIDDEN xbps_find_pkg_in_dict(xbps_dictionary_t d, const char *pkg) { xbps_dictionary_t pkgd = NULL; diff --git a/lib/repo.c b/lib/repo.c index 2ef64033..8f046f48 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -340,6 +340,11 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) if (repo->idx == NULL) return NULL; + /* Try matching vpkg from configuration files */ + if ((pkgd = xbps_find_virtualpkg_in_conf(repo->xhp, repo->idx, pkg))) + return pkgd; + + /* ... otherwise match a real pkg */ pkgd = xbps_find_pkg_in_dict(repo->idx, pkg); if (pkgd) { xbps_dictionary_set_cstring_nocopy(pkgd,