|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Parameters |
| 4 | +# $1 release |
| 5 | +# $2 maven artefacts url (as specified in the vote email) |
| 6 | +# |
| 7 | +# Example use: `./cassandra-check-release.sh 4.0-beta3 https://repository.apache.org/content/repositories/orgapachecassandra-1224/org/apache/cassandra/cassandra-all/4.0-beta3/` |
| 8 | +# |
| 9 | +# This script is very basic and experimental. I beg of you to help improve it. |
| 10 | +# |
| 11 | + |
| 12 | +################### |
| 13 | +# prerequisites |
| 14 | + |
| 15 | +command -v wget >/dev/null 2>&1 || { echo >&2 "wget needs to be installed"; exit 1; } |
| 16 | +command -v gpg >/dev/null 2>&1 || { echo >&2 "gpg needs to be installed"; exit 1; } |
| 17 | +command -v sha1sum >/dev/null 2>&1 || { echo >&2 "sha1sum needs to be installed"; exit 1; } |
| 18 | +command -v md5sum >/dev/null 2>&1 || { echo >&2 "md5sum needs to be installed"; exit 1; } |
| 19 | +command -v sha256sum >/dev/null 2>&1 || { echo >&2 "sha256sum needs to be installed"; exit 1; } |
| 20 | +command -v sha512sum >/dev/null 2>&1 || { echo >&2 "sha512sum needs to be installed"; exit 1; } |
| 21 | +command -v tar >/dev/null 2>&1 || { echo >&2 "tar needs to be installed"; exit 1; } |
| 22 | +command -v ant >/dev/null 2>&1 || { echo >&2 "ant needs to be installed"; exit 1; } |
| 23 | +command -v timeout >/dev/null 2>&1 || { echo >&2 "timeout needs to be installed"; exit 1; } |
| 24 | +command -v docker >/dev/null 2>&1 || { echo >&2 "docker needs to be installed"; exit 1; } |
| 25 | +(docker info >/dev/null 2>&1) || { echo >&2 "docker needs to running"; exit 1; } |
| 26 | +(java -version 2>&1 | grep -q "1.8") || { echo >&2 "Java 8 must be used"; exit 1; } |
| 27 | +(java -version 2>&1 | grep -iq jdk ) || { echo >&2 "Java JDK must be used"; exit 1; } |
| 28 | +(curl --output /dev/null --silent --head --fail "https://dist.apache.org/repos/dist/dev/cassandra/$1/") || { echo >&2 "Not Found: https://dist.apache.org/repos/dist/dev/cassandra/$1/"; exit 1; } |
| 29 | +(curl --output /dev/null --silent --head --fail "$2") || { echo >&2 "Not Found: $2"; exit 1; } |
| 30 | + |
| 31 | +################### |
| 32 | + |
| 33 | +mkdir -p /tmp/$1 |
| 34 | +cd /tmp/$1 |
| 35 | +echo "Downloading KEYS" |
| 36 | +wget https://downloads.apache.org/cassandra/KEYS |
| 37 | +echo "Downloading $2" |
| 38 | +wget -Nqnd -e robots=off --recursive --no-parent $2 |
| 39 | +echo "Downloading https://dist.apache.org/repos/dist/dev/cassandra/$1/" |
| 40 | +wget -Nqe robots=off --recursive --no-parent https://dist.apache.org/repos/dist/dev/cassandra/$1/ |
| 41 | + |
| 42 | +echo |
| 43 | +echo "====== CHECK RESULTS ======" |
| 44 | +echo |
| 45 | + |
| 46 | +gpg --import KEYS |
| 47 | + |
| 48 | +(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; } |
| 49 | +for f in *.asc ; do gpg --verify $f ; done |
| 50 | +(compgen -G "*.pom" >/dev/null) || { echo >&2 "No *.pom files found in $(pwd)"; exit 1; } |
| 51 | +(compgen -G "*.jar" >/dev/null) || { echo >&2 "No *.jar files found in $(pwd)"; exit 1; } |
| 52 | +for f in *.pom *.jar *.asc ; do echo -n "sha1: " ; echo "$(cat $f.sha1) $f" | sha1sum -c ; echo -n "md5: " ; echo "$(cat $f.md5) $f" | md5sum -c ; done |
| 53 | + |
| 54 | +cd dist.apache.org/repos/dist/dev/cassandra/$1 |
| 55 | +(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; } |
| 56 | +for f in *.asc ; do gpg --verify $f ; done |
| 57 | +(compgen -G "*.gz" >/dev/null) || { echo >&2 "No *.gz files found in $(pwd)"; exit 1; } |
| 58 | +(compgen -G "*.sha256" >/dev/null) || { echo >&2 "No *.sha256 files found in $(pwd)"; exit 1; } |
| 59 | +(compgen -G "*.sha512" >/dev/null) || { echo >&2 "No *.sha512 files found in $(pwd)"; exit 1; } |
| 60 | +for f in *.gz ; do echo -n "sha256: " ; echo "$(cat $f.sha256) $f" | sha256sum -c ; echo -n "sha512:" ; echo "$(cat $f.sha512) $f" | sha512sum -c ; done |
| 61 | + |
| 62 | +echo |
| 63 | +rm -fR apache-cassandra-$1-src |
| 64 | +tar -xzf apache-cassandra-$1-src.tar.gz |
| 65 | +rm -fR apache-cassandra-$1 |
| 66 | +tar -xzf apache-cassandra-$1-bin.tar.gz |
| 67 | + |
| 68 | +JDKS="8" |
| 69 | +if ! [[ $1 =~ [23]\. ]] ; then |
| 70 | + JDKS=("8" "11") |
| 71 | +fi |
| 72 | + |
| 73 | +for JDK in ${JDKS[@]} ; do |
| 74 | + |
| 75 | + if [ "$JDK" == "11" ] ; then |
| 76 | + BUILD_OPT="-Duse.jdk11=true" |
| 77 | + fi |
| 78 | + echo |
| 79 | + rm -f procfifo |
| 80 | + mkfifo procfifo |
| 81 | + docker run -i -v `pwd`/apache-cassandra-$1-src:/apache-cassandra-$1-src openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "( apt -qq update; apt -qq install -y ant build-essential git ) 2>/dev/null; cd apache-cassandra-$1-src ; ant artifacts ${BUILD_OPT}" 2>&1 >procfifo & |
| 82 | + |
| 83 | + PID=$! |
| 84 | + success=false |
| 85 | + while read LINE && ! $success ; do |
| 86 | + if [[ $LINE =~ '^BUILD ' ]] ; then |
| 87 | + echo "Source build (JDK ${JDK}) OK" |
| 88 | + kill "$PID" |
| 89 | + success=true |
| 90 | + fi |
| 91 | + done < procfifo |
| 92 | + rm -f procfifo |
| 93 | + wait "$PID" |
| 94 | + if ! $success ; then |
| 95 | + echo "Source build (JDK ${JDK}) FAILED" |
| 96 | + fi |
| 97 | + |
| 98 | + echo |
| 99 | + rm -f procfifo |
| 100 | + mkfifo procfifo |
| 101 | + docker run -i -v `pwd`/apache-cassandra-$1:/apache-cassandra-$1 openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "( apt -qq update; apt -qq install -y python python3 procps ) 2>/dev/null; apache-cassandra-$1/bin/cassandra -R -f" 2>&1 >procfifo & |
| 102 | + |
| 103 | + PID=$! |
| 104 | + success=false |
| 105 | + while read LINE && ! $success ; do |
| 106 | + if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then |
| 107 | + echo "Binary artefact (JDK ${JDK}) OK" |
| 108 | + kill "$PID" |
| 109 | + success=true |
| 110 | + fi |
| 111 | + done < procfifo |
| 112 | + rm -f procfifo |
| 113 | + wait "$PID" |
| 114 | + if ! $success ; then |
| 115 | + echo "Binary artefact (JDK ${JDK}) FAILED" |
| 116 | + fi |
| 117 | + |
| 118 | + echo |
| 119 | + rm -f procfifo |
| 120 | + mkfifo procfifo |
| 121 | + docker run -i -v `pwd`/debian:/debian openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "( apt -qq update; apt -qq install -y python python3 procps; dpkg --ignore-depends=java7-runtime --ignore-depends=java8-runtime -i debian/*.deb ) 2>/dev/null; CASSANDRA_CONF=file:///etc/cassandra/ HEAP_NEWSIZE=500m MAX_HEAP_SIZE=1g cassandra -R -f" 2>&1 >procfifo & |
| 122 | + PID=$! |
| 123 | + success=false |
| 124 | + while read LINE && ! $success ; do |
| 125 | + if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then |
| 126 | + echo "Debian package (JDK ${JDK}) OK" |
| 127 | + kill "$PID" |
| 128 | + success=true |
| 129 | + fi |
| 130 | + done < procfifo |
| 131 | + rm -f procfifo |
| 132 | + wait "$PID" |
| 133 | + if ! $success ; then |
| 134 | + echo "Debian package (JDK ${JDK}) FAILED" |
| 135 | + fi |
| 136 | + |
| 137 | + if [ "$JDK" == "8" ] ; then |
| 138 | + JDK_RH="java-1.8.0-openjdk" |
| 139 | + elif [ "$JDK" == "11" ] ; then |
| 140 | + JDK_RH="java-11-openjdk-devel" |
| 141 | + fi |
| 142 | + |
| 143 | + for RH_DIST in "almalinux" "centos:7" ; do |
| 144 | + echo |
| 145 | + rm -f procfifo |
| 146 | + mkfifo procfifo |
| 147 | + docker run -i -v `pwd`/redhat:/redhat ${RH_DIST} timeout 1080 /bin/bash -c "( yum install -y ${JDK_RH} procps-ng python3-pip ; rpm -i --nodeps redhat/*.rpm ) 2>/dev/null; cassandra -R -f " 2>&1 >procfifo & |
| 148 | + PID=$! |
| 149 | + |
| 150 | + success=false |
| 151 | + while read LINE && ! $success ; do |
| 152 | + if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then |
| 153 | + echo "Redhat package (${RH_DIST} JDK ${JDK}) OK" |
| 154 | + kill "$PID" |
| 155 | + success=true |
| 156 | + fi |
| 157 | + done < procfifo |
| 158 | + rm -f procfifo |
| 159 | + wait "$PID" |
| 160 | + if ! $success ; then |
| 161 | + echo "Redhat package (${RH_DIST} JDK ${JDK}) FAILED" |
| 162 | + fi |
| 163 | + done |
| 164 | +done |
0 commit comments