From b502dc708a63fec8fcb1073dcb52bc9459a70894 Mon Sep 17 00:00:00 2001 From: human Date: Wed, 16 Jan 2019 19:48:00 +0200 Subject: [PATCH] fix setting alternatives for packages with more than one group --- lib/package_alternatives.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/package_alternatives.c b/lib/package_alternatives.c index 145d1ba7..2985bcd5 100644 --- a/lib/package_alternatives.c +++ b/lib/package_alternatives.c @@ -249,6 +249,9 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname, if (!xbps_dictionary_count(pkg_alternatives)) return ENOENT; + if (group && !xbps_dictionary_get(pkg_alternatives, group)) + return ENOENT; + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); allkeys = xbps_dictionary_all_keys(pkg_alternatives); @@ -261,10 +264,8 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname, keysym = xbps_array_get(allkeys, i); keyname = xbps_dictionary_keysym_cstring_nocopy(keysym); - if (group && strcmp(keyname, group)) { - rv = ENOENT; + if (group && strcmp(keyname, group)) continue; - } array = xbps_dictionary_get(alternatives, keyname); if (array == NULL) @@ -294,7 +295,7 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname, xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_ADDED, 0, NULL, "%s: applying '%s' alternatives group", pkgver, keyname); rv = create_symlinks(xhp, xbps_dictionary_get(pkg_alternatives, keyname), keyname); - if (rv != 0) + if (rv != 0 || group) break; } xbps_object_release(allkeys);