Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Take PKG_ATTR_{VITAL,LOCKED} into account at the solver level.
Gleb Popov committed 1 year ago
commit 052a2d3e547b937286e6bde4afefa63487784541
parent 740b7f3
3 files changed +8 -5
modified libpkg/pkg_jobs.c
@@ -669,7 +669,7 @@ _is_orphaned(struct pkg_jobs *j, const char *uid)
		return (false);
	unit = pkg_jobs_universe_find(j->universe, uid);
	if (unit != NULL) {
-
		if (!unit->pkg->automatic)
+
		if (!unit->pkg->automatic || unit->pkg->vital)
			return (false);
		npkg = unit->pkg;
	} else {
@@ -678,7 +678,7 @@ _is_orphaned(struct pkg_jobs *j, const char *uid)
		    PKG_LOAD_SHLIBS_REQUIRED|PKG_LOAD_REQUIRES);
		if (npkg == NULL)
			return (false);
-
		if (!npkg->automatic) {
+
		if (!npkg->automatic || npkg->vital) {
			pkg_free(npkg);
			return (false);
		}
@@ -1502,7 +1502,7 @@ jobs_solve_deinstall(struct pkg_jobs *j)
		while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_RDEPS|
		    PKG_LOAD_DEPS|PKG_LOAD_ANNOTATIONS|PKG_LOAD_PROVIDES|
		    PKG_LOAD_SHLIBS_PROVIDED) == EPKG_OK) {
-
			if(pkg->locked) {
+
			if(pkg->locked || pkg->vital) {
				if (tsearch(pkg, &j->lockedpkgs, comp) == NULL) {
					pkgdb_it_free(it);
					return (EPKG_FATAL);
modified libpkg/pkg_solve.c
@@ -1,5 +1,7 @@
/*-
 * Copyright (c) 2013-2017 Vsevolod Stakhov <vsevolod@FreeBSD.org>
+
 * Copyright (c) 2024 Serenity Cyber Security, LLC <license@futurecrew.ru>
+
 *                    Author: Gleb Popov <arrowd@FreeBSD.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
@@ -633,6 +635,7 @@ pkg_solve_process_universe_variable(struct pkg_solve_problem *problem,
	struct pkg_jobs *j = problem->j;
	struct pkg_job_request *jreq = NULL;
	bool chain_added = false;
+
	bool force = j->flags & PKG_FLAG_FORCE;

	LL_FOREACH(var, cur_var) {
		pkg = cur_var->unit->pkg;
@@ -1121,7 +1124,7 @@ reiterate:
		for (i = 0; i < problem->nvars; i ++) {
			struct pkg_solve_variable *var = &problem->variables[i];

-
			if (var->flags & PKG_VAR_TOP) {
+
			if (var->flags & PKG_VAR_TOP || var->unit->pkg->vital) {
				if (var->flags & PKG_VAR_FAILED) {
					var->flags ^= PKG_VAR_INSTALL | PKG_VAR_FAILED;
				}
modified src/delete.c
@@ -191,7 +191,7 @@ exec_delete(int argc, char **argv)
	}

	if (pkg_jobs_has_lockedpkgs(jobs)) {
-
		printf("The following package(s) are locked and may not ");
+
		printf("The following package(s) are locked or vital and may not ");
		printf("be removed:\n\n");
		pkg_jobs_iter_lockedpkgs(jobs, print_pkg, &locked_pkgs);
		putchar('\n');