From b3be9f6e0863e6a3fc5611b611b039372665f3e5 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Fri, 14 Jul 2017 16:32:16 -0400 Subject: [PATCH 01/15] Remove sudo from autoprivision script --- system-dependencies.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/system-dependencies.sh b/system-dependencies.sh index 099c477b608..3f987e51922 100755 --- a/system-dependencies.sh +++ b/system-dependencies.sh @@ -159,7 +159,7 @@ function install_mono () { curl -L $MONO_URL > $MONO_PKG log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." - sudo installer -pkg $MONO_PKG -target / + installer -pkg $MONO_PKG -target / rm -f $MONO_PKG } @@ -184,9 +184,9 @@ function install_visual_studio () { log "Mounting $VS_DMG into $VS_MOUNTPOINT..." hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse log "Removing previous Visual Studio from $VS" - sudo rm -Rf "$VS" + rm -Rf "$VS" log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." - sudo cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications + cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications log "Unmounting $VS_DMG..." hdiutil detach $VS_MOUNTPOINT -quiet @@ -247,11 +247,11 @@ function install_specific_xcode () { rm -f $XCODE_DMG log "Removing any com.apple.quarantine attributes from the installed Xcode" - sudo xattr -d -r com.apple.quarantine $XCODE_ROOT + xattr -d -r com.apple.quarantine $XCODE_ROOT if is_at_least_version $XCODE_VERSION 5.0; then log "Accepting Xcode license" - sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept fi if is_at_least_version $XCODE_VERSION 8.0; then @@ -259,7 +259,7 @@ function install_specific_xcode () { for pkg in $PKGS; do if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then log "Installing $pkg" - sudo /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / + /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / log "Installed $pkg" else log "Not installing $pkg because it doesn't exist." @@ -267,8 +267,8 @@ function install_specific_xcode () { done fi - log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" - sudo xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" + xcode-select -s $XCODE_DEVELOPER_ROOT ok "Xcode $XCODE_VERSION provisioned" } @@ -295,9 +295,9 @@ function check_specific_xcode () { if is_at_least_version $XCODE_VERSION 5.0; then if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then if ! test -z $PROVISION_XCODE; then - sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept else - fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute 'sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." + fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." fi return fi @@ -314,10 +314,10 @@ function check_specific_xcode () { local XCODE_SELECT=$(xcode-select -p) if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then if ! test -z $PROVISION_XCODE; then - log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" - sudo xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" + xcode-select -s $XCODE_DEVELOPER_ROOT else - fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." + fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." fi fi From 3c80fb99f1a4e56c82d399188207a9ceecd8d10e Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Fri, 14 Jul 2017 16:49:29 -0400 Subject: [PATCH 02/15] Add product sign script --- product-sign.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 product-sign.sh diff --git a/product-sign.sh b/product-sign.sh new file mode 100644 index 00000000000..bf58058d491 --- /dev/null +++ b/product-sign.sh @@ -0,0 +1,58 @@ +#!/bin/bash -ex +# +# productsign.sh: run productsign against any installer .pkg +# files in the package output directory for the lane, signing +# with the Xamarin Developer Installer identity and verifying +# the signature's fingerprint after the fact. +# +# Author: +# Aaron Bockover +# +# Copyright 2014 Xamarin, Inc. +# + +PRODUCTSIGN_KEYCHAIN="login.keychain" +PRODUCTSIGN_KEYCHAIN_PASSWORD="beefydude" +PRODUCTSIGN_IDENTITY="Developer ID Installer: Xamarin Inc" +PRODUCTSIGN_FINGERPRINT="3F:BE:54:B1:41:8B:F1:20:FA:B4:9D:A7:F2:5E:72:95:5A:49:21:D6" + +if [ -z "$BUILD_REVISION" ]; then + echo BUILD_REVISION is unset. Bailing. + exit 1 +fi + +mkdir -p "/tmp/$BUILD_REVISION" + +echo Before signing +ls -l package + +security -v find-identity +security unlock-keychain -p "$PRODUCTSIGN_KEYCHAIN_PASSWORD" "$PRODUCTSIGN_KEYCHAIN" + +for pkg in package/*.pkg; do + productsign -s "$PRODUCTSIGN_IDENTITY" "$pkg" "/tmp/$BUILD_REVISION/$(basename "$pkg")" +done + +echo Signing output +ls -l /tmp/$BUILD_REVISION + +mv /tmp/$BUILD_REVISION/* package + +echo After signing +ls -l package + +echo 'setns x=http://www.w3.org/2000/09/xmldsig#' > shell.xmllint +echo 'cat (//xar/toc/signature/x:KeyInfo/x:X509Data/x:X509Certificate)[1]/text()' >> shell.xmllint + +echo Signature Verification +for pkg in package/*.pkg; do + pkgutil --check-signature "$pkg" + xar -f "$pkg" --dump-toc="$pkg.toc" + ( + echo '-----BEGIN CERTIFICATE-----' && + xmllint --shell "$pkg.toc" < shell.xmllint | grep -Ev '^/' && + echo '-----END CERTIFICATE-----' + ) | openssl x509 -fingerprint | grep "$PRODUCTSIGN_FINGERPRINT" || exit 1 +done + +rm shell.xmllint \ No newline at end of file From b95eac5412fb3ed20d9ef6a0207537321ab655b9 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sat, 15 Jul 2017 12:55:42 -0400 Subject: [PATCH 03/15] Create file to trigger builds -_- --- build.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 00000000000..64685077969 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +make world From d63ca7cc785ad778cfaa0213a6f2bebf2c308007 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sat, 15 Jul 2017 13:44:51 -0400 Subject: [PATCH 04/15] Print out path to debug --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index 64685077969..f3c51fa1baf 100644 --- a/build.sh +++ b/build.sh @@ -1 +1,3 @@ +echo "PATH ======= $PATH" + make world From ab01370f856cb73514fa5b3634e845a0da1b9ac7 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sun, 16 Jul 2017 11:58:42 -0400 Subject: [PATCH 05/15] Use BUILD_SOURCEVERSION if BUILD_REVISION isn't set --- product-sign.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/product-sign.sh b/product-sign.sh index bf58058d491..71ec387dd35 100644 --- a/product-sign.sh +++ b/product-sign.sh @@ -17,7 +17,12 @@ PRODUCTSIGN_IDENTITY="Developer ID Installer: Xamarin Inc" PRODUCTSIGN_FINGERPRINT="3F:BE:54:B1:41:8B:F1:20:FA:B4:9D:A7:F2:5E:72:95:5A:49:21:D6" if [ -z "$BUILD_REVISION" ]; then - echo BUILD_REVISION is unset. Bailing. + echo BUILD_REVISION is unset. Using BUILD_SOURCEVERSION. + BUILD_REVISION=$BUILD_SOURCEVERSION +fi + +if [ -z "$BUILD_SOURCEVERSION" ]; then + echo BUILD_SOURCEVERSION is unset. Bailing. exit 1 fi From 25e147eb4e1296ec24ac11d6b97b9cd9b3aa87f7 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sun, 16 Jul 2017 16:26:02 -0400 Subject: [PATCH 06/15] Use arguments in script invoking make targets --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index f3c51fa1baf..0ea2f59f926 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ echo "PATH ======= $PATH" - -make world +mkdir ../package +make $1 From adeb581bedb13818c96656306ab0987748de4fb6 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sun, 16 Jul 2017 18:43:33 -0400 Subject: [PATCH 07/15] Add package step --- Makefile | 10 ++++++++++ build.sh | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f4b92406f72..468861bf3b1 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,16 @@ else endif endif +package: + mkdir ../package + $(MAKE) -C ../maccore package + # copy .pkg, .zip and *updateinfo to the packages directory to be uploaded to storage + cp ../maccore/release/*.pkg ../package + -cp ../maccore/release/*.zip ../package + -cp ../maccore/release/*updateinfo ../package + -cp ../maccore/tests/*.zip ../package + -cp ../xamarin-macios/tests/*.zip ../package + install-system: install-system-ios install-system-mac @# Clean up some old files $(Q) rm -Rf /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS diff --git a/build.sh b/build.sh index 0ea2f59f926..257b334ec21 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,2 @@ echo "PATH ======= $PATH" -mkdir ../package make $1 From e8f57f84003e5fba990248128b3365f6d920667c Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sun, 16 Jul 2017 22:33:56 -0400 Subject: [PATCH 08/15] Rename source directory in vsts builds --- build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sh b/build.sh index 257b334ec21..2665ca2e6b8 100644 --- a/build.sh +++ b/build.sh @@ -1,2 +1,5 @@ echo "PATH ======= $PATH" +if [ "$1" = "world" ]; then + cd .. && mv s xamarin-macios && cd xamarin-macios +fi make $1 From 31a64bf947b9c95226142b26b0e79b5618c05f37 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Sun, 16 Jul 2017 23:57:05 -0400 Subject: [PATCH 09/15] Tribulations of a hack --- build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 2665ca2e6b8..b5c51afe0ec 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,9 @@ echo "PATH ======= $PATH" if [ "$1" = "world" ]; then cd .. && mv s xamarin-macios && cd xamarin-macios + make world + cd .. && mv xamarin-macios s && cd s +else + make $1 fi -make $1 + From fc6e6fbf2f33d811af829b0843444d6cbec7d03e Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Mon, 17 Jul 2017 01:46:24 -0400 Subject: [PATCH 10/15] Suppress errors in package target --- Makefile | 2 +- build.sh | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 468861bf3b1..acd346305d7 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,7 @@ endif endif package: - mkdir ../package + mkdir -p ../package $(MAKE) -C ../maccore package # copy .pkg, .zip and *updateinfo to the packages directory to be uploaded to storage cp ../maccore/release/*.pkg ../package diff --git a/build.sh b/build.sh index b5c51afe0ec..6efaea0c117 100644 --- a/build.sh +++ b/build.sh @@ -1,9 +1,6 @@ echo "PATH ======= $PATH" -if [ "$1" = "world" ]; then - cd .. && mv s xamarin-macios && cd xamarin-macios - make world - cd .. && mv xamarin-macios s && cd s -else - make $1 -fi + +cd .. && mv s xamarin-macios && cd xamarin-macios +make $1 +cd .. && mv xamarin-macios s && cd s From 3491d2161fb238cc45f486e0369c8f5caf8ec284 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Mon, 17 Jul 2017 11:34:49 -0400 Subject: [PATCH 11/15] Use correct package path --- product-sign.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/product-sign.sh b/product-sign.sh index 71ec387dd35..550b58b8937 100644 --- a/product-sign.sh +++ b/product-sign.sh @@ -29,28 +29,28 @@ fi mkdir -p "/tmp/$BUILD_REVISION" echo Before signing -ls -l package +ls -l ../package security -v find-identity security unlock-keychain -p "$PRODUCTSIGN_KEYCHAIN_PASSWORD" "$PRODUCTSIGN_KEYCHAIN" -for pkg in package/*.pkg; do +for pkg in ../package/*.pkg; do productsign -s "$PRODUCTSIGN_IDENTITY" "$pkg" "/tmp/$BUILD_REVISION/$(basename "$pkg")" done echo Signing output ls -l /tmp/$BUILD_REVISION -mv /tmp/$BUILD_REVISION/* package +mv /tmp/$BUILD_REVISION/* ../package echo After signing -ls -l package +ls -l ../package echo 'setns x=http://www.w3.org/2000/09/xmldsig#' > shell.xmllint echo 'cat (//xar/toc/signature/x:KeyInfo/x:X509Data/x:X509Certificate)[1]/text()' >> shell.xmllint echo Signature Verification -for pkg in package/*.pkg; do +for pkg in ../package/*.pkg; do pkgutil --check-signature "$pkg" xar -f "$pkg" --dump-toc="$pkg.toc" ( From 394df20fef262698fd0d38d9c282dc575809f278 Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Mon, 24 Jul 2017 14:26:10 -0400 Subject: [PATCH 12/15] Add non-sudo dependencies file --- system-dependencies-no-sudo.sh | 598 +++++++++++++++++++++++++++++++++ system-dependencies.sh | 26 +- 2 files changed, 611 insertions(+), 13 deletions(-) create mode 100755 system-dependencies-no-sudo.sh diff --git a/system-dependencies-no-sudo.sh b/system-dependencies-no-sudo.sh new file mode 100755 index 00000000000..3f987e51922 --- /dev/null +++ b/system-dependencies-no-sudo.sh @@ -0,0 +1,598 @@ +#!/bin/bash -e + +set -o pipefail + +FAIL= +PROVISION_DOWNLOAD_DIR=/tmp/x-provisioning + +# parse command-line arguments +while ! test -z $1; do + case $1 in + --provision-xcode) + PROVISION_XCODE=1 + shift + ;; + --provision) + # historical reasons :( + PROVISION_XCODE=1 + PROVISION_VS=1 + shift + ;; + --provision-*-studio) + PROVISION_VS=1 + shift + ;; + --provision-mono) + PROVISION_MONO=1 + shift + ;; + --provision-cmake) + PROVISION_CMAKE=1 + shift + ;; + --provision-autotools) + PROVISION_AUTOTOOLS=1 + shift + ;; + --provision-all) + PROVISION_MONO=1 + PROVISION_VS=1 + PROVISION_XCODE=1 + PROVISION_CMAKE=1 + PROVISION_AUTOTOOLS=1 + PROVISION_HOMEBREW=1 + shift + ;; + --ignore-osx) + IGNORE_OSX=1 + shift + ;; + --ignore-xcode) + IGNORE_XCODE=1 + shift + ;; + --ignore-*-studio) + IGNORE_VISUAL_STUDIO=1 + shift + ;; + --ignore-mono) + IGNORE_MONO=1 + shift + ;; + --ignore-autotools) + IGNORE_AUTOTOOLS=1 + shift + ;; + --ignore-cmake) + IGNORE_CMAKE=1 + shift + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac +done + +# reporting functions +function fail () { + tput setaf 1 2>/dev/null || true + echo " $1" + tput sgr0 2>/dev/null || true + FAIL=1 +} + +function warn () { + tput setaf 3 2>/dev/null || true + echo " $1" + tput sgr0 2>/dev/null || true +} + +function ok () { + echo " $1" +} + +function log () { + echo " $1" +} + +# $1: the version to check +# $2: the minimum version to check against +function is_at_least_version () { + ACT_V=$1 + MIN_V=$2 + + if [[ "$ACT_V" == "$MIN_V" ]]; then + return 0 + fi + + IFS=. read -a V_ACT <<< "$ACT_V" + IFS=. read -a V_MIN <<< "$MIN_V" + + # get the minimum # of elements + AC=${#V_ACT[@]} + MC=${#V_MIN[@]} + COUNT=$(($AC>$MC?$MC:$AC)) + + C=0 + while (( $C < $COUNT )); do + ACT=${V_ACT[$C]} + MIN=${V_MIN[$C]} + if (( $ACT > $MIN )); then + return 0 + elif (( "$MIN" > "$ACT" )); then + return 1 + fi + let C++ + done + + if (( $AC == $MC )); then + # identical? + return 0 + fi + + if (( $AC > $MC )); then + # more version fields in actual than min: OK + return 0 + elif (( $AC == $MC )); then + # entire strings aren't equal (first check in function), but each individual field is? + return 0 + else + # more version fields in min than actual (1.0 vs 1.0.1 for instance): not OK + return 1 + fi +} + +function install_mono () { + local MONO_URL=`grep MIN_MONO_URL= Make.config | sed 's/.*=//'` + local MIN_MONO_VERSION=`grep MIN_MONO_VERSION= Make.config | sed 's/.*=//'` + + if test -z $MONO_URL; then + fail "No MIN_MONO_URL set in Make.config, cannot provision" + return + fi + + mkdir -p $PROVISION_DOWNLOAD_DIR + log "Downloading Mono $MIN_MONO_VERSION from $MONO_URL to $PROVISION_DOWNLOAD_DIR..." + local MONO_NAME=`basename $MONO_URL` + local MONO_PKG=$PROVISION_DOWNLOAD_DIR/$MONO_NAME + curl -L $MONO_URL > $MONO_PKG + + log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." + installer -pkg $MONO_PKG -target / + + rm -f $MONO_PKG +} + +function install_visual_studio () { + local VS="/Applications/Visual Studio.app" + local VS_URL=`grep MIN_VISUAL_STUDIO_URL= Make.config | sed 's/.*=//'` + local MIN_VISUAL_STUDIO_VERSION=`grep MIN_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` + + if test -z $VS_URL; then + fail "No MIN_VISUAL_STUDIO_URL set in Make.config, cannot provision" + return + fi + + mkdir -p $PROVISION_DOWNLOAD_DIR + log "Downloading Visual Studio $MIN_VISUAL_STUDIO_VERSION from $VS_URL to $PROVISION_DOWNLOAD_DIR..." + local VS_NAME=`basename $VS_URL` + local VS_DMG=$PROVISION_DOWNLOAD_DIR/$VS_NAME + curl -L $VS_URL > $VS_DMG + + local VS_MOUNTPOINT=$PROVISION_DOWNLOAD_DIR/$VS_NAME-mount + log "Mounting $VS_DMG into $VS_MOUNTPOINT..." + hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse + log "Removing previous Visual Studio from $VS" + rm -Rf "$VS" + log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." + cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications + log "Unmounting $VS_DMG..." + hdiutil detach $VS_MOUNTPOINT -quiet + + VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` + ok "Visual Studio $VS_ACTUAL_VERSION provisioned" + + rm -f $VS_DMG +} + +function install_specific_xcode () { + local XCODE_URL=`grep XCODE$1_URL= Make.config | sed 's/.*=//'` + local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'` + local XCODE_ROOT=$(dirname `dirname $XCODE_DEVELOPER_ROOT`) + + if test -z $XCODE_URL; then + fail "No XCODE$1_URL set in Make.config, cannot provision" + return + fi + + mkdir -p $PROVISION_DOWNLOAD_DIR + log "Downloading Xcode $XCODE_VERSION from $XCODE_URL to $PROVISION_DOWNLOAD_DIR..." + local XCODE_NAME=`basename $XCODE_URL` + local XCODE_DMG=$PROVISION_DOWNLOAD_DIR/$XCODE_NAME + + # To test this script with new Xcode versions, copy the downloaded file to $XCODE_DMG, + # uncomment the following curl line, and run ./system-dependencies.sh --provision-xcode + if test -f "~/Downloads/$XCODE_NAME"; then + log "Found XCode $XCODE_VERSION in your ~/Downloads folder, copying that version instead." + cp "~/Downloads/$XCODE_NAME" "$XCODE_DMG" + else + curl -L $XCODE_URL > $XCODE_DMG + fi + + if [[ ${XCODE_DMG: -4} == ".dmg" ]]; then + local XCODE_MOUNTPOINT=$PROVISION_DOWNLOAD_DIR/$XCODE_NAME-mount + log "Mounting $XCODE_DMG into $XCODE_MOUNTPOINT..." + hdiutil attach $XCODE_DMG -mountpoint $XCODE_MOUNTPOINT -quiet -nobrowse + log "Removing previous Xcode from $XCODE_ROOT" + rm -Rf $XCODE_ROOT + log "Installing Xcode $XCODE_VERSION to $XCODE_ROOT..." + cp -R $XCODE_MOUNTPOINT/*.app $XCODE_ROOT + log "Unmounting $XCODE_DMG..." + hdiutil detach $XCODE_MOUNTPOINT -quiet + elif [[ ${XCODE_DMG: -4} == ".xip" ]]; then + log "Extracting $XCODE_DMG..." + pushd . > /dev/null + cd $PROVISION_DOWNLOAD_DIR + # make sure there's nothing interfering + rm -Rf *.app + # extract + /System/Library/CoreServices/Applications/Archive\ Utility.app/Contents/MacOS/Archive\ Utility "$XCODE_DMG" + log "Installing Xcode $XCODE_VERSION to $XCODE_ROOT..." + mv *.app $XCODE_ROOT + popd > /dev/null + else + fail "Don't know how to install $XCODE_DMG" + fi + rm -f $XCODE_DMG + + log "Removing any com.apple.quarantine attributes from the installed Xcode" + xattr -d -r com.apple.quarantine $XCODE_ROOT + + if is_at_least_version $XCODE_VERSION 5.0; then + log "Accepting Xcode license" + $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + fi + + if is_at_least_version $XCODE_VERSION 8.0; then + PKGS="MobileDevice.pkg MobileDeviceDevelopment.pkg XcodeSystemResources.pkg" + for pkg in $PKGS; do + if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then + log "Installing $pkg" + /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / + log "Installed $pkg" + else + log "Not installing $pkg because it doesn't exist." + fi + done + fi + + log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" + xcode-select -s $XCODE_DEVELOPER_ROOT + + ok "Xcode $XCODE_VERSION provisioned" +} + +function check_specific_xcode () { + local XCODE_DEVELOPER_ROOT=`grep XCODE$1_DEVELOPER_ROOT= Make.config | sed 's/.*=//'` + local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'` + local XCODE_ROOT=$(dirname `dirname $XCODE_DEVELOPER_ROOT`) + local ENABLE_XAMARIN=$(grep -s ^ENABLE_XAMARIN= Make.config.local configure.inc | sed 's/.*=//') + + if ! test -d $XCODE_DEVELOPER_ROOT; then + if ! test -z $PROVISION_XCODE; then + if ! test -z $ENABLE_XAMARIN; then + install_specific_xcode $1 + else + fail "Automatic provisioning of Xcode is only supported for provisioning internal build bots." + fail "Please download and install Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode" + fi + else + fail "You must install Xcode ($XCODE_VERSION) in $XCODE_ROOT. You can download Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode" + fi + return + else + if is_at_least_version $XCODE_VERSION 5.0; then + if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then + if ! test -z $PROVISION_XCODE; then + $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + else + fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." + fi + return + fi + fi + fi + + local XCODE_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$XCODE_DEVELOPER_ROOT/../version.plist"` + # this is a hard match, having 4.5 when requesting 4.4 is not OK (but 4.4.1 is OK) + if [[ ! "x$XCODE_ACTUAL_VERSION" =~ "x$XCODE_VERSION" ]]; then + fail "You must install Xcode $XCODE_VERSION in $XCODE_ROOT (found $XCODE_ACTUAL_VERSION). You can download Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode"; + return + fi + + local XCODE_SELECT=$(xcode-select -p) + if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then + if ! test -z $PROVISION_XCODE; then + log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" + xcode-select -s $XCODE_DEVELOPER_ROOT + else + fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." + fi + fi + + ok "Found Xcode $XCODE_ACTUAL_VERSION in $XCODE_ROOT" +} + +function check_xcode () { + if ! test -z $IGNORE_XCODE; then return; fi + + # must have latest Xcode in /Applications/Xcode.app + check_specific_xcode + + local XCODE_DEVELOPER_ROOT=`grep ^XCODE_DEVELOPER_ROOT= Make.config | sed 's/.*=//'` + local IOS_SDK_VERSION=`grep ^IOS_SDK_VERSION= Make.config | sed 's/.*=//'` + local OSX_SDK_VERSION=`grep ^OSX_SDK_VERSION= Make.config | sed 's/.*=//'` + local WATCH_SDK_VERSION=`grep ^WATCH_SDK_VERSION= Make.config | sed 's/.*=//'` + local TVOS_SDK_VERSION=`grep ^TVOS_SDK_VERSION= Make.config | sed 's/.*=//'` + + local D=$XCODE_DEVELOPER_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk + if test ! -d $D -a -z "$FAIL"; then + fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update IOS_SDK_VERSION in Make.config." + fi + + local D=$XCODE_DEVELOPER_ROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk + if test ! -d $D -a -z "$FAIL"; then + fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update OSX_SDK_VERSION in Make.config." + fi + + local D=$XCODE_DEVELOPER_ROOT/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS${TVOS_SDK_VERSION}.sdk + if test ! -d $D -a -z "$FAIL"; then + fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update TVOS_SDK_VERSION in Make.config." + fi + + local D=$XCODE_DEVELOPER_ROOT/Platforms/WatchOS.platform/Developer/SDKs/WatchOS${WATCH_SDK_VERSION}.sdk + if test ! -d $D -a -z "$FAIL"; then + fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update WATCH_SDK_VERSION in Make.config." + fi +} + +function check_mono () { + if ! test -z $IGNORE_MONO; then return; fi + + PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/pkg-config + if ! /Library/Frameworks/Mono.framework/Commands/mono --version 2>/dev/null >/dev/null; then + if ! test -z $PROVISION_MONO; then + install_mono + else + fail "You must install the Mono MDK (http://www.mono-project.com/download/)" + return + fi + elif ! test -e $PKG_CONFIG_PATH; then + if ! test -z $PROVISION_MONO; then + install_mono + else + fail "Could not find pkg-config, you must install the Mono MDK (http://www.mono-project.com/download/)" + return + fi + fi + + MIN_MONO_VERSION=`grep MIN_MONO_VERSION= Make.config | sed 's/.*=//'` + MAX_MONO_VERSION=`grep MAX_MONO_VERSION= Make.config | sed 's/.*=//'` + + ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono`.`cat /Library/Frameworks/Mono.framework/Home/updateinfo | cut -d' ' -f2 | cut -c6- | awk '{print(int($0))}'` + if ! is_at_least_version $ACTUAL_MONO_VERSION $MIN_MONO_VERSION; then + if ! test -z $PROVISION_MONO; then + install_mono + ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono` + else + fail "You must have at least Mono $MIN_MONO_VERSION, found $ACTUAL_MONO_VERSION" + return + fi + elif [[ "$ACTUAL_MONO_VERSION" == "$MAX_MONO_VERSION" ]]; then + : # this is ok + elif is_at_least_version $ACTUAL_MONO_VERSION $MAX_MONO_VERSION; then + if ! test -z $PROVISION_MONO; then + install_mono + ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono`.`cat /Library/Frameworks/Mono.framework/Home/updateinfo | cut -d' ' -f2 | cut -c6- | awk '{print(int($0))}'` + else + fail "Your mono version is too new, max version is $MAX_MONO_VERSION, found $ACTUAL_MONO_VERSION." + fail "You may edit Make.config and change MAX_MONO_VERSION to your actual version to continue the" + fail "build (unless you're on a release branch). Once the build completes successfully, please" + fail "commit the new MAX_MONO_VERSION value." + return + fi + fi + + ok "Found Mono $ACTUAL_MONO_VERSION (at least $MIN_MONO_VERSION and not more than $MAX_MONO_VERSION is required)" +} + +function install_autoconf () { + if ! brew --version >& /dev/null; then + fail "Asked to install autoconf, but brew is not installed." + return + fi + + brew install autoconf +} + +function install_libtool () { + if ! brew --version >& /dev/null; then + fail "Asked to install libtool, but brew is not installed." + return + fi + + brew install libtool +} + +function install_automake () { + if ! brew --version >& /dev/null; then + fail "Asked to install automake, but brew is not installed." + return + fi + + brew install automake +} + + +function check_autotools () { + if ! test -z $IGNORE_AUTOTOOLS; then return; fi + +IFStmp=$IFS +IFS=' +' + if AUTOCONF_VERSION=($(autoconf --version 2>/dev/null)); then + ok "Found ${AUTOCONF_VERSION[0]} (no specific version is required)" + elif ! test -z $PROVISION_AUTOTOOLS; then + install_autoconf + else + fail "You must install autoconf, read the README.md for instructions" + fi + + if ! LIBTOOL=$(which glibtool 2>/dev/null); then + LIBTOOL=$(which libtool) + fi + + if LIBTOOL_VERSION=($($LIBTOOL --version 2>/dev/null )); then + ok "Found ${LIBTOOL_VERSION[0]} (no specific version is required)" + elif ! test -z $PROVISION_AUTOTOOLS; then + install_libtool + else + fail "You must install libtool, read the README.md for instructions" + fi + + if AUTOMAKE_VERSION=($(automake --version 2>/dev/null)); then + ok "Found ${AUTOMAKE_VERSION[0]} (no specific version is required)" + elif ! test -z $PROVISION_AUTOTOOLS; then + install_automake + else + fail "You must install automake, read the README.md for instructions" + fi +IFS=$IFS_tmp +} + +function check_visual_studio () { + if ! test -z $IGNORE_VISUAL_STUDIO; then return; fi + + VS="/Applications/Visual Studio.app" + local VS_URL=`grep MIN_VISUAL_STUDIO_URL= Make.config | sed 's/.*=//'` + if ! test -d "$VS"; then + if ! test -z $PROVISION_VS; then + install_visual_studio + else + fail "You must install Visual Studio, from http://www.monodevelop.com/download/" + fi + return + fi + + MIN_VISUAL_STUDIO_VERSION=`grep MIN_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` + MAX_VISUAL_STUDIO_VERSION=`grep MAX_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` + VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` + if ! is_at_least_version $VS_ACTUAL_VERSION $MIN_VISUAL_STUDIO_VERSION; then + if ! test -z $PROVISION_VS; then + install_visual_studio + VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` + else + fail "You must have at least Visual Studio $MIN_VISUAL_STUDIO_VERSION (found $VS_ACTUAL_VERSION). Download URL: $VS_URL" + fi + return + elif [[ "$VS_ACTUAL_VERSION" == "$MAX_VISUAL_STUDIO_VERSION" ]]; then + : # this is ok + elif is_at_least_version $VS_ACTUAL_VERSION $MAX_VISUAL_STUDIO_VERSION; then + if ! test -z $PROVISION_VS; then + install_visual_studio + VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` + else + fail "Your Visual Studio version is too new, max version is $MAX_VISUAL_STUDIO_VERSION, found $VS_ACTUAL_VERSION." + fail "You may edit Make.config and change MAX_VISUAL_STUDIO_VERSION to your actual version to continue the" + fail "build (unless you're on a release branch). Once the build completes successfully, please" + fail "commit the new MAX_VISUAL_STUDIO_VERSION value." + fail "Alternatively you can download an older version from $VS_URL." + fi + return + fi + + ok "Found Visual Studio $VS_ACTUAL_VERSION (at least $MIN_VISUAL_STUDIO_VERSION and not more than $MAX_VISUAL_STUDIO_VERSION is required)" +} + +function check_osx_version () { + if ! test -z $IGNORE_OSX; then return; fi + + MIN_OSX_BUILD_VERSION=`grep MIN_OSX_BUILD_VERSION= Make.config | sed 's/.*=//'` + + ACTUAL_OSX_VERSION=$(sw_vers -productVersion) + if ! is_at_least_version $ACTUAL_OSX_VERSION $MIN_OSX_BUILD_VERSION; then + fail "You must have at least OSX $MIN_OSX_BUILD_VERSION (found $ACTUAL_OSX_VERSION)" + return + fi + + ok "Found OSX $ACTUAL_OSX_VERSION (at least $MIN_OSX_BUILD_VERSION is required)" +} + +function install_cmake () { + if ! brew --version >& /dev/null; then + fail "Asked to install cmake, but brew is not installed." + return + fi + + brew install cmake +} + +function check_cmake () { + if ! test -z $IGNORE_CMAKE; then return; fi + + local MIN_CMAKE_VERSION=`grep MIN_CMAKE_VERSION= Make.config | sed 's/.*=//'` + local CMAKE_URL=`grep CMAKE_URL= Make.config | sed 's/.*=//'` + + if ! cmake --version &> /dev/null; then + if ! test -z $PROVISION_CMAKE; then + install_cmake + else + fail "You must install CMake ($CMAKE_URL)" + fi + return + fi + + ACTUAL_CMAKE_VERSION=$(cmake --version | grep "cmake version" | sed 's/cmake version //') + if ! is_at_least_version $ACTUAL_CMAKE_VERSION $MIN_CMAKE_VERSION; then + fail "You must have at least CMake $MIN_CMAKE_VERSION (found $ACTUAL_CMAKE_VERSION)" + return + fi + + ok "Found CMake $ACTUAL_CMAKE_VERSION (at least $MIN_CMAKE_VERSION is required)" +} + +function check_homebrew () +{ +IFStmp=$IFS +IFS=' +' + if HOMEBREW_VERSION=($(brew --version 2>/dev/null)); then + ok "Found Homebrew ($HOMEBREW_VERSION)" + elif ! test -z $PROVISION_HOMEBREW; then + log "Installing Homebrew..." + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + HOMEBREW_VERSION=($(brew --version 2>/dev/null)) + log "Installed Homebrew ($HOMEBREW_VERSION)" + else + warn "Could not find Homebrew. Homebrew is required to auto-provision some dependencies (autotools, cmake), but not required otherwise." + fi +IFS=$IFS_tmp +} + +echo "Checking system..." + +check_osx_version +check_xcode +check_homebrew +check_autotools +check_mono +check_visual_studio +check_cmake + +if test -z $FAIL; then + echo "System check succeeded" +else + echo "System check failed" + exit 1 +fi diff --git a/system-dependencies.sh b/system-dependencies.sh index 3f987e51922..099c477b608 100755 --- a/system-dependencies.sh +++ b/system-dependencies.sh @@ -159,7 +159,7 @@ function install_mono () { curl -L $MONO_URL > $MONO_PKG log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." - installer -pkg $MONO_PKG -target / + sudo installer -pkg $MONO_PKG -target / rm -f $MONO_PKG } @@ -184,9 +184,9 @@ function install_visual_studio () { log "Mounting $VS_DMG into $VS_MOUNTPOINT..." hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse log "Removing previous Visual Studio from $VS" - rm -Rf "$VS" + sudo rm -Rf "$VS" log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." - cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications + sudo cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications log "Unmounting $VS_DMG..." hdiutil detach $VS_MOUNTPOINT -quiet @@ -247,11 +247,11 @@ function install_specific_xcode () { rm -f $XCODE_DMG log "Removing any com.apple.quarantine attributes from the installed Xcode" - xattr -d -r com.apple.quarantine $XCODE_ROOT + sudo xattr -d -r com.apple.quarantine $XCODE_ROOT if is_at_least_version $XCODE_VERSION 5.0; then log "Accepting Xcode license" - $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept fi if is_at_least_version $XCODE_VERSION 8.0; then @@ -259,7 +259,7 @@ function install_specific_xcode () { for pkg in $PKGS; do if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then log "Installing $pkg" - /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / + sudo /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / log "Installed $pkg" else log "Not installing $pkg because it doesn't exist." @@ -267,8 +267,8 @@ function install_specific_xcode () { done fi - log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" - xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" + sudo xcode-select -s $XCODE_DEVELOPER_ROOT ok "Xcode $XCODE_VERSION provisioned" } @@ -295,9 +295,9 @@ function check_specific_xcode () { if is_at_least_version $XCODE_VERSION 5.0; then if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then if ! test -z $PROVISION_XCODE; then - $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept else - fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." + fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute 'sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." fi return fi @@ -314,10 +314,10 @@ function check_specific_xcode () { local XCODE_SELECT=$(xcode-select -p) if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then if ! test -z $PROVISION_XCODE; then - log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" - xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" + sudo xcode-select -s $XCODE_DEVELOPER_ROOT else - fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." + fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." fi fi From dba42ba96cad7374296cd0313a490e96f08f8ebc Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Mon, 24 Jul 2017 18:49:21 -0400 Subject: [PATCH 13/15] Use a variable switch to invoke commands with sudo --- system-dependencies-no-sudo.sh | 598 --------------------------------- system-dependencies.sh | 32 +- 2 files changed, 18 insertions(+), 612 deletions(-) delete mode 100755 system-dependencies-no-sudo.sh diff --git a/system-dependencies-no-sudo.sh b/system-dependencies-no-sudo.sh deleted file mode 100755 index 3f987e51922..00000000000 --- a/system-dependencies-no-sudo.sh +++ /dev/null @@ -1,598 +0,0 @@ -#!/bin/bash -e - -set -o pipefail - -FAIL= -PROVISION_DOWNLOAD_DIR=/tmp/x-provisioning - -# parse command-line arguments -while ! test -z $1; do - case $1 in - --provision-xcode) - PROVISION_XCODE=1 - shift - ;; - --provision) - # historical reasons :( - PROVISION_XCODE=1 - PROVISION_VS=1 - shift - ;; - --provision-*-studio) - PROVISION_VS=1 - shift - ;; - --provision-mono) - PROVISION_MONO=1 - shift - ;; - --provision-cmake) - PROVISION_CMAKE=1 - shift - ;; - --provision-autotools) - PROVISION_AUTOTOOLS=1 - shift - ;; - --provision-all) - PROVISION_MONO=1 - PROVISION_VS=1 - PROVISION_XCODE=1 - PROVISION_CMAKE=1 - PROVISION_AUTOTOOLS=1 - PROVISION_HOMEBREW=1 - shift - ;; - --ignore-osx) - IGNORE_OSX=1 - shift - ;; - --ignore-xcode) - IGNORE_XCODE=1 - shift - ;; - --ignore-*-studio) - IGNORE_VISUAL_STUDIO=1 - shift - ;; - --ignore-mono) - IGNORE_MONO=1 - shift - ;; - --ignore-autotools) - IGNORE_AUTOTOOLS=1 - shift - ;; - --ignore-cmake) - IGNORE_CMAKE=1 - shift - ;; - *) - echo "Unknown argument: $1" - exit 1 - ;; - esac -done - -# reporting functions -function fail () { - tput setaf 1 2>/dev/null || true - echo " $1" - tput sgr0 2>/dev/null || true - FAIL=1 -} - -function warn () { - tput setaf 3 2>/dev/null || true - echo " $1" - tput sgr0 2>/dev/null || true -} - -function ok () { - echo " $1" -} - -function log () { - echo " $1" -} - -# $1: the version to check -# $2: the minimum version to check against -function is_at_least_version () { - ACT_V=$1 - MIN_V=$2 - - if [[ "$ACT_V" == "$MIN_V" ]]; then - return 0 - fi - - IFS=. read -a V_ACT <<< "$ACT_V" - IFS=. read -a V_MIN <<< "$MIN_V" - - # get the minimum # of elements - AC=${#V_ACT[@]} - MC=${#V_MIN[@]} - COUNT=$(($AC>$MC?$MC:$AC)) - - C=0 - while (( $C < $COUNT )); do - ACT=${V_ACT[$C]} - MIN=${V_MIN[$C]} - if (( $ACT > $MIN )); then - return 0 - elif (( "$MIN" > "$ACT" )); then - return 1 - fi - let C++ - done - - if (( $AC == $MC )); then - # identical? - return 0 - fi - - if (( $AC > $MC )); then - # more version fields in actual than min: OK - return 0 - elif (( $AC == $MC )); then - # entire strings aren't equal (first check in function), but each individual field is? - return 0 - else - # more version fields in min than actual (1.0 vs 1.0.1 for instance): not OK - return 1 - fi -} - -function install_mono () { - local MONO_URL=`grep MIN_MONO_URL= Make.config | sed 's/.*=//'` - local MIN_MONO_VERSION=`grep MIN_MONO_VERSION= Make.config | sed 's/.*=//'` - - if test -z $MONO_URL; then - fail "No MIN_MONO_URL set in Make.config, cannot provision" - return - fi - - mkdir -p $PROVISION_DOWNLOAD_DIR - log "Downloading Mono $MIN_MONO_VERSION from $MONO_URL to $PROVISION_DOWNLOAD_DIR..." - local MONO_NAME=`basename $MONO_URL` - local MONO_PKG=$PROVISION_DOWNLOAD_DIR/$MONO_NAME - curl -L $MONO_URL > $MONO_PKG - - log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." - installer -pkg $MONO_PKG -target / - - rm -f $MONO_PKG -} - -function install_visual_studio () { - local VS="/Applications/Visual Studio.app" - local VS_URL=`grep MIN_VISUAL_STUDIO_URL= Make.config | sed 's/.*=//'` - local MIN_VISUAL_STUDIO_VERSION=`grep MIN_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` - - if test -z $VS_URL; then - fail "No MIN_VISUAL_STUDIO_URL set in Make.config, cannot provision" - return - fi - - mkdir -p $PROVISION_DOWNLOAD_DIR - log "Downloading Visual Studio $MIN_VISUAL_STUDIO_VERSION from $VS_URL to $PROVISION_DOWNLOAD_DIR..." - local VS_NAME=`basename $VS_URL` - local VS_DMG=$PROVISION_DOWNLOAD_DIR/$VS_NAME - curl -L $VS_URL > $VS_DMG - - local VS_MOUNTPOINT=$PROVISION_DOWNLOAD_DIR/$VS_NAME-mount - log "Mounting $VS_DMG into $VS_MOUNTPOINT..." - hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse - log "Removing previous Visual Studio from $VS" - rm -Rf "$VS" - log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." - cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications - log "Unmounting $VS_DMG..." - hdiutil detach $VS_MOUNTPOINT -quiet - - VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` - ok "Visual Studio $VS_ACTUAL_VERSION provisioned" - - rm -f $VS_DMG -} - -function install_specific_xcode () { - local XCODE_URL=`grep XCODE$1_URL= Make.config | sed 's/.*=//'` - local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'` - local XCODE_ROOT=$(dirname `dirname $XCODE_DEVELOPER_ROOT`) - - if test -z $XCODE_URL; then - fail "No XCODE$1_URL set in Make.config, cannot provision" - return - fi - - mkdir -p $PROVISION_DOWNLOAD_DIR - log "Downloading Xcode $XCODE_VERSION from $XCODE_URL to $PROVISION_DOWNLOAD_DIR..." - local XCODE_NAME=`basename $XCODE_URL` - local XCODE_DMG=$PROVISION_DOWNLOAD_DIR/$XCODE_NAME - - # To test this script with new Xcode versions, copy the downloaded file to $XCODE_DMG, - # uncomment the following curl line, and run ./system-dependencies.sh --provision-xcode - if test -f "~/Downloads/$XCODE_NAME"; then - log "Found XCode $XCODE_VERSION in your ~/Downloads folder, copying that version instead." - cp "~/Downloads/$XCODE_NAME" "$XCODE_DMG" - else - curl -L $XCODE_URL > $XCODE_DMG - fi - - if [[ ${XCODE_DMG: -4} == ".dmg" ]]; then - local XCODE_MOUNTPOINT=$PROVISION_DOWNLOAD_DIR/$XCODE_NAME-mount - log "Mounting $XCODE_DMG into $XCODE_MOUNTPOINT..." - hdiutil attach $XCODE_DMG -mountpoint $XCODE_MOUNTPOINT -quiet -nobrowse - log "Removing previous Xcode from $XCODE_ROOT" - rm -Rf $XCODE_ROOT - log "Installing Xcode $XCODE_VERSION to $XCODE_ROOT..." - cp -R $XCODE_MOUNTPOINT/*.app $XCODE_ROOT - log "Unmounting $XCODE_DMG..." - hdiutil detach $XCODE_MOUNTPOINT -quiet - elif [[ ${XCODE_DMG: -4} == ".xip" ]]; then - log "Extracting $XCODE_DMG..." - pushd . > /dev/null - cd $PROVISION_DOWNLOAD_DIR - # make sure there's nothing interfering - rm -Rf *.app - # extract - /System/Library/CoreServices/Applications/Archive\ Utility.app/Contents/MacOS/Archive\ Utility "$XCODE_DMG" - log "Installing Xcode $XCODE_VERSION to $XCODE_ROOT..." - mv *.app $XCODE_ROOT - popd > /dev/null - else - fail "Don't know how to install $XCODE_DMG" - fi - rm -f $XCODE_DMG - - log "Removing any com.apple.quarantine attributes from the installed Xcode" - xattr -d -r com.apple.quarantine $XCODE_ROOT - - if is_at_least_version $XCODE_VERSION 5.0; then - log "Accepting Xcode license" - $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept - fi - - if is_at_least_version $XCODE_VERSION 8.0; then - PKGS="MobileDevice.pkg MobileDeviceDevelopment.pkg XcodeSystemResources.pkg" - for pkg in $PKGS; do - if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then - log "Installing $pkg" - /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / - log "Installed $pkg" - else - log "Not installing $pkg because it doesn't exist." - fi - done - fi - - log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" - xcode-select -s $XCODE_DEVELOPER_ROOT - - ok "Xcode $XCODE_VERSION provisioned" -} - -function check_specific_xcode () { - local XCODE_DEVELOPER_ROOT=`grep XCODE$1_DEVELOPER_ROOT= Make.config | sed 's/.*=//'` - local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'` - local XCODE_ROOT=$(dirname `dirname $XCODE_DEVELOPER_ROOT`) - local ENABLE_XAMARIN=$(grep -s ^ENABLE_XAMARIN= Make.config.local configure.inc | sed 's/.*=//') - - if ! test -d $XCODE_DEVELOPER_ROOT; then - if ! test -z $PROVISION_XCODE; then - if ! test -z $ENABLE_XAMARIN; then - install_specific_xcode $1 - else - fail "Automatic provisioning of Xcode is only supported for provisioning internal build bots." - fail "Please download and install Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode" - fi - else - fail "You must install Xcode ($XCODE_VERSION) in $XCODE_ROOT. You can download Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode" - fi - return - else - if is_at_least_version $XCODE_VERSION 5.0; then - if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then - if ! test -z $PROVISION_XCODE; then - $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept - else - fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." - fi - return - fi - fi - fi - - local XCODE_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$XCODE_DEVELOPER_ROOT/../version.plist"` - # this is a hard match, having 4.5 when requesting 4.4 is not OK (but 4.4.1 is OK) - if [[ ! "x$XCODE_ACTUAL_VERSION" =~ "x$XCODE_VERSION" ]]; then - fail "You must install Xcode $XCODE_VERSION in $XCODE_ROOT (found $XCODE_ACTUAL_VERSION). You can download Xcode $XCODE_VERSION here: https://developer.apple.com/downloads/index.action?name=Xcode"; - return - fi - - local XCODE_SELECT=$(xcode-select -p) - if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then - if ! test -z $PROVISION_XCODE; then - log "Executing 'xcode-select -s $XCODE_DEVELOPER_ROOT'" - xcode-select -s $XCODE_DEVELOPER_ROOT - else - fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." - fi - fi - - ok "Found Xcode $XCODE_ACTUAL_VERSION in $XCODE_ROOT" -} - -function check_xcode () { - if ! test -z $IGNORE_XCODE; then return; fi - - # must have latest Xcode in /Applications/Xcode.app - check_specific_xcode - - local XCODE_DEVELOPER_ROOT=`grep ^XCODE_DEVELOPER_ROOT= Make.config | sed 's/.*=//'` - local IOS_SDK_VERSION=`grep ^IOS_SDK_VERSION= Make.config | sed 's/.*=//'` - local OSX_SDK_VERSION=`grep ^OSX_SDK_VERSION= Make.config | sed 's/.*=//'` - local WATCH_SDK_VERSION=`grep ^WATCH_SDK_VERSION= Make.config | sed 's/.*=//'` - local TVOS_SDK_VERSION=`grep ^TVOS_SDK_VERSION= Make.config | sed 's/.*=//'` - - local D=$XCODE_DEVELOPER_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk - if test ! -d $D -a -z "$FAIL"; then - fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update IOS_SDK_VERSION in Make.config." - fi - - local D=$XCODE_DEVELOPER_ROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk - if test ! -d $D -a -z "$FAIL"; then - fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update OSX_SDK_VERSION in Make.config." - fi - - local D=$XCODE_DEVELOPER_ROOT/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS${TVOS_SDK_VERSION}.sdk - if test ! -d $D -a -z "$FAIL"; then - fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update TVOS_SDK_VERSION in Make.config." - fi - - local D=$XCODE_DEVELOPER_ROOT/Platforms/WatchOS.platform/Developer/SDKs/WatchOS${WATCH_SDK_VERSION}.sdk - if test ! -d $D -a -z "$FAIL"; then - fail "The directory $D does not exist. If you've updated the Xcode location it means you also need to update WATCH_SDK_VERSION in Make.config." - fi -} - -function check_mono () { - if ! test -z $IGNORE_MONO; then return; fi - - PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/pkg-config - if ! /Library/Frameworks/Mono.framework/Commands/mono --version 2>/dev/null >/dev/null; then - if ! test -z $PROVISION_MONO; then - install_mono - else - fail "You must install the Mono MDK (http://www.mono-project.com/download/)" - return - fi - elif ! test -e $PKG_CONFIG_PATH; then - if ! test -z $PROVISION_MONO; then - install_mono - else - fail "Could not find pkg-config, you must install the Mono MDK (http://www.mono-project.com/download/)" - return - fi - fi - - MIN_MONO_VERSION=`grep MIN_MONO_VERSION= Make.config | sed 's/.*=//'` - MAX_MONO_VERSION=`grep MAX_MONO_VERSION= Make.config | sed 's/.*=//'` - - ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono`.`cat /Library/Frameworks/Mono.framework/Home/updateinfo | cut -d' ' -f2 | cut -c6- | awk '{print(int($0))}'` - if ! is_at_least_version $ACTUAL_MONO_VERSION $MIN_MONO_VERSION; then - if ! test -z $PROVISION_MONO; then - install_mono - ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono` - else - fail "You must have at least Mono $MIN_MONO_VERSION, found $ACTUAL_MONO_VERSION" - return - fi - elif [[ "$ACTUAL_MONO_VERSION" == "$MAX_MONO_VERSION" ]]; then - : # this is ok - elif is_at_least_version $ACTUAL_MONO_VERSION $MAX_MONO_VERSION; then - if ! test -z $PROVISION_MONO; then - install_mono - ACTUAL_MONO_VERSION=`$PKG_CONFIG_PATH --modversion mono`.`cat /Library/Frameworks/Mono.framework/Home/updateinfo | cut -d' ' -f2 | cut -c6- | awk '{print(int($0))}'` - else - fail "Your mono version is too new, max version is $MAX_MONO_VERSION, found $ACTUAL_MONO_VERSION." - fail "You may edit Make.config and change MAX_MONO_VERSION to your actual version to continue the" - fail "build (unless you're on a release branch). Once the build completes successfully, please" - fail "commit the new MAX_MONO_VERSION value." - return - fi - fi - - ok "Found Mono $ACTUAL_MONO_VERSION (at least $MIN_MONO_VERSION and not more than $MAX_MONO_VERSION is required)" -} - -function install_autoconf () { - if ! brew --version >& /dev/null; then - fail "Asked to install autoconf, but brew is not installed." - return - fi - - brew install autoconf -} - -function install_libtool () { - if ! brew --version >& /dev/null; then - fail "Asked to install libtool, but brew is not installed." - return - fi - - brew install libtool -} - -function install_automake () { - if ! brew --version >& /dev/null; then - fail "Asked to install automake, but brew is not installed." - return - fi - - brew install automake -} - - -function check_autotools () { - if ! test -z $IGNORE_AUTOTOOLS; then return; fi - -IFStmp=$IFS -IFS=' -' - if AUTOCONF_VERSION=($(autoconf --version 2>/dev/null)); then - ok "Found ${AUTOCONF_VERSION[0]} (no specific version is required)" - elif ! test -z $PROVISION_AUTOTOOLS; then - install_autoconf - else - fail "You must install autoconf, read the README.md for instructions" - fi - - if ! LIBTOOL=$(which glibtool 2>/dev/null); then - LIBTOOL=$(which libtool) - fi - - if LIBTOOL_VERSION=($($LIBTOOL --version 2>/dev/null )); then - ok "Found ${LIBTOOL_VERSION[0]} (no specific version is required)" - elif ! test -z $PROVISION_AUTOTOOLS; then - install_libtool - else - fail "You must install libtool, read the README.md for instructions" - fi - - if AUTOMAKE_VERSION=($(automake --version 2>/dev/null)); then - ok "Found ${AUTOMAKE_VERSION[0]} (no specific version is required)" - elif ! test -z $PROVISION_AUTOTOOLS; then - install_automake - else - fail "You must install automake, read the README.md for instructions" - fi -IFS=$IFS_tmp -} - -function check_visual_studio () { - if ! test -z $IGNORE_VISUAL_STUDIO; then return; fi - - VS="/Applications/Visual Studio.app" - local VS_URL=`grep MIN_VISUAL_STUDIO_URL= Make.config | sed 's/.*=//'` - if ! test -d "$VS"; then - if ! test -z $PROVISION_VS; then - install_visual_studio - else - fail "You must install Visual Studio, from http://www.monodevelop.com/download/" - fi - return - fi - - MIN_VISUAL_STUDIO_VERSION=`grep MIN_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` - MAX_VISUAL_STUDIO_VERSION=`grep MAX_VISUAL_STUDIO_VERSION= Make.config | sed 's/.*=//'` - VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` - if ! is_at_least_version $VS_ACTUAL_VERSION $MIN_VISUAL_STUDIO_VERSION; then - if ! test -z $PROVISION_VS; then - install_visual_studio - VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` - else - fail "You must have at least Visual Studio $MIN_VISUAL_STUDIO_VERSION (found $VS_ACTUAL_VERSION). Download URL: $VS_URL" - fi - return - elif [[ "$VS_ACTUAL_VERSION" == "$MAX_VISUAL_STUDIO_VERSION" ]]; then - : # this is ok - elif is_at_least_version $VS_ACTUAL_VERSION $MAX_VISUAL_STUDIO_VERSION; then - if ! test -z $PROVISION_VS; then - install_visual_studio - VS_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$VS/Contents/Info.plist"` - else - fail "Your Visual Studio version is too new, max version is $MAX_VISUAL_STUDIO_VERSION, found $VS_ACTUAL_VERSION." - fail "You may edit Make.config and change MAX_VISUAL_STUDIO_VERSION to your actual version to continue the" - fail "build (unless you're on a release branch). Once the build completes successfully, please" - fail "commit the new MAX_VISUAL_STUDIO_VERSION value." - fail "Alternatively you can download an older version from $VS_URL." - fi - return - fi - - ok "Found Visual Studio $VS_ACTUAL_VERSION (at least $MIN_VISUAL_STUDIO_VERSION and not more than $MAX_VISUAL_STUDIO_VERSION is required)" -} - -function check_osx_version () { - if ! test -z $IGNORE_OSX; then return; fi - - MIN_OSX_BUILD_VERSION=`grep MIN_OSX_BUILD_VERSION= Make.config | sed 's/.*=//'` - - ACTUAL_OSX_VERSION=$(sw_vers -productVersion) - if ! is_at_least_version $ACTUAL_OSX_VERSION $MIN_OSX_BUILD_VERSION; then - fail "You must have at least OSX $MIN_OSX_BUILD_VERSION (found $ACTUAL_OSX_VERSION)" - return - fi - - ok "Found OSX $ACTUAL_OSX_VERSION (at least $MIN_OSX_BUILD_VERSION is required)" -} - -function install_cmake () { - if ! brew --version >& /dev/null; then - fail "Asked to install cmake, but brew is not installed." - return - fi - - brew install cmake -} - -function check_cmake () { - if ! test -z $IGNORE_CMAKE; then return; fi - - local MIN_CMAKE_VERSION=`grep MIN_CMAKE_VERSION= Make.config | sed 's/.*=//'` - local CMAKE_URL=`grep CMAKE_URL= Make.config | sed 's/.*=//'` - - if ! cmake --version &> /dev/null; then - if ! test -z $PROVISION_CMAKE; then - install_cmake - else - fail "You must install CMake ($CMAKE_URL)" - fi - return - fi - - ACTUAL_CMAKE_VERSION=$(cmake --version | grep "cmake version" | sed 's/cmake version //') - if ! is_at_least_version $ACTUAL_CMAKE_VERSION $MIN_CMAKE_VERSION; then - fail "You must have at least CMake $MIN_CMAKE_VERSION (found $ACTUAL_CMAKE_VERSION)" - return - fi - - ok "Found CMake $ACTUAL_CMAKE_VERSION (at least $MIN_CMAKE_VERSION is required)" -} - -function check_homebrew () -{ -IFStmp=$IFS -IFS=' -' - if HOMEBREW_VERSION=($(brew --version 2>/dev/null)); then - ok "Found Homebrew ($HOMEBREW_VERSION)" - elif ! test -z $PROVISION_HOMEBREW; then - log "Installing Homebrew..." - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - HOMEBREW_VERSION=($(brew --version 2>/dev/null)) - log "Installed Homebrew ($HOMEBREW_VERSION)" - else - warn "Could not find Homebrew. Homebrew is required to auto-provision some dependencies (autotools, cmake), but not required otherwise." - fi -IFS=$IFS_tmp -} - -echo "Checking system..." - -check_osx_version -check_xcode -check_homebrew -check_autotools -check_mono -check_visual_studio -check_cmake - -if test -z $FAIL; then - echo "System check succeeded" -else - echo "System check failed" - exit 1 -fi diff --git a/system-dependencies.sh b/system-dependencies.sh index 099c477b608..1f06e39a0ee 100755 --- a/system-dependencies.sh +++ b/system-dependencies.sh @@ -4,10 +4,14 @@ set -o pipefail FAIL= PROVISION_DOWNLOAD_DIR=/tmp/x-provisioning - +SUDO=sudo # parse command-line arguments while ! test -z $1; do case $1 in + --no-sudo) + SUDO= + shift + ;; --provision-xcode) PROVISION_XCODE=1 shift @@ -159,7 +163,7 @@ function install_mono () { curl -L $MONO_URL > $MONO_PKG log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." - sudo installer -pkg $MONO_PKG -target / + $(sudo) installer -pkg $MONO_PKG -target / rm -f $MONO_PKG } @@ -184,9 +188,9 @@ function install_visual_studio () { log "Mounting $VS_DMG into $VS_MOUNTPOINT..." hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse log "Removing previous Visual Studio from $VS" - sudo rm -Rf "$VS" + $(sudo) rm -Rf "$VS" log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." - sudo cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications + $(sudo) cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications log "Unmounting $VS_DMG..." hdiutil detach $VS_MOUNTPOINT -quiet @@ -247,11 +251,11 @@ function install_specific_xcode () { rm -f $XCODE_DMG log "Removing any com.apple.quarantine attributes from the installed Xcode" - sudo xattr -d -r com.apple.quarantine $XCODE_ROOT + $(sudo) xattr -d -r com.apple.quarantine $XCODE_ROOT if is_at_least_version $XCODE_VERSION 5.0; then log "Accepting Xcode license" - sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept fi if is_at_least_version $XCODE_VERSION 8.0; then @@ -259,7 +263,7 @@ function install_specific_xcode () { for pkg in $PKGS; do if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then log "Installing $pkg" - sudo /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / + $(sudo) /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / log "Installed $pkg" else log "Not installing $pkg because it doesn't exist." @@ -267,8 +271,8 @@ function install_specific_xcode () { done fi - log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" - sudo xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT'" + $(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT ok "Xcode $XCODE_VERSION provisioned" } @@ -295,9 +299,9 @@ function check_specific_xcode () { if is_at_least_version $XCODE_VERSION 5.0; then if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then if ! test -z $PROVISION_XCODE; then - sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept else - fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute 'sudo $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." + fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." fi return fi @@ -314,10 +318,10 @@ function check_specific_xcode () { local XCODE_SELECT=$(xcode-select -p) if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then if ! test -z $PROVISION_XCODE; then - log "Executing 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT'" - sudo xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT'" + $(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT else - fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute 'sudo xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." + fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." fi fi From 09e5b2064830b8cf4c93da0d0d3c7cbfa6d5fa9b Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Tue, 25 Jul 2017 12:46:15 -0400 Subject: [PATCH 14/15] Don't 'execute' sudo --- system-dependencies.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/system-dependencies.sh b/system-dependencies.sh index 1f06e39a0ee..71c4ceb5bcb 100755 --- a/system-dependencies.sh +++ b/system-dependencies.sh @@ -163,7 +163,7 @@ function install_mono () { curl -L $MONO_URL > $MONO_PKG log "Installing Mono $MIN_MONO_VERSION from $MONO_URL..." - $(sudo) installer -pkg $MONO_PKG -target / + $SUDO installer -pkg $MONO_PKG -target / rm -f $MONO_PKG } @@ -188,9 +188,9 @@ function install_visual_studio () { log "Mounting $VS_DMG into $VS_MOUNTPOINT..." hdiutil attach $VS_DMG -mountpoint $VS_MOUNTPOINT -quiet -nobrowse log "Removing previous Visual Studio from $VS" - $(sudo) rm -Rf "$VS" + $SUDO rm -Rf "$VS" log "Installing Visual Studio $MIN_VISUAL_STUDIO_VERSION to $VS..." - $(sudo) cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications + $SUDO cp -R "$VS_MOUNTPOINT/Visual Studio.app" /Applications log "Unmounting $VS_DMG..." hdiutil detach $VS_MOUNTPOINT -quiet @@ -251,11 +251,11 @@ function install_specific_xcode () { rm -f $XCODE_DMG log "Removing any com.apple.quarantine attributes from the installed Xcode" - $(sudo) xattr -d -r com.apple.quarantine $XCODE_ROOT + $SUDO xattr -d -r com.apple.quarantine $XCODE_ROOT if is_at_least_version $XCODE_VERSION 5.0; then log "Accepting Xcode license" - $(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept fi if is_at_least_version $XCODE_VERSION 8.0; then @@ -263,7 +263,7 @@ function install_specific_xcode () { for pkg in $PKGS; do if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then log "Installing $pkg" - $(sudo) /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / + $SUDO /usr/sbin/installer -dumplog -verbose -pkg "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg" -target / log "Installed $pkg" else log "Not installing $pkg because it doesn't exist." @@ -271,8 +271,8 @@ function install_specific_xcode () { done fi - log "Executing '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT'" - $(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing '$SUDO xcode-select -s $XCODE_DEVELOPER_ROOT'" + $SUDO xcode-select -s $XCODE_DEVELOPER_ROOT ok "Xcode $XCODE_VERSION provisioned" } @@ -299,9 +299,9 @@ function check_specific_xcode () { if is_at_least_version $XCODE_VERSION 5.0; then if ! $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license check >/dev/null 2>&1; then if ! test -z $PROVISION_XCODE; then - $(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept + $SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept else - fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$(sudo) $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." + fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it." fi return fi @@ -318,10 +318,10 @@ function check_specific_xcode () { local XCODE_SELECT=$(xcode-select -p) if [[ "x$XCODE_SELECT" != "x$XCODE_DEVELOPER_ROOT" ]]; then if ! test -z $PROVISION_XCODE; then - log "Executing '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT'" - $(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT + log "Executing '$SUDO xcode-select -s $XCODE_DEVELOPER_ROOT'" + $SUDO xcode-select -s $XCODE_DEVELOPER_ROOT else - fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute '$(sudo) xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." + fail "'xcode-select -p' does not point to $XCODE_DEVELOPER_ROOT, it points to $XCODE_SELECT. Execute '$SUDO xcode-select -s $XCODE_DEVELOPER_ROOT' to fix." fi fi @@ -600,3 +600,4 @@ else echo "System check failed" exit 1 fi + From 5e5306833377f3adbe228812e5dde74f477c31dd Mon Sep 17 00:00:00 2001 From: Joseph Stroman Date: Wed, 26 Jul 2017 17:04:36 -0400 Subject: [PATCH 15/15] Print out workspace --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 6efaea0c117..8fd4215fa20 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ echo "PATH ======= $PATH" - +echo "WORKSPACE ======= $WORKSPACE" cd .. && mv s xamarin-macios && cd xamarin-macios make $1 cd .. && mv xamarin-macios s && cd s