From d6d232a7dde48fa8c7504043819c485748eb34c3 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Mon, 4 Apr 2022 10:02:51 +0200 Subject: [PATCH] chore: make get-distro.sh aware of windows --- scripts/get-distro.sh | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/get-distro.sh b/scripts/get-distro.sh index 2a2d39182..92e44ff2f 100755 --- a/scripts/get-distro.sh +++ b/scripts/get-distro.sh @@ -5,15 +5,24 @@ set -euo pipefail -if [ "$(uname -s)" = 'Darwin' ]; then - echo 'macos' -elif [ "$(uname -s)" = 'Linux' ]; then - if grep -q -i 'centos' /etc/*-release; then - DIST='centos' - VERSION_ID="$(rpm --eval '%{centos_ver}')" - else - DIST="$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" - VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')" - fi - echo "${DIST}${VERSION_ID}" | sed -r 's/([a-zA-Z]*)-.*/\1/g' -fi +UNAME="$(uname -s)" + +case "$UNAME" in + Darwin) + SYSTEM='macos' + ;; + Linux) + if grep -q -i 'rhel' /etc/*-release; then + DIST='centos' + VERSION_ID="$(rpm --eval '%{rhel}')" + else + DIST="$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" + VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')" + fi + SYSTEM="$(echo "${DIST}${VERSION_ID}" | sed -r 's/([a-zA-Z]*)-.*/\1/g')" + ;; + CYGWIN*|MSYS*|MINGW*) + SYSTEM="windows" + ;; +esac +echo "$SYSTEM"