]> https://gitweb.dealii.org/ - candi.git/commitdiff
more unique and simplified OS major version number with lsb_release and grep of reg... 44/head
authorUwe Köcher <koecher@hsu-hamburg.de>
Tue, 25 Jul 2017 20:02:55 +0000 (22:02 +0200)
committerUwe Köcher <koecher@hsu-hamburg.de>
Tue, 25 Jul 2017 20:02:55 +0000 (22:02 +0200)
candi.sh

index 5828655afb4567d8acd4d2aa8e85a6fc52d6c5cd..abd9a631c25ae2f6ccb96ae969f345cd12f58711 100755 (executable)
--- a/candi.sh
+++ b/candi.sh
@@ -560,27 +560,30 @@ guess_platform() {
     
     elif [ ! -z "$CRAYOS_VERSION" ]; then
         echo cray
-    
-    elif [ -f /etc/fedora-release ]; then
-        echo fedora`lsb_release -r -s`
-    
-    elif [ -f /etc/redhat-release ]; then
-        local RHELNAME=`gawk '{if (match($0,/\((.*)\)/,f)) print f[1]}' /etc/redhat-release`
-        case ${RHELNAME} in
-            "Maipo"*)             echo rhel7;;
-            "Core"*)              echo centos7;;
-        esac
-    
+
     elif [ -x /usr/bin/lsb_release ]; then
-        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`lsb_release -r -s`;;
-            *:*:*openSUSE\ 12*)   echo opensuse12;;
-            *:*:*openSUSE\ 13*)   echo opensuse13;;
-        esac
+        local OSVER=$(lsb_release -r -s  |grep -o -E '[0-9]+' |head -n 1)
+        
+        if [ -f /etc/fedora-release ]; then
+            echo fedora${OSVER}
+        
+        elif [ -f /etc/centos-release ]; then
+            echo centos${OSVER}
+        
+        elif [ -f /etc/redhat-release ]; then
+            echo rhel${OSVER}
+        
+        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;;
+            esac
+        fi
     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.