chore(scripts): get-distro support windows

This commit is contained in:
Zaiming (Stone) Shi 2022-01-10 10:54:24 +01:00
parent 8a92b9dafa
commit 4897e00aab
1 changed files with 23 additions and 14 deletions

View File

@ -5,11 +5,15 @@
set -euo pipefail
if [ "$(uname -s)" = 'Darwin' ]; then
UNAME="$(uname -s)"
case "$UNAME" in
Darwin)
DIST='macos'
VERSION_ID=$(sw_vers | gsed -n '/^ProductVersion:/p' | gsed -r 's/ProductVersion:(.*)/\1/g' | gsed -r 's/([0-9]+).*/\1/g' | gsed 's/^[ \t]*//g')
SYSTEM="$(echo "${DIST}${VERSION_ID}" | gsed -r 's/([a-zA-Z]*)-.*/\1/g')"
elif [ "$(uname -s)" = 'Linux' ]; then
;;
Linux)
if grep -q -i 'centos' /etc/*-release; then
DIST='centos'
VERSION_ID="$(rpm --eval '%{centos_ver}')"
@ -18,5 +22,10 @@ elif [ "$(uname -s)" = 'Linux' ]; then
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')"
fi
;;
CYGWIN*|MSYS*|MINGW*)
SYSTEM="windows"
;;
esac
echo "$SYSTEM"