diff options
author | Liang Qi <liang.qi@qt.io> | 2019-11-06 14:19:45 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-11-06 14:19:45 +0100 |
commit | 68189ab965784b5f83729e08de5f54965dc7cd32 (patch) | |
tree | 5a9bfe72da0ee5b1ae5abca6c4854503efc06840 /coin/provisioning/common/unix/common.sourced.sh | |
parent | 98cb5fa96506837f417d6c2cfdb9c6abe3223d52 (diff) | |
parent | d690f84fd40beebcb9891df8bb656973daf55b22 (diff) |
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
coin/provisioning/qtci-macos-10.12-x86_64/05-systemsetup.sh
Change-Id: Ie9eae2144868cbe4a6c5ff9472c1a0e8fd53ed08
Diffstat (limited to 'coin/provisioning/common/unix/common.sourced.sh')
-rw-r--r-- | coin/provisioning/common/unix/common.sourced.sh | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/coin/provisioning/common/unix/common.sourced.sh b/coin/provisioning/common/unix/common.sourced.sh index a52880b2..aca5dd04 100644 --- a/coin/provisioning/common/unix/common.sourced.sh +++ b/coin/provisioning/common/unix/common.sourced.sh @@ -65,8 +65,10 @@ fatal () { fi } +# Takes one argument which should be the filename of this script. Returns true +# if the script is being sourced, false if the script is being executed. is_script_executed () { - [ x"$(basename "$0")" = x"$1" ] + [ x"$(basename $(echo "$0" | sed s/^-//))" = x"$1" ] } @@ -74,6 +76,25 @@ is_script_executed common.sourced.sh \ && fatal "Script common.sourced.sh should always be sourced, not executed" +_detect_linux_OS_ID () { + if [ -f /etc/os-release ] + then + . /etc/os-release + PROVISIONING_OS_ID="$ID" + elif [ -f /etc/redhat-release ] + then + case "$(cat /etc/redhat-release)" in + "Red Hat Enterprise Linux"*) + PROVISIONING_OS_ID="rhel" + ;; + "CentOS Linux"*) + PROVISIONING_OS_ID="centos" + ;; + *) fatal "Unknown string in /etc/redhat-release" ;; + esac + fi +} + set_common_environment () { # Unfortunately we can't find the provisioning directory from a sourced # script in a portable way @@ -86,8 +107,7 @@ set_common_environment () { case "$uname_s" in Linux) PROVISIONING_OS=linux - . /etc/os-release - PROVISIONING_OS_ID="$ID" + _detect_linux_OS_ID case "$PROVISIONING_OS_ID" in suse|sles|opensuse*) CMD_PKG_INSTALL="sudo zypper -nq install" |