alternatives: don't switch unchanged alternative groups on removal
Closes: #82 [via git-merge-pr]
This commit is contained in:
parent
4162ec2bd6
commit
456f775e4d
@ -332,6 +332,8 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
|
|||||||
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
|
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
|
||||||
xbps_array_t array;
|
xbps_array_t array;
|
||||||
xbps_object_t keysym;
|
xbps_object_t keysym;
|
||||||
|
xbps_dictionary_t curpkgd = pkgd;
|
||||||
|
bool current = false;
|
||||||
const char *first = NULL, *keyname;
|
const char *first = NULL, *keyname;
|
||||||
|
|
||||||
keysym = xbps_array_get(allkeys, i);
|
keysym = xbps_array_get(allkeys, i);
|
||||||
@ -342,7 +344,7 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
xbps_array_get_cstring_nocopy(array, 0, &first);
|
xbps_array_get_cstring_nocopy(array, 0, &first);
|
||||||
if (strcmp(pkgname, first) == 0) {
|
if ((current = (strcmp(pkgname, first) == 0))) {
|
||||||
/* this pkg is the current alternative for this group */
|
/* this pkg is the current alternative for this group */
|
||||||
rv = remove_symlinks(xhp,
|
rv = remove_symlinks(xhp,
|
||||||
xbps_dictionary_get(pkg_alternatives, keyname),
|
xbps_dictionary_get(pkg_alternatives, keyname),
|
||||||
@ -358,23 +360,29 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
|
|||||||
|
|
||||||
if (xbps_array_count(array) == 0) {
|
if (xbps_array_count(array) == 0) {
|
||||||
xbps_dictionary_remove(alternatives, keyname);
|
xbps_dictionary_remove(alternatives, keyname);
|
||||||
} else {
|
continue;
|
||||||
xbps_dictionary_t curpkgd;
|
}
|
||||||
|
|
||||||
|
if (!update && !current)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!current) {
|
||||||
|
/* get the new alternative group package */
|
||||||
first = NULL;
|
first = NULL;
|
||||||
xbps_array_get_cstring_nocopy(array, 0, &first);
|
xbps_array_get_cstring_nocopy(array, 0, &first);
|
||||||
curpkgd = xbps_pkgdb_get_pkg(xhp, first);
|
curpkgd = xbps_pkgdb_get_pkg(xhp, first);
|
||||||
assert(curpkgd);
|
assert(curpkgd);
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_SWITCHED, 0, NULL,
|
|
||||||
"Switched '%s' alternatives group to '%s'", keyname, first);
|
|
||||||
pkg_alternatives = xbps_dictionary_get(curpkgd, "alternatives");
|
|
||||||
rv = create_symlinks(xhp,
|
|
||||||
xbps_dictionary_get(pkg_alternatives, keyname),
|
|
||||||
keyname);
|
|
||||||
if (rv != 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_SWITCHED, 0, NULL,
|
||||||
|
"Switched '%s' alternatives group to '%s'", keyname, first);
|
||||||
|
pkg_alternatives = xbps_dictionary_get(curpkgd, "alternatives");
|
||||||
|
rv = create_symlinks(xhp,
|
||||||
|
xbps_dictionary_get(pkg_alternatives, keyname),
|
||||||
|
keyname);
|
||||||
|
if (rv != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
xbps_object_release(allkeys);
|
xbps_object_release(allkeys);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
|
Loading…
Reference in New Issue
Block a user