OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright 2015-2016, Google Inc. |
| 3 # All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 # |
| 31 # This script is invoked by Jenkins and triggers a test run of |
| 32 # linuxbrew installation of a selected language |
| 33 set -ex |
| 34 |
| 35 # Our homebrew installation script command, per language |
| 36 # Can be used in both linux and macos |
| 37 if [ "$language" == "core" ]; then |
| 38 command="curl -fsSL https://goo.gl/getgrpc | bash -" |
| 39 elif [[ "python nodejs ruby php" =~ "$language" ]]; then |
| 40 command="curl -fsSL https://goo.gl/getgrpc | bash -s $language" |
| 41 else |
| 42 echo "unsupported language $language" |
| 43 exit 1 |
| 44 fi |
| 45 |
| 46 if [ "$platform" == "linux" ]; then |
| 47 |
| 48 if [ "$dist_channel" == "homebrew" ]; then |
| 49 |
| 50 sha1=$(sha1sum tools/dockerfile/grpc_linuxbrew/Dockerfile | cut -f1 -d\ ) |
| 51 DOCKER_IMAGE_NAME=grpc_linuxbrew_$sha1 |
| 52 |
| 53 # build docker image, contains all pre-requisites |
| 54 docker build -t $DOCKER_IMAGE_NAME tools/dockerfile/grpc_linuxbrew |
| 55 |
| 56 # run per-language homebrew installation script |
| 57 docker run --rm=true $DOCKER_IMAGE_NAME bash -l \ |
| 58 -c "nvm use 0.12; \ |
| 59 npm set unsafe-perm true; \ |
| 60 rvm use ruby-2.1; \ |
| 61 $command" |
| 62 |
| 63 else |
| 64 echo "Unsupported $platform dist_channel $dist_channel" |
| 65 exit 1 |
| 66 fi |
| 67 |
| 68 elif [ "$platform" == "macos" ]; then |
| 69 |
| 70 if [ "$dist_channel" == "homebrew" ]; then |
| 71 |
| 72 echo "Formulas installed by system-wide homebrew (before)" |
| 73 brew list -l |
| 74 |
| 75 # Save the original PATH so that we can run the system `brew` command |
| 76 # again at the end of the script |
| 77 export ORIGINAL_PATH=$PATH |
| 78 |
| 79 # Set up temp directories for test installation of homebrew |
| 80 brew_root=/tmp/homebrew-test-$language |
| 81 rm -rf $brew_root |
| 82 mkdir -p $brew_root |
| 83 git clone https://github.com/Homebrew/homebrew.git $brew_root |
| 84 |
| 85 # Make sure we are operating at the right copy of temp homebrew |
| 86 # installation |
| 87 export PATH=$brew_root/bin:$PATH |
| 88 |
| 89 # Set up right environment for each language |
| 90 case $language in |
| 91 *python*) |
| 92 rm -rf jenkins_python_venv |
| 93 virtualenv jenkins_python_venv |
| 94 source jenkins_python_venv/bin/activate |
| 95 ;; |
| 96 *nodejs*) |
| 97 export PATH=$HOME/.nvm/versions/node/v0.12.7/bin:$PATH |
| 98 ;; |
| 99 *ruby*) |
| 100 export PATH=/usr/local/rvm/rubies/ruby-2.2.1/bin:$PATH |
| 101 ;; |
| 102 *php*) |
| 103 export CFLAGS="-Wno-parentheses-equality" |
| 104 ;; |
| 105 esac |
| 106 |
| 107 # Run our homebrew installation script |
| 108 bash -c "$command" |
| 109 |
| 110 # Uninstall / clean up per-language modules/extensions after the test |
| 111 case $language in |
| 112 *python*) |
| 113 deactivate |
| 114 rm -rf jenkins_python_venv |
| 115 ;; |
| 116 *nodejs*) |
| 117 npm list -g | grep grpc |
| 118 npm uninstall -g grpc |
| 119 ;; |
| 120 *ruby*) |
| 121 gem list | grep grpc |
| 122 gem uninstall grpc |
| 123 ;; |
| 124 *php*) |
| 125 rm grpc.so |
| 126 ;; |
| 127 esac |
| 128 |
| 129 # Clean up |
| 130 rm -rf $brew_root |
| 131 |
| 132 echo "Formulas installed by system-wide homebrew (after, should be unaffecte
d)" |
| 133 export PATH=$ORIGINAL_PATH |
| 134 brew list -l |
| 135 |
| 136 else |
| 137 echo "Unsupported $platform dist_channel $dist_channel" |
| 138 exit 1 |
| 139 fi |
| 140 |
| 141 else |
| 142 echo "unsupported platform $platform" |
| 143 exit 1 |
| 144 fi |
OLD | NEW |