Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: Clean up subroutines which fetch upgrade candidates
Mark Johnston committed 8 months ago
commit 735123715c85a4ea18e1841ec3029f749c0b2b71
parent cf0e119
1 file changed +11 -8
modified libpkg/pkg_jobs.c
@@ -1450,12 +1450,19 @@ jobs_solve_autoremove(struct pkg_jobs *j)
	return (EPKG_OK);
}

+
/*
+
 * Do we need to touch this package as part of an upgrade job?
+
 */
static bool
-
pkg_jobs_check_remote_candidate(struct pkg_jobs *j, struct pkg *pkg)
+
is_upgrade_candidate(struct pkg_jobs *j, struct pkg *pkg)
{
	struct pkgdb_it *it;
	struct pkg *p = NULL;

+
	/* A forced upgrade upgrades everything. */
+
	if ((j->flags & PKG_FLAG_FORCE) != 0)
+
		return (true);
+

	/* If we have no digest, we need to check this package */
	if (pkg->digest == NULL)
		return (true);
@@ -1490,7 +1497,7 @@ pkg_jobs_check_remote_candidate(struct pkg_jobs *j, struct pkg *pkg)
}

static candidates_t *
-
pkg_jobs_find_install_candidates(struct pkg_jobs *j)
+
pkg_jobs_find_upgrade_candidates(struct pkg_jobs *j)
{
	struct pkg *pkg = NULL;
	struct pkgdb_it *it;
@@ -1500,13 +1507,9 @@ pkg_jobs_find_install_candidates(struct pkg_jobs *j)
		return (NULL);

	candidates = xcalloc(1, sizeof(*candidates));
-

	while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
-

-
		if ((j->flags & PKG_FLAG_FORCE) ||
-
						pkg_jobs_check_remote_candidate(j, pkg)) {
+
		if (is_upgrade_candidate(j, pkg))
			vec_push(candidates, pkg->id);
-
		}
		pkg_free(pkg);
		pkg = NULL;
	}
@@ -1531,7 +1534,7 @@ jobs_solve_full_upgrade(struct pkg_jobs *j)

	assert(!j->solved);

-
	candidates = pkg_jobs_find_install_candidates(j);
+
	candidates = pkg_jobs_find_upgrade_candidates(j);
	jcount = candidates->len;

	pkg_emit_progress_start("Checking for upgrades (%zd candidates)",