Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: fix --register-only with empty packages
Isaac Freund committed 1 month ago
commit 1f99b9620104f4e5062b0a8c1141ddf360cd7020
parent eaa2efc
2 files changed +42 -1
modified libpkg/pkg_add.c
@@ -1664,7 +1664,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
			pkg_delete_dirs(db, pkg, NULL);
			goto cleanup;
		}
-
	} else if (flags & PKG_ADD_REGISTER_ONLY) {
+
	} else if (flags & PKG_ADD_REGISTER_ONLY && nfiles > 0) {
		/* Need to populate config file contents so they can be stored in
		   the database */
		retcode = populate_config_file_contents(a, ae, pkg);
modified tests/frontend/install.sh
@@ -9,6 +9,7 @@ tests_init \
	post_script_ignored \
	install_missing_dep \
	install_register_only \
+
	install_register_only_empty \
	install_autoremove \
	install_autoremove_flag \
	install_suggest_clear_automatic \
@@ -267,6 +268,46 @@ EOF
		test -d dir
}

+
install_register_only_empty_body()
+
{
+
	test_setup
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
+

+
	mkdir repoconf
+
	cat << EOF > repoconf/repo.conf
+
repo: {
+
	url: file:///$TMPDIR/repo,
+
	enabled: true
+
}
+
EOF
+

+
	mkdir repo
+

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

+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg repo repo
+

+
	export REPOS_DIR="${TMPDIR}/repoconf"
+
	atf_check \
+
		-o ignore \
+
		-s exit:0 \
+
		pkg install -r repo -y --register-only test
+

+
	atf_check \
+
		-o inline:"0\n" \
+
		-e empty \
+
		pkg query "%a" test
+
}
+

install_autoremove_body() {
	# Pre-register: olddep (automatic), master depends on olddep
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "olddep" "olddep" "1"