From patchwork Thu Jun 20 10:45:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1950072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AhPjoxfQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4cdv3Tt2z20KL for ; Thu, 20 Jun 2024 20:48:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eSyViJ2WawsgfLCa6XiCBa+R2dkkq5WvEt3I9DN5oI8=; b=AhPjoxfQJs9FIh raF8yc7VFNWCdIZ4fsetpw1TueISR4R0H7OfktlDwZi9f1S0Yg0cjkK78ZlImjdxff/7I76tWCaqC gfr5xlpZzFMhigsdcoeonCOYdYxfBz+9sxO/7gKDOzUh2h4RAYafkH/yFrAVgP843AjZfJxMY8j+u mWjIswP6efhQn++6SKa9LMLu6Vo+9a1RLdcuBgTiCvxPJe/MlBlZ1aW84wdkTwvILckfxe5AzGWuo WGboIXq+1DM5S+oOBQSNu/KKFWZo2zW+jHYVDgSyq/qgFwzWc6+ZD1KNqo9rQ+TUzBiH2tttER/Wv boi+LmEOd7GhXyT/Oemg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKFIx-00000004cZS-1hOe; Thu, 20 Jun 2024 10:46:11 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKFIp-00000004cVP-3TAu for openwrt-devel@lists.openwrt.org; Thu, 20 Jun 2024 10:46:09 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1sKFIm-0055Sc-Hk; Thu, 20 Jun 2024 12:46:00 +0200 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sKFIl-003cnO-Pg; Thu, 20 Jun 2024 12:45:59 +0200 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 705BD240053; Thu, 20 Jun 2024 12:45:59 +0200 (CEST) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 0AA35240050; Thu, 20 Jun 2024 12:45:59 +0200 (CEST) Received: from localhost.localdomain (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 2D8BA3881D; Thu, 20 Jun 2024 12:45:58 +0200 (CEST) From: Florian Eckert To: daniel@makrotopia.org, mail@aparcar.org Cc: Eckert.Florian@googlemail.com, openwrt-devel@lists.openwrt.org Subject: [PATCH v2] system: replace openwrt_release with os-release Date: Thu, 20 Jun 2024 12:45:55 +0200 Message-ID: <20240620104555.24233-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-type: clean X-purgate-ID: 151534::1718880360-71C5F34D-21FCFB80/0/0 X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_034604_043631_4E66F461 X-CRM114-Status: GOOD ( 13.46 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The information required for output via the ubus is currently read from the file '/etc/openwrt_release'. The same information can also be found under '/usr/lib/os-release'. This file contains further [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [194.37.255.70 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The information required for output via the ubus is currently read from the file '/etc/openwrt_release'. The same information can also be found under '/usr/lib/os-release'. This file contains further information and is also the most common used file in other Linux distributions. Let´s use '/usr/lib/os-release'. Signed-off-by: Florian Eckert --- v2: - fixed spelling info: This is a preparatory commit to make the 'SOURCE_DATE_EPOCH' information also available via ubus [1]. The 'SOURCE_DATE_EPOCH' value is used for reproducible builds. After the merge of this and the referenced [1] commit, this information can also be made readable via the ubus. To do this, the reading of '/usr/lib/os-release' must be extended. [1] https://patchwork.ozlabs.org/project/openwrt/patch/20240618132343.3740920-1-fe@dev.tdt.de/ system.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/system.c b/system.c index 21ec3cd..dcc37e0 100644 --- a/system.c +++ b/system.c @@ -251,7 +251,7 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj, if (rootfs_type) blobmsg_add_string(&b, "rootfs_type", rootfs_type); - if ((f = fopen("/etc/openwrt_release", "r")) != NULL) + if ((f = fopen("/usr/lib/os-release", "r")) != NULL) { c = blobmsg_open_table(&b, "release"); @@ -267,17 +267,17 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj, *(val++) = 0; - if (!strcasecmp(key, "DISTRIB_ID")) + if (!strcasecmp(key, "NAME")) key = "distribution"; - else if (!strcasecmp(key, "DISTRIB_RELEASE")) + else if (!strcasecmp(key, "VERSION")) key = "version"; - else if (!strcasecmp(key, "DISTRIB_REVISION")) + else if (!strcasecmp(key, "BUILD_ID")) key = "revision"; - else if (!strcasecmp(key, "DISTRIB_CODENAME")) + else if (!strcasecmp(key, "VERSION_CODENAME")) key = "codename"; - else if (!strcasecmp(key, "DISTRIB_TARGET")) + else if (!strcasecmp(key, "OPENWRT_BOARD")) key = "target"; - else if (!strcasecmp(key, "DISTRIB_DESCRIPTION")) + else if (!strcasecmp(key, "PRETTY_NAME")) key = "description"; else continue;