1#!/bin/bash 2 3function check_libs { 4 local elf_path=$1 5 6 for elf in $(find $elf_path -maxdepth 1 -exec file {} \; | grep 'ELF ' | cut -d':' -f1); do 7 echo "$elf" 8 ldd "$elf" 9 done 10 return 11} 12 13function prepare { 14 CURDIR=$(pwd) 15 TMP_DIR="$CURDIR/temp" 16 17 mkdir -p "$CURDIR"/temp 18 19 if [ -f /etc/redhat-release ]; then 20 export PATH=$PATH:/usr/sbin 21 fi 22 23 TARBALLS="" 24 for tarball in $(find . -name "*.tar.gz"); do 25 TARBALLS+=" $(basename $tarball)" 26 done 27 28 DIRLIST="bin lib lib/private lib/plugin" 29} 30 31function install_deps { 32 if [ -f /etc/redhat-release ]; then 33 yum install -y epel-release 34 yum install -y perl-Time-HiRes perl numactl numactl-libs libaio libev libatomic libidn || true 35 else 36 apt-get install -y perl numactl libaio-dev libev4 libatomic1 libidn11 || true 37 38 fi 39} 40 41main () { 42 prepare 43 for tarfile in $TARBALLS; do 44 echo "Unpacking tarball: $tarfile" 45 cd "$TMP_DIR" 46 tar xf "$CURDIR/$tarfile" 47 cd "${tarfile%.tar.gz}" 48 49 echo "Building ELFs ldd output list" 50 for DIR in $DIRLIST; do 51 if ! check_libs "$DIR" >> "$TMP_DIR"/libs_err.log; then 52 echo "There is an error with libs linkage" 53 echo "Displaying log: " 54 cat "$TMP_DIR"/libs_err.log 55 exit 1 56 fi 57 done 58 59 echo "Checking for missing libraries" 60 if [[ ! -z $(grep "not found" $TMP_DIR/libs_err.log) ]]; then 61 echo "ERROR: There are missing libraries: " 62 grep "not found" "$TMP_DIR"/libs_err.log 63 echo "Log: " 64 cat "$TMP_DIR"/libs_err.log 65 exit 1 66 fi 67 68 # Run MTRs 69 if [[ -z "${SKIP_MTR}" ]] && [[ "$SKIP_MTR" != "true" ]]; then 70 export PATH=$PATH:$(pwd)/bin 71 cd percona-xtrabackup-8.0-test/test 72 ./bootstrap.sh xtradb80 73 ./run.sh -j $(nproc) -f 74 fi 75 76 rm -rf "${TMP_DIR:?}/*" 77 done 78} 79 80case "$1" in 81 --install_deps) install_deps ;; 82 --test) main ;; 83 --help|*) 84 cat <<EOF 85Usage: $0 [OPTIONS] 86 The following options may be given : 87 --install_deps 88 --test 89 --help) usage ;; 90Example $0 --install_deps 91EOF 92 ;; 93esac 94