]> https://gitweb.dealii.org/ - candi.git/commitdiff
candi.sh: new guess_platform: removes dependency from lsb_release
authorUwe Köcher <mail@uwe.koecher.cc>
Fri, 22 Jan 2021 21:48:24 +0000 (22:48 +0100)
committerUwe Köcher <mail@uwe.koecher.cc>
Fri, 22 Jan 2021 21:48:24 +0000 (22:48 +0100)
candi.sh

index 391a138ac27b2965c88c14b4c445389c9f429039..c08afe55a11cc987beb4af893d41750192c7afc3 100755 (executable)
--- a/candi.sh
+++ b/candi.sh
@@ -572,41 +572,38 @@ guess_platform() {
     elif [ ! -z "$CRAYOS_VERSION" ]; then
         echo cray
 
-    elif [ -x /usr/bin/lsb_release ]; then
-        local OSVER=$(lsb_release -r -s  |grep -o -E '[0-9]+' |head -n 1)
+    elif [ -f /etc/os-release ]; then
+        local OS_ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
+        local OS_VERSIONID=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
+        local OS_NAME=$(grep -oP '(?<=^NAME=).+' /etc/os-release | tr -d '"')
+        local OS_PRETTY_NAME=$(grep -oP '(?<=^PRETTY_NAME=).+' /etc/os-release | tr -d '"')
 
-        if [ -f /etc/fedora-release ]; then
-            echo fedora${OSVER}
+        if [ "$OS_ID" == "fedora" ]; then
+            echo fedora${OS_VERSIONID}
 
-        elif [ -f /etc/centos-release ]; then
-            echo centos${OSVER}
+        elif [ "$OS_ID" == "centos" ]; then
+            echo centos${OS_VERSIONID}
 
-        elif [ -f /etc/redhat-release ]; then
-            echo rhel${OSVER}
+        elif [ "$OS_ID" == "rhel" ]; then
+            echo rhel${OS_VERSIONID}
 
-        else
-            local DISTRO=$(lsb_release -i -s)
-            local CODENAME=$(lsb_release -c -s)
-            local DESCRIPTION=$(lsb_release -d -s)
-            case ${DISTRO}:${CODENAME}:${DESCRIPTION} in
-                *:*:*Debian*9*)       echo debian9;;
-                *:*:*Ubuntu*)         echo ubuntu${OSVER};;
-                *:*:*openSUSE\ 12*)   echo opensuse12;;
-                *:*:*openSUSE\ 13*)   echo opensuse13;;
-                *:*:*openSUSE\ 15*)   echo opensuse15;;
-            esac
+        elif [ "$OS_ID" == "debian" ]; then
+            echo debian${OS_VERSIONID}
+
+        elif [ "$OS_ID" == "ubuntu" ]; then
+            echo ubuntu${OS_VERSIONID}
+
+        elif [ "$OS_ID" == "opensuse" ]; then
+            if [ "${OS_NAME}" == "openSUSE Leap" ]; then
+                echo opensuse15
+            fi
+
+        elif [ "${PRETTY_NAME}" == "Arch Linux" ]; then
+            echo arch
+
+        elif [ "${PRETTY_NAME}" == "Manjaro Linux" ]; then
+            echo arch
         fi
-    elif [ -f /etc/os-release ]; then
-       . /etc/os-release
-       if [ "${PRETTY_NAME}" == "openSUSE Leap 15.0" ]; then
-           echo opensuse15
-       fi
-       if [ "${PRETTY_NAME}" == "Manjaro Linux" ]; then
-           echo arch
-       fi
-       if [ "${PRETTY_NAME}" == "Arch Linux" ]; then
-           echo arch
-       fi
     fi
 }
 
@@ -618,15 +615,6 @@ guess_ostype() {
     elif [ -x /usr/bin/sw_vers ]; then
         echo macos
 
-    elif [ -f /etc/fedora-release ]; then
-        echo linux
-
-    elif [ -f /etc/redhat-release ]; then
-        echo linux
-
-    elif [ -x /usr/bin/lsb_release ]; then
-        echo linux
-
     elif [ -x /etc/os-release ]; then
         echo linux
     fi

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.