Fix dependency checking on osx

This commit is contained in:
Harshavardhana 2015-07-27 18:09:23 -07:00
parent 7133513600
commit c503bf412f

View File

@ -32,6 +32,27 @@ _init() {
MISSING="" MISSING=""
} }
readlink() {
TARGET_FILE=$1
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=$(env readlink $TARGET_FILE)
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
RESULT=$PHYS_DIR/$TARGET_FILE
echo $RESULT
}
### ###
# #
# Takes two arguments # Takes two arguments
@ -47,7 +68,7 @@ _init() {
# 3 - If args have length zero # 3 - If args have length zero
# #
#### ####
check_version () { check_version() {
## validate args ## validate args
[[ -z "$1" ]] && return 3 [[ -z "$1" ]] && return 3
[[ -z "$2" ]] && return 3 [[ -z "$2" ]] && return 3
@ -72,7 +93,7 @@ check_version () {
return 1 return 1
fi fi
if ((10#${ver1[i]} < 10#${ver2[i]})); then if ((10#${ver1[i]} < 10#${ver2[i]})); then
## Installed version is lesser than required - Bad condition ## Installed version is lesser than required - Bad condition
return 2 return 2
fi fi
done done
@ -82,18 +103,18 @@ check_version () {
check_golang_env() { check_golang_env() {
echo ${GOROOT:?} 2>&1 >/dev/null echo ${GOROOT:?} 2>&1 >/dev/null
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
echo "ERROR" echo "ERROR"
echo "GOROOT environment variable missing, please refer to Go installation document" echo "GOROOT environment variable missing, please refer to Go installation document"
echo "https://github.com/minio/minio/blob/master/INSTALLGO.md#install-go-13" echo "https://github.com/minio/minio/blob/master/INSTALLGO.md#install-go-13"
exit 1 exit 1
fi fi
echo ${GOPATH:?} 2>&1 >/dev/null echo ${GOPATH:?} 2>&1 >/dev/null
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
echo "ERROR" echo "ERROR"
echo "GOPATH environment variable missing, please refer to Go installation document" echo "GOPATH environment variable missing, please refer to Go installation document"
echo "https://github.com/minio/minio/blob/master/INSTALLGO.md#install-go-13" echo "https://github.com/minio/minio/blob/master/INSTALLGO.md#install-go-13"
exit 1 exit 1
fi fi
local go_binary_path=$(which go) local go_binary_path=$(which go)
@ -106,7 +127,7 @@ check_golang_env() {
local new_go_binary_path=${go_binary_path} local new_go_binary_path=${go_binary_path}
if [ -h "${go_binary_path}" ]; then if [ -h "${go_binary_path}" ]; then
new_go_binary_path=$(/bin/readlink -f ${go_binary_path}) new_go_binary_path=$(readlink ${go_binary_path})
fi fi
if [[ !"$(dirname ${new_go_binary_path})" =~ *"${GOROOT%%*(/)}"* ]] ; then if [[ !"$(dirname ${new_go_binary_path})" =~ *"${GOROOT%%*(/)}"* ]] ; then
@ -122,14 +143,14 @@ is_supported_os() {
"Linux") "Linux")
os="linux" os="linux"
;; ;;
"Darwin") "Darwin")
osx_host_version=$(env sw_vers -productVersion) osx_host_version=$(env sw_vers -productVersion)
check_version "${osx_host_version}" "${OSX_VERSION}" check_version "${osx_host_version}" "${OSX_VERSION}"
[[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}" [[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}"
;; ;;
"*") "*")
echo "Exiting.. unsupported operating system found" echo "Exiting.. unsupported operating system found"
exit 1; exit 1;
esac esac
} }
@ -145,41 +166,41 @@ is_supported_arch() {
esac esac
if [ $supported -eq 0 ]; then if [ $supported -eq 0 ]; then
echo "Invalid arch: ${UNAME} not supported, please use x86_64/amd64" echo "Invalid arch: ${UNAME} not supported, please use x86_64/amd64"
exit 1; exit 1;
fi fi
} }
check_deps() { check_deps() {
check_version "$(env go version 2>/dev/null | sed 's/^.* go\([0-9.]*\).*$/\1/')" "${GO_VERSION}" check_version "$(env go version 2>/dev/null | sed 's/^.* go\([0-9.]*\).*$/\1/')" "${GO_VERSION}"
if [ $? -ge 2 ]; then if [ $? -ge 2 ]; then
MISSING="${MISSING} golang(1.4)" MISSING="${MISSING} golang(1.4)"
fi fi
check_version "$(env git --version 2>/dev/null | sed -e 's/^.* \([0-9.\].*\).*$/\1/' -e 's/^\([0-9.\]*\).*/\1/g')" "${GIT_VERSION}" check_version "$(env git --version 2>/dev/null | sed -e 's/^.* \([0-9.\].*\).*$/\1/' -e 's/^\([0-9.\]*\).*/\1/g')" "${GIT_VERSION}"
if [ $? -ge 2 ]; then if [ $? -ge 2 ]; then
MISSING="${MISSING} git" MISSING="${MISSING} git"
fi fi
case ${UNAME%% *} in case ${UNAME%% *} in
"Linux") "Linux")
check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${GCC_VERSION}" check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${GCC_VERSION}"
if [ $? -ge 2 ]; then if [ $? -ge 2 ]; then
MISSING="${MISSING} build-essential" MISSING="${MISSING} build-essential"
fi fi
;;
"Darwin")
check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${CLANG_VERSION}"
if [ $? -ge 2 ]; then
MISSING="${MISSING} xcode-cli"
fi
;;
"*")
;; ;;
"Darwin")
check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${CLANG_VERSION}"
if [ $? -ge 2 ]; then
MISSING="${MISSING} xcode-cli"
fi
;;
"*")
;;
esac esac
check_version "$(env yasm --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${YASM_VERSION}" check_version "$(env yasm --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${YASM_VERSION}"
if [ $? -ge 2 ]; then if [ $? -ge 2 ]; then
MISSING="${MISSING} yasm(1.2.0)" MISSING="${MISSING} yasm(1.2.0)"
fi fi
} }
@ -202,17 +223,17 @@ main() {
## If dependencies are missing, warn the user and abort ## If dependencies are missing, warn the user and abort
if [ "x${MISSING}" != "x" ]; then if [ "x${MISSING}" != "x" ]; then
echo "ERROR" echo "ERROR"
echo echo
echo "The following build tools are missing:" echo "The following build tools are missing:"
echo echo
echo "** ${MISSING} **" echo "** ${MISSING} **"
echo echo
echo "Please install them " echo "Please install them "
echo "${MISSING}" echo "${MISSING}"
echo echo
echo "Follow https://github.com/minio/minio/blob/master/INSTALLGO.md for further instructions" echo "Follow https://github.com/minio/minio/blob/master/INSTALLGO.md for further instructions"
exit 1 exit 1
fi fi
echo "Done" echo "Done"
} }