Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge remote-tracking branch 'upstream/master'
Shawn Webb committed 2 years ago
commit 9d0c3f299925724a54aa81c0599abcffa4c43556
parent 74037cb
3 files changed +73 -5
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
@@ -53,6 +55,7 @@ enum pkg_solve_rule_type {
	PKG_RULE_REQUEST_CONFLICT,
	PKG_RULE_REQUEST,
	PKG_RULE_REQUIRE,
+
	PKG_RULE_VITAL,
	PKG_RULE_MAX
};

@@ -63,6 +66,7 @@ static const char *rule_reasons[] = {
	[PKG_RULE_EXPLICIT_CONFLICT] = "conflict",
	[PKG_RULE_REQUEST] = "request",
	[PKG_RULE_REQUIRE] = "require",
+
	[PKG_RULE_VITAL] = "vital",
	[PKG_RULE_MAX] = NULL
};

@@ -244,6 +248,10 @@ pkg_print_rule_buf(struct pkg_solve_rule *rule, xstring *sb)
					it->next ? ", " : "");
		}
		break;
+
	case PKG_RULE_VITAL:
+
		fprintf(sb->fp, "The following package is marked vital: %s-%s",
+
				rule->items->var->uid, rule->items->var->unit->pkg->version);
+
		break;
	default:
		break;
	}
@@ -621,6 +629,17 @@ pkg_solve_add_chain_rule(struct pkg_solve_problem *problem,
}

static int
+
pkg_solve_add_vital_rule(struct pkg_solve_problem *problem,
+
	struct pkg_solve_variable *var)
+
{
+
	struct pkg_solve_rule* rule = pkg_solve_rule_new(PKG_RULE_VITAL);
+
	pkg_solve_item_new(rule, var, 1);
+
	tll_push_front(problem->rules, rule);
+

+
	return (EPKG_OK);
+
}
+

+
static int
pkg_solve_process_universe_variable(struct pkg_solve_problem *problem,
		struct pkg_solve_variable *var)
{
@@ -631,6 +650,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;
@@ -649,6 +669,10 @@ pkg_solve_process_universe_variable(struct pkg_solve_problem *problem,
			cur_var->assumed_reponame = pkg->reponame;
		}

+
		if (pkg->locked || (pkg->vital && !force)) {
+
			pkg_solve_add_vital_rule(problem, cur_var);
+
		}
+

		/* Depends */
		LL_FOREACH(pkg->depends, dep) {
			if (pkg_solve_add_depend_rule(problem, cur_var, dep,
@@ -949,6 +973,10 @@ pkg_solve_set_initial_assumption(struct pkg_solve_problem *problem,
	case PKG_RULE_REQUIRE:
		/* XXX: deal with require rules somehow */
		break;
+
	case PKG_RULE_VITAL:
+
		var = item->var;
+
		picosat_set_default_phase_lit(problem->sat, var->order, 1);
+
		break;
	default:
		/* No nothing */
		return;
modified src/info.c
@@ -82,7 +82,6 @@ exec_info(int argc, char **argv)
	match_t match = MATCH_GLOB;
	char *pkgname;
	char *pkgversion = NULL, *pkgversion2 = NULL;
-
	size_t len;
	const char *file = NULL;
	int ch, fd;
	int ret = EPKG_OK;
@@ -336,9 +335,8 @@ exec_info(int argc, char **argv)
		 * allow to search for origin with a trailing /
		 * likes audio/linux-vsound depending on ${PORTSDIR}/audio/sox/
		 */
-
		len = strlen(pkgname);
-
		if (argc > 0 && pkgname[len - 1] == '/')
-
			pkgname[len - 1] = '\0';
+
		if (argc > 0 && pkgname[strlen(pkgname) -1] == '/')
+
			pkgname[strlen(pkgname) -1] = '\0';

		if (argc > 0) {
			j=0;
modified tests/frontend/upgrade.sh
@@ -8,7 +8,8 @@ tests_init \
	three_digit_revision \
	dual_conflict \
	file_become_dir \
-
	dir_become_file
+
	dir_become_file \
+
	vital

issue1881_body() {
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg pkg1 pkg_a 1
@@ -262,3 +263,44 @@ dir_become_file_body() {
	atf_check pkg create -M pkg.ucl -p plist-2
	atf_check -o ignore pkg -o REPOS_DIR="${TMPDIR}" -r ${TMPDIR}/target install -Uy ${TMPDIR}/pkg-2.pkg
}
+

+
vital_body() {
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "meta" "mymeta" "1"
+
	mkdir file-pkg-1
+
	cat << EOF >> meta.ucl
+
vital = true;
+
EOF
+
	echo entry > file-pkg-1/file
+
	echo "${TMPDIR}/file-pkg-1/file" > plist-1
+
	atf_check pkg create -M meta.ucl -p plist-1
+
	mkdir target
+
	atf_check -o ignore pkg -o REPOS_DIR="${TMPDIR}" -r ${TMPDIR}/target install -Uy ${TMPDIR}/mymeta-1.pkg
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "plop" "myplop" "1"
+
	atf_check pkg create -M plop.ucl
+
	atf_check -o ignore pkg -o REPOS_DIR="${TMPDIR}" -r ${TMPDIR}/target install -Uy ${TMPDIR}/myplop-1.pkg
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "plop" "myplop" "2"
+
	echo "${TMPDIR}/file-pkg-1/file" > plist-2
+
	atf_check pkg create -M plop.ucl -p plist-2
+
	mkdir repoconf
+
	cat << EOF > repoconf/repo.conf
+
local: {
+
	url: file:///$TMPDIR,
+
	enabled: true
+
}
+
EOF
+

+
	atf_check -o ignore pkg repo .
+
	atf_check -o ignore pkg -o REPOS_DIR="$TMPDIR/repoconf" -r ${TMPDIR}/target -o PKG_CACHEDIR="$TMPDIR" update
+
	OUTPUT="Updating local repository catalogue...
+
local repository is up to date.
+
All repositories are up to date.
+
Checking for upgrades (2 candidates):  done
+
Processing candidates (2 candidates):  done
+
Checking integrity... done (1 conflicting)
+
  - myplop-2 conflicts with mymeta-1 on ${TMPDIR}/file-pkg-1/file
+
Cannot solve problem using SAT solver, trying another plan
+
Checking integrity... done (0 conflicting)
+
Your packages are up to date.
+
"
+
	atf_check -o inline:"${OUTPUT}" pkg -o REPOS_DIR="$TMPDIR/repoconf" -r ${TMPDIR}/target -o PKG_CACHEDIR="$TMPDIR" upgrade -y
+
}