xbps.d(5): 'virtualpkg' can now be used to map any pkg to another.

See NEWS for more information.
This commit is contained in:
Juan RP
2016-03-23 12:46:52 +01:00
parent 897ac238c4
commit 29765271e9
4 changed files with 39 additions and 10 deletions

View File

@@ -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;

View File

@@ -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,