run homebrew installation script on macos jenkins

pull/2608/head
Stanley Cheung 10 years ago
parent 49c8a15357
commit f64825f24b
  1. 98
      tools/jenkins/run_distribution.sh

@ -32,6 +32,15 @@
# linuxbrew installation of a selected language # linuxbrew installation of a selected language
set -ex set -ex
if [ "$language" == "core" ]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -"
elif [[ "python nodejs ruby php" =~ "$language" ]]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -s $language"
else
echo "unsupported language $language"
exit 1
fi
if [ "$platform" == "linux" ]; then if [ "$platform" == "linux" ]; then
if [ "$dist_channel" == "homebrew" ]; then if [ "$dist_channel" == "homebrew" ]; then
@ -42,15 +51,6 @@ if [ "$platform" == "linux" ]; then
# build docker image, contains all pre-requisites # build docker image, contains all pre-requisites
docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_linuxbrew docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_linuxbrew
if [ "$language" == "core" ]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -"
elif [[ "python nodejs ruby php" =~ "$language" ]]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -s $language"
else
echo "unsupported language $language"
exit 1
fi
# run per-language homebrew installation script # run per-language homebrew installation script
docker run $DOCKER_IMAGE_NAME bash -l \ docker run $DOCKER_IMAGE_NAME bash -l \
-c "nvm use 0.12; \ -c "nvm use 0.12; \
@ -66,67 +66,60 @@ if [ "$platform" == "linux" ]; then
elif [ "$platform" == "macos" ]; then elif [ "$platform" == "macos" ]; then
if [ "$dist_channel" == "homebrew" ]; then if [ "$dist_channel" == "homebrew" ]; then
# system installed homebrew, don't interfere echo "Formulas installed by system-wide homebrew (before)"
brew list -l brew list -l
# Save the original PATH so that we can run the system `brew` command
# again at the end of the script
export ORIGINAL_PATH=$PATH
# Set up temp directories for test installation of homebrew # Set up temp directories for test installation of homebrew
brew_root=/tmp/homebrew-test-$language brew_root=/tmp/homebrew-test-$language
rm -rf $brew_root rm -rf $brew_root
mkdir -p $brew_root mkdir -p $brew_root
git clone https://github.com/Homebrew/homebrew.git $brew_root git clone https://github.com/Homebrew/homebrew.git $brew_root
# Install grpc via homebrew # Make sure we are operating at the right copy of temp homebrew
# # installation
# The temp $PATH env variable makes sure we are operating at the right copy of
# temp homebrew installation, and do not interfere with the system's main brew
# installation.
#
# TODO: replace the next section with the actual homebrew installation script
# i.e. curl -fsSL https://goo.gl/getgrpc | bash -s $language
# need to resolve a bunch of environment and privilege issue on the jenkins
# mac machine itself
export OLD_PATH=$PATH
export PATH=$brew_root/bin:$PATH export PATH=$brew_root/bin:$PATH
cd $brew_root
brew tap homebrew/dupes
brew install zlib
brew install openssl
brew tap grpc/grpc
brew install --without-python google-protobuf
brew install grpc
brew list -l
# Install per-language modules/extensions on top of core grpc # Set up right environment for each language
# case $language in
# If a command below needs root access, the binary had been added to *python*)
# /etc/sudoers. This step needs to be repeated if we add more mac instances rm -rf jenkins_python_venv
# to our jenkins project. virtualenv jenkins_python_venv
# source jenkins_python_venv/bin/activate
# Examples (lines that needed to be added to /etc/sudoers): ;;
# + Defaults env_keep += "CFLAGS CXXFLAGS LDFLAGS enable_grpc" *nodejs*)
# + jenkinsnode1 ALL=(ALL) NOPASSWD: /usr/bin/pecl, /usr/local/bin/pip, export PATH=$HOME/.nvm/versions/node/v0.12.7/bin:$PATH
# + /usr/local/bin/npm ;;
*php*)
export CFLAGS="-Wno-parentheses-equality"
;;
*)
;;
esac
# Run our homebrew installation script
bash -c "$command"
# Uninstall / clean up per-language modules/extensions after the test
case $language in case $language in
*core*) ;; *core*) ;;
*python*) *python*)
sudo CFLAGS=-I$brew_root/include LDFLAGS=-L$brew_root/lib pip install grpcio deactivate
pip list | grep grpcio rm -rf jenkins_python_venv
echo 'y' | sudo pip uninstall grpcio
;; ;;
*nodejs*) *nodejs*)
sudo CXXFLAGS=-I$brew_root/include LDFLAGS=-L$brew_root/lib npm install grpc npm list -g | grep grpc
npm list | grep grpc npm uninstall -g grpc
sudo npm uninstall grpc
;; ;;
*ruby*) *ruby*)
gem install grpc -- --with-grpc-dir=$brew_root
gem list | grep grpc gem list | grep grpc
gem uninstall grpc gem uninstall grpc
;; ;;
*php*) *php*)
sudo enable_grpc=$brew_root CFLAGS="-Wno-parentheses-equality" pecl install grpc-alpha rm grpc.so
pecl list | grep grpc
sudo pecl uninstall grpc
;; ;;
*) *)
echo "Unsupported language $language" echo "Unsupported language $language"
@ -134,12 +127,11 @@ elif [ "$platform" == "macos" ]; then
;; ;;
esac esac
# clean up # Clean up
cd ~/
rm -rf $brew_root rm -rf $brew_root
# Make sure the system brew installation is still unaffected echo "Formulas installed by system-wide homebrew (after, should be unaffected)"
export PATH=$OLD_PATH export PATH=$ORIGINAL_PATH
brew list -l brew list -l
else else

Loading…
Cancel
Save