Skip to content

Commit

Permalink
SQUASH – add ability to check published releases too
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Jul 18, 2024
1 parent f5a33a8 commit 333a269
Showing 1 changed file with 69 additions and 51 deletions.
120 changes: 69 additions & 51 deletions cassandra-release/cassandra-check-release.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

# Parameters
# $1 release
# $2 maven artefacts url number (as specified in the vote email)
# $1 staged|released
# $2 release
# $3 maven artefacts staging repo id (as specified in the repo url found in the vote email) (ignored for 'released')
#
# Example use: `./cassandra-check-release.sh 4.0-beta3 1224
# Example use: `./cassandra-check-release.sh staged 4.0-beta3 1224
#
# This script is very basic and experimental. I beg of you to help improve it.
#
Expand All @@ -19,25 +20,52 @@ command -v md5sum >/dev/null 2>&1 || { echo >&2 "md5sum needs to be installed";
command -v sha256sum >/dev/null 2>&1 || { echo >&2 "sha256sum needs to be installed"; exit 1; }
command -v sha512sum >/dev/null 2>&1 || { echo >&2 "sha512sum needs to be installed"; exit 1; }
command -v tar >/dev/null 2>&1 || { echo >&2 "tar needs to be installed"; exit 1; }
command -v ant >/dev/null 2>&1 || { echo >&2 "ant needs to be installed"; exit 1; }
command -v timeout >/dev/null 2>&1 || { echo >&2 "timeout needs to be installed"; exit 1; }
command -v docker >/dev/null 2>&1 || { echo >&2 "docker needs to be installed"; exit 1; }
(docker info >/dev/null 2>&1) || { echo >&2 "docker needs to running"; exit 1; }
(java -version 2>&1 | grep -q "1.8") || { echo >&2 "Java 8 must be used"; exit 1; }
(java -version 2>&1 | grep -iq jdk ) || { echo >&2 "Java JDK must be used"; exit 1; }
(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; }
(curl --output /dev/null --silent --head --fail "https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1") || { echo >&2 "Not Found: https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1"; exit 1; }

( [ "staged" = $1 ] || [ "released" = $1 ] ) || { echo >&2 "first argument must be staged or released"; exit 1; }
( [ $# -ge 2 ] ) || { echo >&2 "minimum two arguments must be provided"; exit 1; }
if [ -z "$3" ] ; then
[ "released" == $1 ] || { echo >&2 "third argument must not be specified when first is released"; exit 1; }
dist_url="https://dist.apache.org/repos/dist/release/cassandra/$2/"
maven_repo_url="https://repository.apache.org/content/repositories/releases/org/apache/cassandra/cassandra-all/$2"
debian_url="https://debian.cassandra.apache.org/"
redhat_url="https://redhat.cassandra.apache.org/"
else
[ "staged" == $1 ] || { echo >&2 "third argument must be specified when first is staged"; exit 1; }
dist_url="https://dist.apache.org/repos/dist/dev/cassandra/$2/"
maven_repo_url="https://repository.apache.org/content/repositories/orgapachecassandra-$3/org/apache/cassandra/cassandra-all/$2"
debian_url="https://dist.apache.org/repos/dist/dev/cassandra/${2}/debian/"
redhat_url="https://dist.apache.org/repos/dist/dev/cassandra/${2}/redhat/"
fi
(curl --output /dev/null --silent --head --fail "${dist_url}") || { echo >&2 "Not Found: ${dist_url}"; exit 1; }
(curl --output /dev/null --silent --head --fail "${maven_repo_url}") || { echo >&2 "Not found: ${maven_repo_url}"; exit 1; }

###################

mkdir -p /tmp/$1
cd /tmp/$1
idx=`expr index "$2" -`
if [ $idx -eq 0 ] ; then
release_short=${2}
else
release_short=${2:0:$((idx-1))}
fi
packaging_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"

mkdir -p /tmp/$2
cd /tmp/$2
echo "Downloading KEYS"
wget -q https://downloads.apache.org/cassandra/KEYS
echo "Downloading https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1"
wget -Nqnd -e robots=off --recursive --no-parent https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1
echo "Downloading https://dist.apache.org/repos/dist/dev/cassandra/$1/"
wget -Nqe robots=off --recursive --no-parent https://dist.apache.org/repos/dist/dev/cassandra/$1/
echo "Downloading ${maven_repo_url}"
wget -Nqnd -e robots=off --recursive --no-parent ${maven_repo_url}
echo "Downloading ${dist_url}"
wget -Nqe robots=off --recursive --no-parent ${dist_url}
if [ -z "$3" ] ; then
mkdir dist.apache.org/repos/dist/release/cassandra/$2/{debian,redhat}
echo "Downloading ${debian_url}/pool/main/c/cassandra/*${2/-/\~}/*.deb"
wget -Nqe robots=off --recursive --no-parent -A "*${2/-/\~}*.deb" -P dist.apache.org/repos/dist/release/cassandra/$2/debian ${debian_url}/pool/main/c/cassandra/
echo "Downloading ${redhat_url}/${packaging_series}/**/*${2/-/\~}*.rpm"
wget -Nqe robots=off --recursive --no-parent -A "*${2/-/\~}*.rpm" -P dist.apache.org/repos/dist/release/cassandra/$2/redhat ${redhat_url}/${packaging_series}/
fi

echo
echo "====== CHECK RESULTS ======"
Expand All @@ -51,7 +79,7 @@ for f in *.asc ; do gpg --verify $f ; done
(compgen -G "*.jar" >/dev/null) || { echo >&2 "No *.jar files found in $(pwd)"; exit 1; }
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

cd dist.apache.org/repos/dist/dev/cassandra/$1
cd dist.apache.org/repos/dist/*/cassandra/$2
(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; }
for f in *.asc ; do gpg --verify $f ; done
(compgen -G "*.gz" >/dev/null) || { echo >&2 "No *.gz files found in $(pwd)"; exit 1; }
Expand All @@ -60,17 +88,18 @@ for f in *.asc ; do gpg --verify $f ; done
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

echo
rm -fR apache-cassandra-$1-src
tar -xzf apache-cassandra-$1-src.tar.gz
rm -fR apache-cassandra-$1
tar -xzf apache-cassandra-$1-bin.tar.gz
rm -fR apache-cassandra-$2-src
tar -xzf apache-cassandra-$2-src.tar.gz
rm -fR apache-cassandra-$2
tar -xzf apache-cassandra-$2-bin.tar.gz

JDKS="8"
if [[ $1 =~ [4]\. ]] ; then
if [[ $2 =~ [4]\. ]] ; then
JDKS=("8" "11")
elif [[ $1 =~ [5]\. ]] ; then
elif [[ $2 =~ [5]\. ]] ; then
JDKS=("11" "17")
fi
TIMEOUT=2160

for JDK in ${JDKS[@]} ; do

Expand All @@ -82,10 +111,10 @@ for JDK in ${JDKS[@]} ; do
echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/apache-cassandra-$1-src:/apache-cassandra-$1-src openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
docker run -i -v `pwd`/apache-cassandra-$2-src:/apache-cassandra-$2-src openjdk:${JDK}-jdk-slim-buster timeout ${TIMEOUT} /bin/bash -c "
( apt -qq update;
apt -qq install -y ant build-essential git python procps ) 2>&1 >/dev/null;
cd apache-cassandra-$1-src ;
cd apache-cassandra-$2-src ;
ant artifacts ${BUILD_OPT}" 2>&1 >procfifo &

PID=$!
Expand All @@ -108,10 +137,10 @@ for JDK in ${JDKS[@]} ; do
echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/apache-cassandra-$1:/apache-cassandra-$1 openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
docker run -i -v `pwd`/apache-cassandra-$2:/apache-cassandra-$2 openjdk:${JDK}-jdk-slim-buster timeout ${TIMEOUT} /bin/bash -c "
( apt -qq update;
apt -qq install -y python python3 procps ) 2>&1 >/dev/null;
apache-cassandra-$1/bin/cassandra -R -f" 2>&1 >procfifo &
apache-cassandra-$2/bin/cassandra -R -f" 2>&1 >procfifo &

PID=$!
success=false
Expand All @@ -138,7 +167,7 @@ for JDK in ${JDKS[@]} ; do
echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/debian:/debian ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
docker run -i -v `pwd`/debian:/debian ${DEBIAN_IMAGE} timeout ${TIMEOUT} /bin/bash -c "
( apt -qq update ;
apt -qq install -y python ; # will silently fail on debian latest
apt -qq install -y python3 procps ;
Expand All @@ -163,20 +192,11 @@ for JDK in ${JDKS[@]} ; do

# test deb repository startup

idx=`expr index "$1" -`
if [ $idx -eq 0 ]
then
release_short=${1}
else
release_short=${1:0:$((idx-1))}
fi
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"

echo
rm -f procfifo
mkfifo procfifo
docker run -i ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
( echo 'deb https://dist.apache.org/repos/dist/dev/cassandra/${1}/debian ${debian_series} main' | tee -a /etc/apt/sources.list.d/cassandra.sources.list ;
docker run -i ${DEBIAN_IMAGE} timeout ${TIMEOUT} /bin/bash -c "
( echo 'deb ${debian_url} ${packaging_series} main' | tee -a /etc/apt/sources.list.d/cassandra.sources.list ;
apt -qq update ;
apt -qq install -y curl gnupg2 ;
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
Expand Down Expand Up @@ -207,30 +227,28 @@ for JDK in ${JDKS[@]} ; do
fi

RH_DISTS="almalinux"
if ! [[ $1 =~ [23]\. ]] ; then
RH_DISTS=("almalinux" "centos:7")
if ! [[ $2 =~ [23]\. ]] ; then
RH_DISTS=("almalinux" "noboolean")
fi
for RH_DIST in ${RH_DISTS[@]} ; do

NOBOOLEAN_REPO=""
if [ "$RH_DIST" == "centos:7" ] ; then
if [ "$RH_DIST" == "noboolean" ] ; then
NOBOOLEAN_REPO="/noboolean"
fi
REPO_VERSION=""
if [ "released" == "$1" ] ; then
REPO_VERSION="${packaging_series}"
fi

# test rpm package startup

echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 2160 /bin/bash -c "
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat almalinux timeout ${TIMEOUT} /bin/bash -c "
( yum install -y procps-ng python3-pip;
if [ "centos:7" == "$RH_DIST" ] && [ "java-17-openjdk-devel" == "$JDK_RH" ] ; then
# centos7 doesn't have jdk17, so manual install ;
curl https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm -o jdk-17_linux-x64_bin.rpm ;
yum -y install ./jdk-17_linux-x64_bin.rpm ;
else
yum install -y ${JDK_RH} ;
fi
yum install -y ${JDK_RH} ;
rpm -i --nodeps redhat/*.rpm ) 2>&1 >/dev/null ;
cassandra -R -f " 2>&1 >procfifo &

Expand All @@ -255,10 +273,10 @@ for JDK in ${JDKS[@]} ; do
rm -f procfifo
mkfifo procfifo
# yum repo installation failing due to a legacy (SHA1) third-party sig in our KEYS file, hence use of update-crypto-policies. Impacts all rhel9+ users.
docker run -i ${RH_DIST} timeout 2160 /bin/bash -c "(
docker run -i almalinux timeout ${TIMEOUT} /bin/bash -c "(
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
echo 'baseurl=${redhat_url}${REPO_VERSION}${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;
Expand Down

0 comments on commit 333a269

Please sign in to comment.