Skip to content

Commit

Permalink
xbps.d(5): 'virtualpkg' can now be used to map any pkg to another.
Browse files Browse the repository at this point in the history
See NEWS for more information.
  • Loading branch information
Juan RP committed Mar 23, 2016
1 parent 897ac23 commit 2976527
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
10 changes: 9 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/xbps_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
32 changes: 23 additions & 9 deletions lib/plist_find.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions lib/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2976527

Please sign in to comment.