Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
solver: do not consider shlibs_required from base on system not running pkgbase
Baptiste Daroussin committed 1 year ago
commit b6e3941b443e17406cb6678845296fb7c0e06f5c
parent 8805cf5
4 files changed +32 -10
modified 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");
modified 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;
modified 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;
			}
		}
modified 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