system: replace openwrt_release with os-release
authorFlorian Eckert <fe@dev.tdt.de>
Thu, 20 Jun 2024 07:53:12 +0000 (09:53 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 20 Oct 2024 21:33:14 +0000 (23:33 +0200)
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 <fe@dev.tdt.de>
system.c

index 21ec3cdc07a2e1b1b17a292bb4a6b5ab0d478069..dcc37e0e1d09ec6243bd81471ee496785a292a1b 100644 (file)
--- 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;