Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Ensure pre-install script makes install fails
Baptiste Daroussin committed 9 years ago
commit 8301e2bee16bd8819a75e81c8553c937afb4f7fa
parent 7aea994
2 files changed +24 -1
modified libpkg/scripts.c
@@ -199,6 +199,7 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)

			if (WEXITSTATUS(pstat) != 0) {
				pkg_emit_error("%s script failed", map[i].arg);
+
				ret = EPKG_FATAL;
				goto cleanup;
			}
		}
modified tests/frontend/install.sh
@@ -3,7 +3,8 @@
. $(atf_get_srcdir)/test_environment.sh

tests_init \
-
	reinstall
+
	reinstall \
+
	script_fail

reinstall_body()
{
@@ -40,3 +41,24 @@ EOF
		-s exit:0 \
		pkg -o REPOS_DIR="${TMPDIR}" install -y test
}
+

+
script_fail_body()
+
{
+
	new_pkg test test 1
+
	cat << EOF >> test.ucl
+
scripts: {
+
   pre-install: "exit 1"
+
}
+
EOF
+

+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M test.ucl
+

+
	atf_check -o ignore \
+
		-e inline:"pkg: PRE-INSTALL script failed\n" \
+
		-s exit:3 \
+
		pkg -o REPOS_DIR="/dev/null" install -y ${TMPDIR}/test-1.txz
+
}