chore: fix RUNNER_ROOT_DIR detection on MacOS
This commit is contained in:
parent
bfe2b67fbe
commit
e8073f9e7d
7
bin/emqx
7
bin/emqx
|
@ -13,10 +13,17 @@ DEBUG="${DEBUG:-0}"
|
||||||
# so we can't use it universally.
|
# so we can't use it universally.
|
||||||
# - `stat -f%R` on MacOS does exactly what `readlink -f` does on Linux, but we can't use it
|
# - `stat -f%R` on MacOS does exactly what `readlink -f` does on Linux, but we can't use it
|
||||||
# as a universal solution either because GNU stat has different syntax and this argument is invalid.
|
# as a universal solution either because GNU stat has different syntax and this argument is invalid.
|
||||||
|
# Also, version of stat which supports this syntax is only available since MacOS 12
|
||||||
if [ "$(uname -s)" == 'Darwin' ]; then
|
if [ "$(uname -s)" == 'Darwin' ]; then
|
||||||
|
product_version="$(sw_vers -productVersion | cut -d '.' -f 1)"
|
||||||
|
if [ "$product_version" -ge 12 ]; then
|
||||||
# if homebrew coreutils package is installed, GNU version of stat can take precedence,
|
# if homebrew coreutils package is installed, GNU version of stat can take precedence,
|
||||||
# so we use absolute path to ensure we are calling MacOS default
|
# so we use absolute path to ensure we are calling MacOS default
|
||||||
RUNNER_ROOT_DIR="$(cd "$(dirname "$(/usr/bin/stat -f%R "$0" || echo "$0")")"/..; pwd -P)"
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(/usr/bin/stat -f%R "$0" || echo "$0")")"/..; pwd -P)"
|
||||||
|
else
|
||||||
|
# try our best to resolve link on MacOS <= 11
|
||||||
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
RUNNER_ROOT_DIR="$(cd "$(dirname "$(realpath "$0" || echo "$0")")"/..; pwd -P)"
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(realpath "$0" || echo "$0")")"/..; pwd -P)"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue