| 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 |
|
| 16 |
set -ex |
| 17 |
|
| 18 |
cd "$(dirname "$0")" |
| 19 |
|
| 20 |
function die { |
| 21 |
echo "$1" |
| 22 |
exit 1 |
| 23 |
} |
| 24 |
|
| 25 |
ARCH="$1" |
| 26 |
PLATFORM="$2" |
| 27 |
PACKAGE_TYPE="$3" |
| 28 |
echo "$EXTERNAL_GIT_ROOT" |
| 29 |
GRPC_VERSION="$(ruby -e 'require ENV["EXTERNAL_GIT_ROOT"] + "/src/ruby/lib/grpc/version.rb"; puts GRPC::VERSION')" |
| 30 |
if [[ "$PACKAGE_TYPE" == "source" ]]; then |
| 31 |
GEM_NAME="grpc-${GRPC_VERSION}.gem" |
| 32 |
else |
| 33 |
[[ "$PACKAGE_TYPE" == "binary" ]] || die "unexpeced package type: $PACKAGE_TYPE" |
| 34 |
GEM_NAME="grpc-${GRPC_VERSION}-${ARCH}-${PLATFORM}.gem" |
| 35 |
fi |
| 36 |
# Create an indexed local gem source with gRPC gems to test |
| 37 |
GEM_SOURCE=../../../gem_source |
| 38 |
mkdir -p "${GEM_SOURCE}/gems" |
| 39 |
cp "${EXTERNAL_GIT_ROOT}/input_artifacts/${GEM_NAME}" "${GEM_SOURCE}/gems" |
| 40 |
# TODO: rewrite the following line to be shellcheck-compliant |
| 41 |
# shellcheck disable=SC2010 |
| 42 |
if [[ "$(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 |
| 45 |
fi; |
| 46 |
gem install builder |
| 47 |
gem generate_index --directory "${GEM_SOURCE}" |
| 48 |
|
| 49 |
bundle install |
| 50 |
|
| 51 |
bundle exec ./distribtest.rb |
| 52 |
|
| 53 |
[[ "$PACKAGE_TYPE" == "source" ]] && exit 0 |
| 54 |
# Attempt to repro https://github.com/protocolbuffers/protobuf/issues/4210. |
| 55 |
# This sanity check only works for linux-based distrib tests and for |
| 56 |
# binary gRPC packages. |
| 57 |
INSTALLATION_DIR="$(gem env | grep '\- INSTALLATION DIRECTORY' | awk '{ print $4 }')" |
| 58 |
if [[ "$(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 |
| 61 |
fi |
| 62 |
LIBRUBY_DEPENDENCY_EXISTS="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'libruby')" || true |
| 63 |
if [[ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ]]; then |
| 64 |
echo "A grpc_c.so file in this binary gRPC package is dynamically linked to libruby." |
| 65 |
fi |
| 66 |
DEPENDENCY_NOT_FOUND="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'not found')" || true |
| 67 |
if [[ "$DEPENDENCY_NOT_FOUND" != 0 ]]; then |
| 68 |
echo "A grpc_c.so file in this binary gRPC package has an non-portable dependency." |
| 69 |
fi |
| 70 |
if [ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ] || [ "$DEPENDENCY_NOT_FOUND" != 0 ]; then |
| 71 |
exit 1 |
| 72 |
fi |