From 506c61b7fc36bf6d8deb811e0b2bf785ccddda07 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:05:59 +0200 Subject: [PATCH 1/7] distro script: Replaced outdated method of detecting OpenSUSE version Replaced the crude parsing of /etc/SuSE-release (which is due to be removed in future OpenSUSE versions) with equally crude parsing of /etc/os-release. /etc/os-release is present on several different distributions and usually contains the same information as /etc/lsb-release when both files are available. For now, parsing /etc/lsb-release takes precedence and /etc/os-release is only used as a fallback when the former is not available. --- scripts/distro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/distro b/scripts/distro index 6655ad47a..abe1fd54e 100755 --- a/scripts/distro +++ b/scripts/distro @@ -27,9 +27,6 @@ elif [ "${OS}" = "Linux" ] ; then PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` - elif [ -f /etc/SuSE-release ] ; then - DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//` - REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //` elif [ -f /etc/mandrake-release ] ; then DIST='Mandrake' PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//` @@ -52,6 +49,9 @@ elif [ "${OS}" = "Linux" ] ; then DIST=$LSB_DIST REV=$LSB_REV fi + elif [ -f /etc/os-release ] ; then + DIST="$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')" + REV="$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '\"')" fi if [ -n "${REV}" ] From 1543f63467886cf1009e91f8dfd070e0c19f848d Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:25:24 +0200 Subject: [PATCH 2/7] Revert "distro script: Only parse /etc/lsb-release if no known distribution is found" This reverts commit d048e5e616a3d50efbc1c41d2fdd926c08dd2ad2. The detection logic for Ubuntu (and perhaps other distributions) relies on /etc/lsb-release. --- scripts/distro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/distro b/scripts/distro index abe1fd54e..752c22e9a 100755 --- a/scripts/distro +++ b/scripts/distro @@ -42,7 +42,9 @@ elif [ "${OS}" = "Linux" ] ; then REV="" # Omit version since Arch Linux uses rolling releases elif [ -f /etc/UnitedLinux-release ] ; then DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" - elif [ -f /etc/lsb-release ] ; then + fi + + if [ -f /etc/lsb-release ] ; then LSB_DIST="`cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2`" LSB_REV="`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2`" if [ "$LSB_DIST" != "" ] ; then From 99b608ef483f4cdf53f3e24310eb1bed0bedbca5 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:33:45 +0200 Subject: [PATCH 3/7] distro script: Ignore /etc/lsb-release on Arch systems On Arch systems, /etc/lsb-release contains the placeholder version string "rolling". Prevent parsing /etc/lsb-release on Arch systems to the script won't report the distribution "Arch rolling". --- scripts/distro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/distro b/scripts/distro index 752c22e9a..a60e277b8 100755 --- a/scripts/distro +++ b/scripts/distro @@ -40,11 +40,12 @@ elif [ "${OS}" = "Linux" ] ; then elif [ -f /etc/arch-release ] ; then DIST="Arch Linux" REV="" # Omit version since Arch Linux uses rolling releases + IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling" elif [ -f /etc/UnitedLinux-release ] ; then DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" fi - if [ -f /etc/lsb-release ] ; then + if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then LSB_DIST="`cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2`" LSB_REV="`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2`" if [ "$LSB_DIST" != "" ] ; then From c806d4cf607545d38c0430a8ffb5bffb2c0c1ab1 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:35:55 +0200 Subject: [PATCH 4/7] distro script: Consider /etc/os-release along with the distribution-specific files and allow /etc/lsb-release to override it --- scripts/distro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/distro b/scripts/distro index a60e277b8..88cfd80a7 100755 --- a/scripts/distro +++ b/scripts/distro @@ -43,6 +43,9 @@ elif [ "${OS}" = "Linux" ] ; then IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling" elif [ -f /etc/UnitedLinux-release ] ; then DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" + elif [ -f /etc/os-release ] ; then + DIST="$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')" + REV="$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '\"')" fi if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then @@ -52,9 +55,6 @@ elif [ "${OS}" = "Linux" ] ; then DIST=$LSB_DIST REV=$LSB_REV fi - elif [ -f /etc/os-release ] ; then - DIST="$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')" - REV="$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '\"')" fi if [ -n "${REV}" ] From 1b816f194d0e420efbb8648c0275171e2b598599 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:37:07 +0200 Subject: [PATCH 5/7] distro script: Removed United Linux (which has been dead since 2004) --- scripts/distro | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/distro b/scripts/distro index 88cfd80a7..f97c4e94d 100755 --- a/scripts/distro +++ b/scripts/distro @@ -41,8 +41,6 @@ elif [ "${OS}" = "Linux" ] ; then DIST="Arch Linux" REV="" # Omit version since Arch Linux uses rolling releases IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling" - elif [ -f /etc/UnitedLinux-release ] ; then - DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" elif [ -f /etc/os-release ] ; then DIST="$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')" REV="$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '\"')" From e853eb1c541c10d44e7836b23d6a9c2999f921d9 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:38:42 +0200 Subject: [PATCH 6/7] distro script: Removed unnecessary quotes --- scripts/distro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/distro b/scripts/distro index f97c4e94d..b4d6b74b4 100755 --- a/scripts/distro +++ b/scripts/distro @@ -42,8 +42,8 @@ elif [ "${OS}" = "Linux" ] ; then REV="" # Omit version since Arch Linux uses rolling releases IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling" elif [ -f /etc/os-release ] ; then - DIST="$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')" - REV="$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '\"')" + DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"') + REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"') fi if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then From b197533cc6315c3def3a787b02a782e5ae895523 Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Thu, 24 Sep 2015 01:39:39 +0200 Subject: [PATCH 7/7] distro script: Added empty lines for better readability --- scripts/distro | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/distro b/scripts/distro index b4d6b74b4..0b31916b9 100755 --- a/scripts/distro +++ b/scripts/distro @@ -9,10 +9,13 @@ if [ "${OS}" = "SunOS" ] ; then OS=Solaris ARCH=`uname -p` OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" + elif [ "${OS}" = "AIX" ] ; then OSSTR="${OS} `oslevel` (`oslevel -r`)" + elif [ "${OS}" = "Linux" ] ; then KERNEL=`uname -r` + if [ -f /etc/redhat-release ] ; then DIST=$(cat /etc/redhat-release | awk '{print $1}') if [ "${DIST}" = "CentOS" ]; then @@ -27,20 +30,25 @@ elif [ "${OS}" = "Linux" ] ; then PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` + elif [ -f /etc/mandrake-release ] ; then DIST='Mandrake' PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//` REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//` + elif [ -f /etc/debian_version ] ; then DIST="Debian `cat /etc/debian_version`" REV="" + elif [ -f /etc/gentoo-release ] ; then DIST="Gentoo" REV=$(tr -d '[[:alpha:]]'