Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
delete: fix -fR
Baptiste Daroussin committed 1 month ago
commit 95a90f137ea507883f94f0276d7bc5ec4c898a94
parent da3a159
2 files changed +32 -1
modified libpkg/pkg_jobs.c
@@ -572,7 +572,8 @@ 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)
+
	if (j->type == PKG_JOBS_DEINSTALL && force &&
+
	    (j->flags & PKG_FLAG_RECURSIVE) == 0)
		return (EPKG_OK);

	/*
modified tests/frontend/delete.sh
@@ -20,6 +20,7 @@ tests_init \
	delete_no_scripts \
	delete_all_preserves_pkg \
	delete_recursive_force \
+
	delete_force_recursive \
	delete_dry_run_no_remove \
	delete_autoremove \
	delete_autoremove_flag
@@ -463,6 +464,35 @@ EOF
	atf_check -s exit:1 pkg info -e pkgC
}

+
delete_force_recursive_body() {
+
	# Regression test for issue #2124: pkg delete -fR should re-enable
+
	# recursive deletion (which -f alone disables).
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "lib" "lib" "1"
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "app" "app" "1"
+
	cat << EOF >> app.ucl
+
deps: {
+
	lib {
+
		origin: lib,
+
		version: "1"
+
	}
+
}
+
EOF
+

+
	atf_check -o ignore pkg register -M lib.ucl
+
	atf_check -o ignore pkg register -M app.ucl
+

+
	# -fR: force + recursive, both lib and its rdep app should be removed
+
	atf_check \
+
		-o match:"lib" \
+
		-o match:"app" \
+
		-s exit:0 \
+
		pkg delete -yfR lib
+

+
	atf_check -s exit:1 pkg info -e lib
+
	atf_check -s exit:1 pkg info -e app
+
}
+

delete_autoremove_body() {
	# test: automatic dependency; master: manual package depending on test
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "dep" "dep" "1"