From: Uwe Köcher Date: Tue, 25 Jul 2017 20:02:55 +0000 (+0200) Subject: more unique and simplified OS major version number with lsb_release and grep of reg... X-Git-Tag: v0.8.5~4^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c442a86d27c751ef17115b34015627b648a7feaa;p=candi.git more unique and simplified OS major version number with lsb_release and grep of reg. ex. --- diff --git a/candi.sh b/candi.sh index 5828655..abd9a63 100755 --- 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 }