From nobody Thu Jan 16 13:51:53 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 4YYkn52CYSz5kTNh; Thu, 16 Jan 2025 13:51:53 +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 4YYkn51jB3z47SH; Thu, 16 Jan 2025 13:51:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737035513; 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=u1h7Ggj+T4ptfx2GtOtA9VxHPQZkJAZhqFIpn4ZcSxQ=; b=I6bd4VfDrTnTBRjE+31LEqWqxdbT4Gt0obmUu7s7wkaP5bxdEjY5VpnJll251KuDzRkxzq idE7cpsF2K08XWdZY5gBYedzgw/YHNGYp3u6Ka3cxyt68IK2wZ496aJnG33XQjD/pKxGG6 IUeGsZTp/sezBAY5RFuJ0M9XwQTWxT0n/JFN24lW3zU6Zft/KnMWpE6u14IdCWNcb/rxHD 7rWjH4+WFPFsZz0zPG5TX6YFJ8w2gBJb1VGkHv4E/AI/vr3+8hFqYhKzMW5DxXWj5COACE lj8yJmCtYW3lmUdkjUjo+pA/MgjV3qS6T+HJ9RMNBOBHfSREj6QtKUnpEM9YOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737035513; 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=u1h7Ggj+T4ptfx2GtOtA9VxHPQZkJAZhqFIpn4ZcSxQ=; b=B/9BTWwxKqa3fduqoBIn1tZcOmq36ie+D0e50PloAlFL2BfM1GbAIFyA+p4Jh3eltZ7y+2 Y08qlm7pYnh+BvBICIKF1ZF46NLNKnDrq8ZdFE+E12FSkzsBhl1qa0Mf2qIAFsDbUfUPSr a+XlpNOV4O69NLJvrmFoIX/slQQ0x7t10jal4DlpJR5oXtt9JQjPsadInUXGTpz1vIIw2o QDsrI9elM5vKsh0/nDn8daeWm/gQQ0JKp1a3tB7nJWG/Eu+30CqV62jd7L17W5SPREHoTB 21l+LFhpioISfb5zAKQjzK9WPcU/BXz1GQeSQS6UlA3OanFApmQ7/ULSf5HKnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737035513; a=rsa-sha256; cv=none; b=L8H31dV7c0qP1Tz2Se8Uoz7ybweW1rzvbGTXjyMIkYXFBRbcIR7FOyGElzNWZS2dZhSg0X 6hU1KoKYNEc3waxcH9P5wq7XQ6m9w7+jlNrsquKo1On5VexQ+7SlyrajjCa1wnULLASWic ZQ8yNbcxp2scw0SLuFjVs8gD5oApQbBwUb23nMfvCBE8LK8aWQhuBHOvmHsIV69XhKqcTy wuF+V/YkDaw2ZutFvkjxkXu2xPTMu8ZdCthEZ51IP3t1U6/3j2muG2dAPoBRLJPthAXQ8u Mr/FDj3tdCcgn+NtQG0p0E5EmHr3UiFWqkFbqCeH8ljUpV7MoLZml4ju+cClGg== 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 4YYkn51J6gzbwJ; Thu, 16 Jan 2025 13:51:53 +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 50GDprfE016813; Thu, 16 Jan 2025 13:51:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50GDprls016810; Thu, 16 Jan 2025 13:51:53 GMT (envelope-from git) Date: Thu, 16 Jan 2025 13:51:53 GMT Message-Id: <202501161351.50GDprls016810@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: e3b4a51580fc - main - pkg(7): expand VERSION_MAJOR, VERSION_MINOR, RELEASE and OSNAME 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: e3b4a51580fcd4a1ddf0d61feb5f325ff1de5420 Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=e3b4a51580fcd4a1ddf0d61feb5f325ff1de5420 commit e3b4a51580fcd4a1ddf0d61feb5f325ff1de5420 Author: Baptiste Daroussin AuthorDate: 2025-01-16 13:50:42 +0000 Commit: Baptiste Daroussin CommitDate: 2025-01-16 13:50:42 +0000 pkg(7): expand VERSION_MAJOR, VERSION_MINOR, RELEASE and OSNAME Catchup with pkg(8) by expanding more variable when parsing repositories The only missing variable now is ARCH, this will have to wait for pkg 2.0 to be the lowest supported version. --- usr.sbin/pkg/config.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index 2ad6c8a93756..26d7dd66b2a4 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -477,11 +477,26 @@ read_conf_file(const char *confpath, const char *requested_repo, struct ucl_parser *p; ucl_object_t *obj = NULL; const char *abi = pkg_get_myabi(); + char *major, *minor; + struct utsname uts; + + if (uname(&uts)) + err(EXIT_FAILURE, "uname"); if (abi == NULL) errx(EXIT_FAILURE, "Failed to determine ABI"); p = ucl_parser_new(0); + asprintf(&major, "%d", __FreeBSD_version/100000); + if (major == NULL) + err(EXIT_FAILURE, "asprintf"); + asprintf(&minor, "%d", (__FreeBSD_version / 1000) % 100); + if (minor == NULL) + err(EXIT_FAILURE, "asprintf"); ucl_parser_register_variable(p, "ABI", abi); + ucl_parser_register_variable(p, "OSNAME", uts.sysname); + ucl_parser_register_variable(p, "RELEASE", major); + ucl_parser_register_variable(p, "VERSION_MAJOR", major); + ucl_parser_register_variable(p, "VERSION_MINOR", minor); if (!ucl_parser_add_file(p, confpath)) { if (errno != ENOENT) @@ -505,6 +520,8 @@ read_conf_file(const char *confpath, const char *requested_repo, ucl_object_unref(obj); ucl_parser_free(p); + free(major); + free(minor); return (0); }