lldpd: Use /etc/os-release instead of /etc/openwrt_*
authorDaniel Dickinson <lede@daniel.thecshore.com>
Wed, 18 May 2016 07:05:42 +0000 (03:05 -0400)
committerJo-Philipp Wich <jo@mein.io>
Mon, 27 Jun 2016 13:16:01 +0000 (15:16 +0200)
With the addition of /etc/os-release patching lldpd to use
/etc/openwrt_release and to have the initscript use
/etc/openwrt_release and/or /etc/openwrt_version becomes
unnecessary.

Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
package/network/services/lldpd/files/lldpd.init
package/network/services/lldpd/patches/100-os-release.patch [deleted file]

index 633a8fbc073973111c60c2d9e61fdac9549e7625..16a6db3cca507ea66d36bda5c9c42bec907f5257 100644 (file)
@@ -10,11 +10,11 @@ LLDPSOCKET=/var/run/lldpd.socket
 
 find_release_info()
 {
-       [ -s /etc/openwrt_release ] && . /etc/openwrt_release
-       [ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
-               DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
+       [ -s /etc/os-release ] && . /etc/os-release
+       [ -z "$PRETTY_NAME" ] && [ -s /etc/openwrt_version ] && \
+               PRETTY_NAME="$(cat /etc/openwrt_version)"
 
-       echo "${DISTRIB_DESCRIPTION:-Unknown Lede release} @ $(cat /proc/sys/kernel/hostname)"
+       echo "${PRETTY_NAME:-Unknown Lede release} @ $(cat /proc/sys/kernel/hostname)"
 }
 
 start_service() {
diff --git a/package/network/services/lldpd/patches/100-os-release.patch b/package/network/services/lldpd/patches/100-os-release.patch
deleted file mode 100644 (file)
index a906f39..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-Index: lldpd-0.7.15/src/daemon/lldpd.c
-===================================================================
---- lldpd-0.7.15.orig/src/daemon/lldpd.c
-+++ lldpd-0.7.15/src/daemon/lldpd.c
-@@ -736,6 +736,10 @@ lldpd_get_os_release() {
-               fp = fopen("/usr/lib/os-release", "r");
-       }
-       if (!fp) {
-+              log_debug("localchassis", "could not open /usr/lib/os-release");
-+              fp = fopen("/etc/openwrt_release", "r");
-+      }
-+      if (!fp) {
-               log_info("localchassis",
-                   "could not open either /etc/os-release or /usr/lib/os-release");
-               return NULL;
-@@ -745,7 +749,8 @@ lldpd_get_os_release() {
-               key = strtok(line, "=");
-               val = strtok(NULL, "=");
--              if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0) {
-+              if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0 ||
-+                  strncmp(key, "DISTRIB_DESCRIPTION", sizeof(line)) == 0) {
-                       strlcpy(release, val, sizeof(line));
-                       break;
-               }
-@@ -755,11 +760,11 @@ lldpd_get_os_release() {
-       /* Remove trailing newline and all " in the string. */
-       ptr1 = release + strlen(release) - 1;
-       while (ptr1 != release &&
--          ((*ptr1 == '"') || (*ptr1 == '\n'))) {
-+          ((*ptr1 == '"') || (*ptr1 == '\n') || (*ptr1 == '\''))) {
-               *ptr1 = '\0';
-               ptr1--;
-       }
--      if (release[0] == '"')
-+      if (release[0] == '"' || release[0] == '\'')
-               return release+1;
-       return release;
- }