Skip to content

Commit b119a93

Browse files
SQUASH – add ability to check published releases too
1 parent f5a33a8 commit b119a93

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

cassandra-release/cassandra-check-release.sh

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22

33
# Parameters
4-
# $1 release
5-
# $2 maven artefacts url number (as specified in the vote email)
4+
# $1 staged|released
5+
# $2 release
6+
# $3 maven artefacts staging repo id (as specified in the repo url found in the vote email) (ignored for 'released')
67
#
7-
# Example use: `./cassandra-check-release.sh 4.0-beta3 1224
8+
# Example use: `./cassandra-check-release.sh staged 4.0-beta3 1224
89
#
910
# This script is very basic and experimental. I beg of you to help improve it.
1011
#
@@ -19,25 +20,32 @@ command -v md5sum >/dev/null 2>&1 || { echo >&2 "md5sum needs to be installed";
1920
command -v sha256sum >/dev/null 2>&1 || { echo >&2 "sha256sum needs to be installed"; exit 1; }
2021
command -v sha512sum >/dev/null 2>&1 || { echo >&2 "sha512sum needs to be installed"; exit 1; }
2122
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; }
2423
command -v docker >/dev/null 2>&1 || { echo >&2 "docker needs to be installed"; exit 1; }
2524
(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 "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; }
25+
26+
( [ "staged" = $1 ] || [ "released" = $1 ] ) || { echo >&2 "first argument must be staged or released"; exit 1; }
27+
( [ $# -ge 2 ] ) || { echo >&2 "minimum two arguments must be provided"; exit 1; }
28+
if [ -z "$3" ] ; then
29+
[ "released" == $1 ] || { echo >&2 "third argument must not be specified when first is released"; exit 1; }
30+
maven_repo_url="https://repository.apache.org/content/repositories/releases/org/apache/cassandra/cassandra-all/$2"
31+
else
32+
[ "staged" == $1 ] || { echo >&2 "third argument must be specified when first is staged"; exit 1; }
33+
maven_repo_url="https://repository.apache.org/content/repositories/orgapachecassandra-$3/org/apache/cassandra/cassandra-all/$2"
34+
fi
35+
(curl --output /dev/null --silent --head --fail "https://dist.apache.org/repos/dist/dev/cassandra/$2/") || { echo >&2 "Not Found: https://dist.apache.org/repos/dist/dev/cassandra/$2/"; exit 1; }
36+
(curl --output /dev/null --silent --head --fail "${maven_repo_url}") || { echo >&2 "Not found: ${maven_repo_url}"; exit 1; }
37+
3038

3139
###################
3240

33-
mkdir -p /tmp/$1
34-
cd /tmp/$1
41+
mkdir -p /tmp/$2
42+
cd /tmp/$2
3543
echo "Downloading KEYS"
3644
wget -q https://downloads.apache.org/cassandra/KEYS
37-
echo "Downloading https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1"
38-
wget -Nqnd -e robots=off --recursive --no-parent https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1
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/
45+
echo "Downloading ${maven_repo_url}"
46+
wget -Nqnd -e robots=off --recursive --no-parent ${maven_repo_url}
47+
echo "Downloading https://dist.apache.org/repos/dist/dev/cassandra/$2/"
48+
wget -Nqe robots=off --recursive --no-parent https://dist.apache.org/repos/dist/dev/cassandra/$2/
4149

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

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

6270
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
71+
rm -fR apache-cassandra-$2-src
72+
tar -xzf apache-cassandra-$2-src.tar.gz
73+
rm -fR apache-cassandra-$2
74+
tar -xzf apache-cassandra-$2-bin.tar.gz
6775

6876
JDKS="8"
69-
if [[ $1 =~ [4]\. ]] ; then
77+
if [[ $2 =~ [4]\. ]] ; then
7078
JDKS=("8" "11")
71-
elif [[ $1 =~ [5]\. ]] ; then
79+
elif [[ $2 =~ [5]\. ]] ; then
7280
JDKS=("11" "17")
7381
fi
82+
TIMEOUT=2160
7483

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

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

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

116125
PID=$!
117126
success=false
@@ -138,7 +147,7 @@ for JDK in ${JDKS[@]} ; do
138147
echo
139148
rm -f procfifo
140149
mkfifo procfifo
141-
docker run -i -v `pwd`/debian:/debian ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
150+
docker run -i -v `pwd`/debian:/debian ${DEBIAN_IMAGE} timeout ${TIMEOUT} /bin/bash -c "
142151
( apt -qq update ;
143152
apt -qq install -y python ; # will silently fail on debian latest
144153
apt -qq install -y python3 procps ;
@@ -163,20 +172,20 @@ for JDK in ${JDKS[@]} ; do
163172

164173
# test deb repository startup
165174

166-
idx=`expr index "$1" -`
175+
idx=`expr index "$2" -`
167176
if [ $idx -eq 0 ]
168177
then
169-
release_short=${1}
178+
release_short=${2}
170179
else
171-
release_short=${1:0:$((idx-1))}
180+
release_short=${2:0:$((idx-1))}
172181
fi
173182
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"
174183

175184
echo
176185
rm -f procfifo
177186
mkfifo procfifo
178-
docker run -i ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
179-
( 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 ;
187+
docker run -i ${DEBIAN_IMAGE} timeout ${TIMEOUT} /bin/bash -c "
188+
( echo 'deb https://dist.apache.org/repos/dist/dev/cassandra/${2}/debian ${debian_series} main' | tee -a /etc/apt/sources.list.d/cassandra.sources.list ;
180189
apt -qq update ;
181190
apt -qq install -y curl gnupg2 ;
182191
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
@@ -207,13 +216,13 @@ for JDK in ${JDKS[@]} ; do
207216
fi
208217

209218
RH_DISTS="almalinux"
210-
if ! [[ $1 =~ [23]\. ]] ; then
211-
RH_DISTS=("almalinux" "centos:7")
219+
if ! [[ $2 =~ [23]\. ]] ; then
220+
RH_DISTS=("almalinux" "noboolean")
212221
fi
213222
for RH_DIST in ${RH_DISTS[@]} ; do
214223

215224
NOBOOLEAN_REPO=""
216-
if [ "$RH_DIST" == "centos:7" ] ; then
225+
if [ "$RH_DIST" == "noboolean" ] ; then
217226
NOBOOLEAN_REPO="/noboolean"
218227
fi
219228

@@ -222,9 +231,9 @@ for JDK in ${JDKS[@]} ; do
222231
echo
223232
rm -f procfifo
224233
mkfifo procfifo
225-
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 2160 /bin/bash -c "
234+
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat almalinux timeout ${TIMEOUT} /bin/bash -c "
226235
( yum install -y procps-ng python3-pip;
227-
if [ "centos:7" == "$RH_DIST" ] && [ "java-17-openjdk-devel" == "$JDK_RH" ] ; then
236+
if [ "noboolean" == "$RH_DIST" ] && [ "java-17-openjdk-devel" == "$JDK_RH" ] ; then
228237
# centos7 doesn't have jdk17, so manual install ;
229238
curl https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm -o jdk-17_linux-x64_bin.rpm ;
230239
yum -y install ./jdk-17_linux-x64_bin.rpm ;
@@ -255,10 +264,10 @@ for JDK in ${JDKS[@]} ; do
255264
rm -f procfifo
256265
mkfifo procfifo
257266
# 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.
258-
docker run -i ${RH_DIST} timeout 2160 /bin/bash -c "(
267+
docker run -i almalinux timeout ${TIMEOUT} /bin/bash -c "(
259268
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
260269
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
261-
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
270+
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${2}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
262271
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
263272
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
264273
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;

0 commit comments

Comments
 (0)