Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
install -A: do not mark upgraded/reinstalled packages as automatic
Baptiste Daroussin committed 1 month ago
commit dd08b148ee97c3d1dc50e0b170701a68ed8fd79c
parent 4a76ab8
2 files changed +55 -2
modified libpkg/pkg_jobs.c
@@ -1969,7 +1969,9 @@ pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j)
		if (ps->type == PKG_SOLVED_UPGRADE_INSTALL)
			flags |= PKG_ADD_SPLITTED_UPGRADE;
	}
-
	if (new->automatic || (j->flags & PKG_FLAG_AUTOMATIC) == PKG_FLAG_AUTOMATIC)
+
	if (new->automatic ||
+
	    ((j->flags & PKG_FLAG_AUTOMATIC) == PKG_FLAG_AUTOMATIC &&
+
	    ps->type == PKG_SOLVED_INSTALL))
		flags |= PKG_ADD_AUTOMATIC;

	if (new->type == PKG_GROUP_REMOTE)
modified tests/frontend/install.sh
@@ -14,7 +14,8 @@ tests_init \
	install_suggest_clear_automatic \
	install_suggest_set_automatic \
	install_no_suggest_when_flag_matches \
-
	install_from_url
+
	install_from_url \
+
	install_automatic_flag_not_on_upgrade

test_setup()
{
@@ -466,6 +467,56 @@ EOF
		pkg query "%a" test
}

+
install_automatic_flag_not_on_upgrade_body() {
+
	# Issue #1350: pkg install -Ay newpkg base should NOT mark base
+
	# as automatic when base is being upgraded (not newly installed).
+
	# Only genuinely new installs should get -A.
+

+
	# Install base v1 as non-automatic
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "base" "base" "1"
+
	atf_check -o ignore pkg register -M base.ucl
+

+
	atf_check \
+
		-o inline:"0\n" \
+
		pkg query "%a" base
+

+
	# Create repo with base v2 and newpkg v1
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "base2" "base" "2"
+
	atf_check pkg create -M base2.ucl -o ./repo
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "newpkg" "newpkg" "1"
+
	atf_check pkg create -M newpkg.ucl -o ./repo
+

+
	cat << EOF > pkg.conf
+
PKG_DBDIR=${TMPDIR}
+
REPOS_DIR=[]
+
repositories: {
+
	local: { url : file://${TMPDIR}/repo }
+
}
+
EOF
+

+
	atf_check -o ignore pkg -C ./pkg.conf repo ./repo
+
	atf_check -o ignore pkg -C ./pkg.conf update -f
+

+
	# Install both with -Ay: base is upgraded, newpkg is new
+
	atf_check \
+
		-o match:"Installing newpkg" \
+
		-o match:"Upgrading base" \
+
		-e ignore \
+
		-s exit:0 \
+
		pkg -C ./pkg.conf install -Ay newpkg base
+

+
	# newpkg should be automatic (newly installed with -A)
+
	atf_check \
+
		-o inline:"1\n" \
+
		pkg query "%a" newpkg
+

+
	# base should still be non-automatic (only upgraded, not newly installed)
+
	atf_check \
+
		-o inline:"0\n" \
+
		pkg query "%a" base
+
}
+

install_from_url_body() {
	# pkg install should accept file:// URLs
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"