xbps_alternatives_unregister: fix removal of current provider.
Fix logic as found by @duncaen in #101. Also set "first" when the entry is removed from the array. Fixes #102 Signed-off-by: Juan RP <xtraeme@gmail.com>
This commit is contained in:
parent
6204bc25f6
commit
04f899c80f
@ -355,8 +355,10 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
|
|||||||
|
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_REMOVED, 0, NULL,
|
xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_REMOVED, 0, NULL,
|
||||||
"%s: unregistered '%s' alternatives group", pkgver, keyname);
|
"%s: unregistered '%s' alternatives group", pkgver, keyname);
|
||||||
if (!update)
|
if (!update) {
|
||||||
xbps_remove_string_from_array(array, pkgname);
|
xbps_remove_string_from_array(array, pkgname);
|
||||||
|
xbps_array_get_cstring_nocopy(array, 0, &first);
|
||||||
|
}
|
||||||
|
|
||||||
if (xbps_array_count(array) == 0) {
|
if (xbps_array_count(array) == 0) {
|
||||||
xbps_dictionary_remove(alternatives, keyname);
|
xbps_dictionary_remove(alternatives, keyname);
|
||||||
@ -366,9 +368,7 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
|
|||||||
if (!update && !current)
|
if (!update && !current)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xbps_array_get_cstring_nocopy(array, 0, &first);
|
if (current) {
|
||||||
|
|
||||||
if (!current) {
|
|
||||||
/* get the new alternative group package */
|
/* get the new alternative group package */
|
||||||
curpkgd = xbps_pkgdb_get_pkg(xhp, first);
|
curpkgd = xbps_pkgdb_get_pkg(xhp, first);
|
||||||
assert(curpkgd);
|
assert(curpkgd);
|
||||||
|
Loading…
Reference in New Issue
Block a user