From af2e5c982947362e1de328ddd752840c7a8cf7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 20 May 2020 17:57:57 +0200 Subject: [PATCH] Use a Brewfile for installing brew packages (#36747) This means we won't be upgrading existing packages on the system that we don't need for the build. Marks install-native-dependencies.sh as executable (+x) so we don't need to start it with `sh` in the build .yml Fixes https://github.com/dotnet/runtime/issues/36727 --- .../requirements/macos-requirements.md | 6 ++-- eng/Brewfile | 8 +++++ eng/install-native-dependencies.sh | 35 +++---------------- eng/pipelines/common/global-build-job.yml | 2 +- .../templates/runtimes/build-test-job.yml | 2 +- eng/pipelines/coreclr/templates/build-job.yml | 2 +- eng/pipelines/installer/jobs/base-job.yml | 2 +- eng/pipelines/libraries/build-job.yml | 2 +- eng/pipelines/mono/templates/build-job.yml | 2 +- 9 files changed, 21 insertions(+), 40 deletions(-) create mode 100644 eng/Brewfile mode change 100644 => 100755 eng/install-native-dependencies.sh diff --git a/docs/workflow/requirements/macos-requirements.md b/docs/workflow/requirements/macos-requirements.md index 82a6610321bb5..4604b87f60f85 100644 --- a/docs/workflow/requirements/macos-requirements.md +++ b/docs/workflow/requirements/macos-requirements.md @@ -16,7 +16,7 @@ Install Apple Xcode developer tools from the Mac App Store ([link](https://apps. Toolchain Setup --------------- -Building dotnet/runtime depends on several tools to be installed. You can download them individually or use [Homebrew](http://brew.sh) for easier toolchain setup. +Building dotnet/runtime depends on several tools to be installed. You can download them individually or use [Homebrew](https://brew.sh) for easier toolchain setup. Install the following packages: @@ -29,8 +29,8 @@ Install the following packages: - pkg-config - python3 -The lines to install all the packages above using Homebrew. +You can install all the packages above using Homebrew by running this command in the repository root: ``` -brew install cmake autoconf automake icu4c libtool openssl@1.1 pkg-config python3 +brew bundle --no-lock --file eng/Brewfile ``` diff --git a/eng/Brewfile b/eng/Brewfile new file mode 100644 index 0000000000000..40252a15f3048 --- /dev/null +++ b/eng/Brewfile @@ -0,0 +1,8 @@ +brew "autoconf" +brew "automake" +brew "cmake" +brew "icu4c" +brew "libtool" +brew "openssl@1.1" +brew "pkg-config" +brew "python3" diff --git a/eng/install-native-dependencies.sh b/eng/install-native-dependencies.sh old mode 100644 new mode 100755 index be154811ea7f1..00be5a6287289 --- a/eng/install-native-dependencies.sh +++ b/eng/install-native-dependencies.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [ "$1" = "Linux" ]; then sudo apt update @@ -9,36 +9,9 @@ if [ "$1" = "Linux" ]; then if [ "$?" != "0" ]; then exit 1; fi -elif [ "$1" = "OSX" ]; then - brew update - brew upgrade - if [ "$?" != "0" ]; then - exit 1; - fi - brew install autoconf automake icu4c libtool openssl@1.1 pkg-config python3 - if [ "$?" != "0" ]; then - exit 1; - fi - if [ "$?" != "0" ]; then - exit 1; - fi -elif [ "$1" = "tvOS" ]; then - brew update - brew upgrade - if [ "$?" != "0" ]; then - exit 1; - fi - brew install autoconf automake libtool openssl@1.1 pkg-config python3 - if [ "$?" != "0" ]; then - exit 1; - fi -elif [ "$1" = "iOS" ]; then - brew update - brew upgrade - if [ "$?" != "0" ]; then - exit 1; - fi - brew install autoconf automake libtool openssl@1.1 pkg-config python3 +elif [ "$1" = "OSX" ] || [ "$1" = "tvOS" ] || [ "$1" = "iOS" ]; then + engdir=$(dirname "${BASH_SOURCE[0]}") + brew bundle --no-lock --file "${engdir}/Brewfile" if [ "$?" != "0" ]; then exit 1; fi diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index e0f71a3f128a9..29071209e79dc 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -28,7 +28,7 @@ jobs: - template: /eng/pipelines/common/clone-checkout-bundle-step.yml - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} displayName: Install Build Dependencies - script: | diff --git a/eng/pipelines/common/templates/runtimes/build-test-job.yml b/eng/pipelines/common/templates/runtimes/build-test-job.yml index a4f94efcc56b4..6c46cfadeb0c4 100644 --- a/eng/pipelines/common/templates/runtimes/build-test-job.yml +++ b/eng/pipelines/common/templates/runtimes/build-test-job.yml @@ -85,7 +85,7 @@ jobs: # Install test build dependencies - ${{ if eq(parameters.osGroup, 'OSX') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) displayName: Install native dependencies - ${{ if eq(parameters.osGroup, 'Windows_NT') }}: # Necessary to install correct cmake version diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index 870cdc6c0822a..c23db63f95666 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -106,7 +106,7 @@ jobs: # and FreeBSD builds use a build agent with dependencies # preinstalled, so we only need this step for OSX and Windows. - ${{ if eq(parameters.osGroup, 'OSX') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) displayName: Install native dependencies - ${{ if eq(parameters.osGroup, 'Windows_NT') }}: # Necessary to install python diff --git a/eng/pipelines/installer/jobs/base-job.yml b/eng/pipelines/installer/jobs/base-job.yml index 2c309c03892a7..8e9c3f1824bb2 100644 --- a/eng/pipelines/installer/jobs/base-job.yml +++ b/eng/pipelines/installer/jobs/base-job.yml @@ -457,7 +457,7 @@ jobs: cleanUnpackFolder: false - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} displayName: Install Build Dependencies - script: | diff --git a/eng/pipelines/libraries/build-job.yml b/eng/pipelines/libraries/build-job.yml index 2287c8f1dafb1..94df7e9469e34 100644 --- a/eng/pipelines/libraries/build-job.yml +++ b/eng/pipelines/libraries/build-job.yml @@ -78,7 +78,7 @@ jobs: - template: /eng/pipelines/common/restore-internal-tools.yml - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} displayName: Install Build Dependencies - script: | diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index 8593d86481033..901bab9a0f660 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -89,7 +89,7 @@ jobs: # and FreeBSD builds use a build agent with dependencies # preinstalled, so we only need this step for OSX and Windows. - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: - - script: sh $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) + - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh $(osGroup) displayName: Install native dependencies - ${{ if eq(parameters.osGroup, 'Windows_NT') }}: # Necessary to install python