From nobody Wed Jan 15 08:21:30 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YXzVL6VJZz5l6N1; Wed, 15 Jan 2025 08:21:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YXzVL4kN9z47TV; Wed, 15 Jan 2025 08:21:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736929290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JoaWyjS+zvJRtZoK2f8Fmam2ZIYZsBJi2zeoXXDir/s=; b=DLSczWqFgW6L9+QarbvJznUa5J1LIASkeFt8T4HUDMZVMoExkieVrlN51aq+vPnaBpNXxz r2B5XEMIgjoaZPkHX4wuH3esy7YJs4u+3dVKXmA9zXw0QBkAMjvjaQ5WM8S6axpDvBEh7q OmWEQF53+uaeSwyYpm8pL+A6ahGsToJxY5h47AAbtijFXFnpXL96KpRQT4HKtIg5fI0e5u v443JnTBkbDn2gEdJ6Mz+27ehqsDOSnIyIx3C3RgsviCYMgtdvaUBK8px+k0OLu3DoVshN TflGZWtkHzCI9i8wbY/boGHavEEpeZqxVXwFepkVecXzEolOLjTS4tvTnHwmDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736929290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JoaWyjS+zvJRtZoK2f8Fmam2ZIYZsBJi2zeoXXDir/s=; b=UO1bUXe2Kw7aN4tuXYYfPr5lyrAsuh3toj65r2S8FTzk7TNO7QmYooFA+H6Ut3WdhY/WC5 iCoUVb+U1TyZ8cW9jO45GAvz8kiEzt1xz2E343sqWUZryGBbnI66BpjZme+Y8ElTvAFHhQ 10w8BWUkOUYt6UYORiwxVJ/c4HCgrF/YWgUgcIgsE1+R/aMh003f1wTt7yui0HoaUqfw7c 1MdiclUIFWw9XxWXLB90buXKMlVOHBlu6oZPPVwy0O/gmrHti2VtZy4p0+eY5rYWTnz8b3 l807LE/afsZCQDVsuAG88gmXwvUTTTYQ/aMgkH/gsPRhjFovbKtPRxGFv2jBmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736929290; a=rsa-sha256; cv=none; b=hf4E9QJ7lmZnPpa5SLHJyA/eGox1iSJQso6RYS9emimY+4pX6vPhff27+jj5/L3OFjlw7D dWWZjnTb/bIfW7IjfQWSmFewgSosxsnXk3RlcYk8Fw8IkE2E4s8MBMAydAzD5VQv1N94rv imfitG6KDBVdIkhbp8b4d5vvDPs8WjuUxriwHxzUglqFJJqd2wYlZ3q9+BawXW2gW4STcm x2vgInHuB963Gj9K7+B4Ci5iZEqQ6sCU+POcdhqHotWclYsqPzPwmiAcUeuBRehgDfqSX6 GwFETAyGD199cd6SArKN4KYIBJB2q5sJ5aG3vS0+mvVWU9LLSx4Eem6mBFXXgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YXzVL4BJHzdk8; Wed, 15 Jan 2025 08:21:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50F8LU9B096692; Wed, 15 Jan 2025 08:21:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50F8LU4B096678; Wed, 15 Jan 2025 08:21:30 GMT (envelope-from git) Date: Wed, 15 Jan 2025 08:21:30 GMT Message-Id: <202501150821.50F8LU4B096678@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 5c341fe5123d - main - pkg(7): support configuration overwrite like pkg(8) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c341fe5123d4aa6961066542de63dd4431d004d Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=5c341fe5123d4aa6961066542de63dd4431d004d commit 5c341fe5123d4aa6961066542de63dd4431d004d Author: Baptiste Daroussin AuthorDate: 2025-01-15 08:18:46 +0000 Commit: Baptiste Daroussin CommitDate: 2025-01-15 08:21:19 +0000 pkg(7): support configuration overwrite like pkg(8) with pkg(8) it is possible to overwrite a configuration like adding FreeBSD { enabled: false } in /usr/local/etc/pkg/repo/overwrite.conf which allows to change any value which can have been reviously configured in anything in /etc/pkg/*.conf now the bootstrap supports the same MFC After: 3 weeks --- usr.sbin/pkg/config.c | 55 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index 3aaa7a7815e8..2ad6c8a93756 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -353,51 +353,79 @@ parse_signature_type(struct repository *repo, const char *st) else { warnx("Signature type %s is not supported for bootstrapping," " ignoring repository %s", st, repo->name); - repo_free(repo); - return false; + return (false); } return (true); } +static struct repository * +find_repository(const char *name) +{ + struct repository *repo; + STAILQ_FOREACH(repo, &repositories, next) { + if (strcmp(repo->name, name) == 0) + return (repo); + } + return (NULL); +} + static void parse_repo(const ucl_object_t *o) { const ucl_object_t *cur; - const char *key; + const char *key, *reponame; ucl_object_iter_t it = NULL; + bool newrepo = false; + struct repository *repo; + + reponame = ucl_object_key(o); + repo = find_repository(reponame); + if (repo == NULL) { + repo = calloc(1, sizeof(struct repository)); + if (repo == NULL) + err(EXIT_FAILURE, "calloc"); - struct repository *repo = calloc(1, sizeof(struct repository)); - if (repo == NULL) - err(EXIT_FAILURE, "calloc"); - - repo->name = strdup(ucl_object_key(o)); - if (repo->name == NULL) - err(EXIT_FAILURE, "strdup"); + repo->name = strdup(reponame); + if (repo->name == NULL) + err(EXIT_FAILURE, "strdup"); + newrepo = true; + } while ((cur = ucl_iterate_object(o, &it, true))) { key = ucl_object_key(cur); if (key == NULL) continue; if (strcasecmp(key, "url") == 0) { + free(repo->url); repo->url = strdup(ucl_object_tostring(cur)); if (repo->url == NULL) err(EXIT_FAILURE, "strdup"); } else if (strcasecmp(key, "mirror_type") == 0) { parse_mirror_type(repo, ucl_object_tostring(cur)); } else if (strcasecmp(key, "signature_type") == 0) { - if (!parse_signature_type(repo, ucl_object_tostring(cur))) + if (!parse_signature_type(repo, ucl_object_tostring(cur))) { + if (newrepo) + repo_free(repo); + else + STAILQ_REMOVE(&repositories, repo, repository, next); return; + } } else if (strcasecmp(key, "fingerprints") == 0) { + free(repo->fingerprints); repo->fingerprints = strdup(ucl_object_tostring(cur)); if (repo->fingerprints == NULL) err(EXIT_FAILURE, "strdup"); } else if (strcasecmp(key, "pubkey") == 0) { + free(repo->pubkey); repo->pubkey = strdup(ucl_object_tostring(cur)); if (repo->pubkey == NULL) err(EXIT_FAILURE, "strdup"); } else if (strcasecmp(key, "enabled") == 0) { if ((cur->type != UCL_BOOLEAN) || !ucl_object_toboolean(cur)) { - repo_free(repo); + if (newrepo) + repo_free(repo); + else + STAILQ_REMOVE(&repositories, repo, repository, next); return; } } @@ -407,7 +435,8 @@ parse_repo(const ucl_object_t *o) repo_free(repo); return; } - STAILQ_INSERT_TAIL(&repositories, repo, next); + if (newrepo) + STAILQ_INSERT_TAIL(&repositories, repo, next); return; }