From ebcc4bf8d3bea1aa530c517248f292f67eac5e05 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 27 Jul 2015 19:12:43 -0700 Subject: [PATCH] Fix deps scripts, add a working osx support --- buildscripts/checkdeps.sh | 137 ++++++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 36 deletions(-) diff --git a/buildscripts/checkdeps.sh b/buildscripts/checkdeps.sh index 1af47ff4..6c98f3b5 100755 --- a/buildscripts/checkdeps.sh +++ b/buildscripts/checkdeps.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Minio Client (C) 2015 Minio, Inc. +# Minio Client, (C) 2015 Minio, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,9 +16,13 @@ # _init() { + + shopt -s extglob + ## Minimum required versions for build dependencies GCC_VERSION="4.0" CLANG_VERSION="3.5" + YASM_VERSION="1.2.0" GIT_VERSION="1.0" GO_VERSION="1.4" OSX_VERSION="10.8" @@ -28,6 +32,27 @@ _init() { 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 @@ -43,7 +68,7 @@ _init() { # 3 - If args have length zero # #### -check_version () { +check_version() { ## validate args [[ -z "$1" ]] && return 3 [[ -z "$2" ]] && return 3 @@ -68,7 +93,7 @@ check_version () { return 1 fi 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 fi done @@ -78,18 +103,38 @@ check_version () { check_golang_env() { echo ${GOROOT:?} 2>&1 >/dev/null if [ $? -eq 1 ]; then - echo "ERROR" - echo "GOROOT environment variable missing, please refer to Go installation document" - echo "https://github.com/minio/minio/blob/master/BUILDDEPS.md#install-go-13" - exit 1 + echo "ERROR" + echo "GOROOT environment variable missing, please refer to Go installation document" + echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13" + exit 1 fi echo ${GOPATH:?} 2>&1 >/dev/null if [ $? -eq 1 ]; then - echo "ERROR" - echo "GOPATH environment variable missing, please refer to Go installation document" - echo "https://github.com/minio/minio/blob/master/BUILDDEPS.md#install-go-13" - exit 1 + echo "ERROR" + echo "GOPATH environment variable missing, please refer to Go installation document" + echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13" + exit 1 + fi + + local go_binary_path=$(which go) + + if [ -z "${go_binary_path}" ] ; then + echo "Cannot find go binary in your PATH configuration, please refer to Go installation document" + echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13" + exit -1 + fi + + local new_go_binary_path=${go_binary_path} + if [ -h "${go_binary_path}" ]; then + new_go_binary_path=$(readlink ${go_binary_path}) + fi + + if [[ !"$(dirname ${new_go_binary_path})" =~ *"${GOROOT%%*(/)}"* ]] ; then + echo "The go binary found in your PATH configuration does not belong to the Go installation pointed by your GOROOT environment," \ + "please refer to Go installation document" + echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13" + exit -1 fi } @@ -98,24 +143,21 @@ is_supported_os() { "Linux") os="linux" ;; - "Darwin") - osx_host_version=$(env sw_vers -productVersion) - check_version "${osx_host_version}" "${OSX_VERSION}" - [[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}" - ;; - "FreeBSD") - os="freebsd" - ;; - "*") - echo "Exiting.. unsupported operating system found" - exit 1; + "Darwin") + osx_host_version=$(env sw_vers -productVersion) + check_version "${osx_host_version}" "${OSX_VERSION}" + [[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}" + ;; + "*") + echo "Exiting.. unsupported operating system found" + exit 1; esac } is_supported_arch() { local supported case ${UNAME##* } in - "x86_64" | "amd64") + "x86_64") supported=1 ;; *) @@ -124,15 +166,38 @@ is_supported_arch() { esac if [ $supported -eq 0 ]; then echo "Invalid arch: ${UNAME} not supported, please use x86_64/amd64" - exit 1; + exit 1; fi } check_deps() { check_version "$(env go version 2>/dev/null | sed 's/^.* go\([0-9.]*\).*$/\1/')" "${GO_VERSION}" if [ $? -ge 2 ]; then - MISSING="${MISSING} golang(1.4)" + MISSING="${MISSING} golang(1.4)" fi + + 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 + MISSING="${MISSING} git" + fi + + case ${UNAME%% *} in + "Linux") + check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${GCC_VERSION}" + if [ $? -ge 2 ]; then + MISSING="${MISSING} build-essential" + 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 + } main() { @@ -153,17 +218,17 @@ main() { ## If dependencies are missing, warn the user and abort if [ "x${MISSING}" != "x" ]; then - echo "ERROR" - echo - echo "The following build tools are missing:" - echo - echo "** ${MISSING} **" - echo - echo "Please install them " - echo "${MISSING}" - echo - echo "Follow https://github.com/minio/minio/blob/master/BUILDDEPS.md for further instructions" - exit 1 + echo "ERROR" + echo + echo "The following build tools are missing:" + echo + echo "** ${MISSING} **" + echo + echo "Please install them " + echo "${MISSING}" + echo + echo "Follow https://github.com/minio/mc/blob/master/INSTALLGO.md for further instructions" + exit 1 fi echo "Done" }