Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
delete: reinstantiate the original -f behaviour
Baptiste Daroussin committed 2 months ago
commit 6c4e197d8ba3c23c86f4447adcf4b38e143060a8
parent 9db9079
2 files changed +67 -1
modified libpkg/pkg_jobs.c
@@ -527,6 +527,9 @@ pkg_jobs_process_delete_request(struct pkg_jobs *j)
	pkgs_t to_process = vec_init();
	pkghash_it it;

+
	if (j->type == PKG_JOBS_DEINSTALL && force)
+
		return (EPKG_OK);
+

	/*
	 * Need to add also all reverse deps here
	 */
modified tests/frontend/delete.sh
@@ -7,7 +7,9 @@ tests_init \
	delete_pkg \
	delete_with_directory_owned \
	simple_delete \
-
	simple_delete_prefix_ending_with_slash
+
	simple_delete_prefix_ending_with_slash \
+
	delete_force_ignores_rdeps \
+
	delete_without_force_pulls_rdeps

delete_all_body() {
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "foo" "foo" "1"
@@ -90,6 +92,67 @@ EOF
	test -d ${TMPDIR} || atf_fail "Prefix have been removed"
}

+
delete_force_ignores_rdeps_body() {
+
	# B depends on A. "pkg delete -fy A" should only delete A, not B.
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgA" "pkgA" "1"
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgB" "pkgB" "1"
+
	cat << EOF >> pkgB.ucl
+
deps: {
+
	pkgA {
+
		origin: pkgA,
+
		version: "1"
+
	}
+
}
+
EOF
+

+
	atf_check -o ignore pkg register -M pkgA.ucl
+
	atf_check -o ignore pkg register -M pkgB.ucl
+

+
	# Force delete pkgA: should succeed and not pull in pkgB
+
	atf_check \
+
		-o match:"Deinstalling pkgA" \
+
		-o not-match:"pkgB" \
+
		-s exit:0 \
+
		pkg delete -yf pkgA
+

+
	# pkgB should still be installed
+
	atf_check \
+
		-o match:"pkgB" \
+
		-s exit:0 \
+
		pkg info
+
}
+

+
delete_without_force_pulls_rdeps_body() {
+
	# B depends on A. "pkg delete A" (no -f) should also schedule B for removal.
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgA" "pkgA" "1"
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "pkgB" "pkgB" "1"
+
	cat << EOF >> pkgB.ucl
+
deps: {
+
	pkgA {
+
		origin: pkgA,
+
		version: "1"
+
	}
+
}
+
EOF
+

+
	atf_check -o ignore pkg register -M pkgA.ucl
+
	atf_check -o ignore pkg register -M pkgB.ucl
+

+
	# Delete pkgA without force: should also remove pkgB (rdep)
+
	atf_check \
+
		-o match:"Deinstalling pkgA" \
+
		-o match:"Deinstalling pkgB" \
+
		-s exit:0 \
+
		pkg delete -y pkgA
+

+
	# Both should be gone
+
	atf_check \
+
		-o not-match:"pkgA" \
+
		-o not-match:"pkgB" \
+
		-s exit:0 \
+
		pkg info
+
}
+

delete_with_directory_owned_body() {
	touch file1
	mkdir dir