Commit ba7b50c0 authored by Ariadne Conill's avatar Ariadne Conill

solver: don't clobber package swaps in cases where an installed package is...

solver: don't clobber package swaps in cases where an installed package is being replaced by a provider
parent 027df02d
......@@ -727,7 +727,12 @@ static void cset_track_deps_removed(struct apk_solver_state *ss, struct apk_pack
static void cset_check_removal_by_deps(struct apk_solver_state *ss, struct apk_package *pkg)
if (pkg->name->ss.requirers == 0)
/* NOTE: an orphaned package name may have 0 requirers because it is now being satisfied
* through an alternate provider. In these cases, we will handle this later as an adjustment
* operation using cset_gen_name_change(). As such, only insert a removal into the transaction
* if there is no other resolved provider.
if (pkg->name->ss.requirers == 0 && pkg->name->ss.chosen.pkg == NULL)
cset_gen_name_remove(ss, pkg);
......@@ -775,12 +780,16 @@ static void cset_gen_name_change(struct apk_solver_state *ss, struct apk_name *n
if (name->ss.in_changeset) return;
pkg = name->ss.chosen.pkg;
if (pkg == NULL) {
/* Package removal */
if (pkg == NULL || pkg->name != name) {
/* Original package dependency name was orphaned, emit a removal.
* See cset_gen_name_remove() for more details. */
opkg = name->ss.installed_pkg;
if (opkg) cset_gen_name_remove(ss, opkg);
name->ss.in_changeset = 1;
/* If a replacement is not provided, then we're done here. */
if (pkg == NULL)
if (pkg->ss.in_changeset) return;
......@@ -881,8 +890,12 @@ static void generate_changeset(struct apk_solver_state *ss, struct apk_dependenc
foreach_array_item(d, world)
cset_gen_dep(ss, NULL, d);
/* NOTE: We used to call cset_gen_name_remove() directly here. While slightly faster, this clobbered
* dependency nodes where a new package was provided under a different name (using provides). As such,
* treat everything as a change first and then call cset_gen_name_remove() from there if appropriate.
list_for_each_entry(ipkg, &ss->db->installed.packages, installed_pkgs_list)
cset_gen_name_remove(ss, ipkg->pkg);
cset_gen_name_change(ss, ipkg->pkg->name);
changeset->num_total_changes =
changeset->num_install +
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment