Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
repo: do not delete repositories in overrides, simply disable them
Baptiste Daroussin committed 20 days ago
commit 55dac2ab4dd594578887ffc533271be0f27c65e4
parent 77d3d8d
2 files changed +43 -18
modified libpkg/pkg_config.c
@@ -616,7 +616,7 @@ disable_plugins_if_static(void)
static void
add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_init_flags flags)
{
-
	const ucl_object_t *cur, *enabled, *env;
+
	const ucl_object_t *cur, *env;
	ucl_object_iter_t it = NULL;
	struct pkg_kv *kv;
	bool enable = true;
@@ -631,29 +631,15 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
	dbg(1, "parsing repository object %s", rname);

	env = NULL;
-
	enabled = ucl_object_find_key(obj, "enabled");
-
	if (enabled == NULL)
-
		enabled = ucl_object_find_key(obj, "ENABLED");
-
	if (enabled != NULL) {
-
		enable = ucl_object_toboolean(enabled);
-
		if (!enable && r != NULL) {
-
			/*
-
			 * We basically want to remove the existing repo r and
-
			 * forget all stuff parsed
-
			 */
-
			dbg(1, "disabling repo %s", rname);
-
			DL_DELETE(repos, r);
-
			pkg_repo_free(r);
-
			return;
-
		}
-
	}

	while ((cur = ucl_iterate_object(obj, &it, true))) {
		key = ucl_object_key(cur);
		if (key == NULL)
			continue;

-
		if (STRIEQ(key, "url")) {
+
		if (STRIEQ(key, "enabled")) {
+
			enable = ucl_object_toboolean(cur);
+
		} else if (STRIEQ(key, "url")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
modified tests/frontend/update.sh
@@ -7,6 +7,7 @@ tests_init \
	file_url \
	update_disabled_repo \
	update_all_disabled_repos \
+
	update_override_disabled_repo \

update_error_body() {

@@ -218,3 +219,41 @@ EOF
		-s exit:0 \
		pkg -R repos update -r repo1
}
+

+
# Verify that "pkg update -r <repo>" works when a repository is initially
+
# enabled in one config file and then overridden to disabled in another.
+
# This is the scenario from GitHub issue #2643.
+
update_override_disabled_repo_body()
+
{
+
	# Create a package and repo
+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
+
	atf_check pkg create -M test.ucl
+
	atf_check -o ignore pkg repo .
+

+
	# First config file defines the repo as enabled
+
	mkdir repos
+
	cat <<EOF > repos/base.conf
+
myrepo: {
+
	url: "file://${TMPDIR}",
+
	enabled: yes
+
}
+
EOF
+
	# Second config file overrides the repo to disabled
+
	cat <<EOF > repos/override.conf
+
myrepo: {
+
	enabled: no
+
}
+
EOF
+

+
	# Without -r, no repos should be updated
+
	atf_check \
+
		-o match:"No repositories are enabled" \
+
		-s exit:1 \
+
		pkg -R repos update
+

+
	# With -r, the overridden-disabled repo should still be updated
+
	atf_check \
+
		-o match:"Updating myrepo" \
+
		-s exit:0 \
+
		pkg -R repos update -r myrepo
+
}