1#!/bin/bash 2# Copyright 2015 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -ex 17 18cd "$(dirname "$0")" 19 20function die { 21 echo "$1" 22 exit 1 23} 24 25ARCH="$1" 26PLATFORM="$2" 27PACKAGE_TYPE="$3" 28echo "$EXTERNAL_GIT_ROOT" 29GRPC_VERSION="$(ruby -e 'require ENV["EXTERNAL_GIT_ROOT"] + "/src/ruby/lib/grpc/version.rb"; puts GRPC::VERSION')" 30if [[ "$PACKAGE_TYPE" == "source" ]]; then 31 GEM_NAME="grpc-${GRPC_VERSION}.gem" 32else 33 [[ "$PACKAGE_TYPE" == "binary" ]] || die "unexpeced package type: $PACKAGE_TYPE" 34 GEM_NAME="grpc-${GRPC_VERSION}-${ARCH}-${PLATFORM}.gem" 35fi 36# Create an indexed local gem source with gRPC gems to test 37GEM_SOURCE=../../../gem_source 38mkdir -p "${GEM_SOURCE}/gems" 39cp "${EXTERNAL_GIT_ROOT}/input_artifacts/${GEM_NAME}" "${GEM_SOURCE}/gems" 40# TODO: rewrite the following line to be shellcheck-compliant 41# shellcheck disable=SC2010 42if [[ "$(ls "${GEM_SOURCE}/gems" | grep -c grpc)" != 1 ]]; then 43 echo "Sanity check failed. Copied over more than one grpc gem into the gem source directory." 44 exit 1 45fi; 46gem install builder 47gem generate_index --directory "${GEM_SOURCE}" 48 49bundle install 50 51bundle exec ./distribtest.rb 52 53[[ "$PACKAGE_TYPE" == "source" ]] && exit 0 54# Attempt to repro https://github.com/google/protobuf/issues/4210. 55# This sanity check only works for linux-based distrib tests and for 56# binary gRPC packages. 57INSTALLATION_DIR="$(gem env | grep '\- INSTALLATION DIRECTORY' | awk '{ print $4 }')" 58if [[ "$(find "$INSTALLATION_DIR" -name 'grpc_c.so' | wc -l)" == 0 ]]; then 59 echo "Sanity check failed. The gRPC package is not installed in $INSTALLATION_DIR." 60 exit 1 61fi 62LIBRUBY_DEPENDENCY_EXISTS="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'libruby')" || true 63if [[ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ]]; then 64 echo "A grpc_c.so file in this binary gRPC package is dynamically linked to libruby." 65fi 66DEPENDENCY_NOT_FOUND="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'not found')" || true 67if [[ "$DEPENDENCY_NOT_FOUND" != 0 ]]; then 68 echo "A grpc_c.so file in this binary gRPC package has an non-portable dependency." 69fi 70if [ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ] || [ "$DEPENDENCY_NOT_FOUND" != 0 ]; then 71 exit 1 72fi 73