Skip to content

Commit

Permalink
solver: do not consider shlibs_required from base on system not runni…
Browse files Browse the repository at this point in the history
…ng pkgbase
  • Loading branch information
bapt committed Jan 23, 2025
1 parent 8805cf5 commit b6e3941
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
32 changes: 27 additions & 5 deletions libpkg/pkg_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions libpkg/pkg_jobs_universe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libpkg/pkg_solve.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libpkg/private/pkg_jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b6e3941

Please sign in to comment.