From b6e3941b443e17406cb6678845296fb7c0e06f5c Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 23 Jan 2025 15:58:12 +0100 Subject: [PATCH] solver: do not consider shlibs_required from base on system not running pkgbase --- libpkg/pkg_jobs.c | 32 +++++++++++++++++++++++++++----- libpkg/pkg_jobs_universe.c | 6 +++--- libpkg/pkg_solve.c | 2 +- libpkg/private/pkg_jobs.h | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/libpkg/pkg_jobs.c b/libpkg/pkg_jobs.c index 90843404e..78b87dd73 100644 --- a/libpkg/pkg_jobs.c +++ b/libpkg/pkg_jobs.c @@ -1047,7 +1047,7 @@ pkg_jobs_find_remote_pattern(struct pkg_jobs *j, struct job_pattern *jp) } bool -pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp) +pkg_jobs_need_upgrade(struct pkghash *system_shlibs, struct pkg *rp, struct pkg *lp) { int ret, ret1, ret2; struct pkg_option *lo = NULL, *ro = NULL; @@ -1241,18 +1241,40 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp) } free(l1); - if (tll_length(rp->shlibs_required) != tll_length(lp->shlibs_required)) { - free(rp->reason); - rp->reason = xstrdup("required shared library changed"); - return (true); + size_t cntr = tll_length(rp->shlibs_required); + size_t cntl = tll_length(lp->shlibs_required); + if (cntr != cntl) { + if (system_shlibs != NULL) { + /* + * before considering shlibs we need to check if we are running + * pkgbase + */ + tll_foreach(rp->shlibs_required, r) { + if (pkghash_get(system_shlibs, r->item) != NULL) + cntr--; + } + tll_foreach(lp->shlibs_required, l) { + if (pkghash_get(system_shlibs, l->item) != NULL) + cntl--; + } + } + if (cntr != cntl) { + free(rp->reason); + rp->reason = xstrdup("required shared library changed"); + return (true); + } } l1 = xcalloc(tll_length(lp->shlibs_required), sizeof (char*)); i = 0; tll_foreach(lp->shlibs_required, l) { + if (pkghash_get(system_shlibs, l->item) != NULL) + continue; l1[i++] = l->item; } i = 0; tll_foreach(rp->shlibs_required, r) { + if (pkghash_get(system_shlibs, r->item) != NULL) + continue; if (!STREQ(r->item, l1[i])) { free(rp->reason); rp->reason = xstrdup("required shared library changed"); diff --git a/libpkg/pkg_jobs_universe.c b/libpkg/pkg_jobs_universe.c index 766138cba..e17640b6d 100644 --- a/libpkg/pkg_jobs_universe.c +++ b/libpkg/pkg_jobs_universe.c @@ -334,7 +334,7 @@ pkg_jobs_universe_process_deps(struct pkg_jobs_universe *universe, if (npkg != NULL) { /* Set reason for upgrades */ - if (!pkg_jobs_need_upgrade(rpkg, npkg)) + if (!pkg_jobs_need_upgrade(universe->j->system_shlibs, rpkg, npkg)) continue; /* Save automatic flag */ rpkg->automatic = npkg->automatic; @@ -355,7 +355,7 @@ pkg_jobs_universe_process_deps(struct pkg_jobs_universe *universe, if (npkg != NULL) { /* Set reason for upgrades */ - if (!pkg_jobs_need_upgrade(rpkg, npkg)) + if (!pkg_jobs_need_upgrade(universe->j->system_shlibs, rpkg, npkg)) continue; /* Save automatic flag */ rpkg->automatic = npkg->automatic; @@ -1017,7 +1017,7 @@ pkg_jobs_universe_get_upgrade_candidates(struct pkg_jobs_universe *universe, } else { if (selected == lp && - (lp == NULL || pkg_jobs_need_upgrade(pkg, lp))) + (lp == NULL || pkg_jobs_need_upgrade(universe->j->system_shlibs, pkg, lp))) selected = pkg; else if (pkg_version_change_between(pkg, selected) == PKG_UPGRADE) selected = pkg; diff --git a/libpkg/pkg_solve.c b/libpkg/pkg_solve.c index cb3c43f83..eca5e6932 100644 --- a/libpkg/pkg_solve.c +++ b/libpkg/pkg_solve.c @@ -925,7 +925,7 @@ pkg_solve_set_initial_assumption(struct pkg_solve_problem *problem, conservative, assumed_reponame, true); if (local && (STREQ(selected->pkg->digest, local->pkg->digest) || - !pkg_jobs_need_upgrade(selected->pkg, local->pkg))) { + !pkg_jobs_need_upgrade(problem->j->system_shlibs, selected->pkg, local->pkg))) { selected = local; } } diff --git a/libpkg/private/pkg_jobs.h b/libpkg/private/pkg_jobs.h index e67d8d179..72e592759 100644 --- a/libpkg/private/pkg_jobs.h +++ b/libpkg/private/pkg_jobs.h @@ -228,7 +228,7 @@ int pkg_conflicts_append_chain(struct pkg_job_universe_item *it, /* * Check whether `rp` is an upgrade for `lp` */ -bool pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp); +bool pkg_jobs_need_upgrade(struct pkghash *system_shlibs, struct pkg *rp, struct pkg *lp); /* * Pre-process universe to fix complex upgrade chains