From b6660d096c2c29b59c4986c20287241667dff817 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Thu, 20 Jun 2024 09:53:12 +0200 Subject: [PATCH 1/2] system: replace openwrt_release with os-release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. So let´s use this file. Signed-off-by: Florian Eckert --- 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; From 41be3d00302bbbed12a25954d50286112b6a56b0 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Mon, 22 Jul 2024 11:24:18 +0200 Subject: [PATCH 2/2] system: add build date to ubus output In the buildsystm the value 'SOURCE_DATE_EPOCH' is used for reproducible builds. This commit adds the new information to the system board ubus call. This information must also be added during the openwrt build to the '/usr/lib/os-release' file so that this can be read. Signed-off-by: Florian Eckert --- system.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system.c b/system.c index dcc37e0..680ead9 100644 --- a/system.c +++ b/system.c @@ -279,6 +279,8 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj, key = "target"; else if (!strcasecmp(key, "PRETTY_NAME")) key = "description"; + else if (!strcasecmp(key, "OPENWRT_BUILD_DATE")) + key = "builddate"; else continue;