Skip to content

Commit 333a269

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

File tree

1 file changed

+69
-51
lines changed

1 file changed

+69
-51
lines changed

cassandra-release/cassandra-check-release.sh

Lines changed: 69 additions & 51 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,52 @@ 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+
dist_url="https://dist.apache.org/repos/dist/release/cassandra/$2/"
31+
maven_repo_url="https://repository.apache.org/content/repositories/releases/org/apache/cassandra/cassandra-all/$2"
32+
debian_url="https://debian.cassandra.apache.org/"
33+
redhat_url="https://redhat.cassandra.apache.org/"
34+
else
35+
[ "staged" == $1 ] || { echo >&2 "third argument must be specified when first is staged"; exit 1; }
36+
dist_url="https://dist.apache.org/repos/dist/dev/cassandra/$2/"
37+
maven_repo_url="https://repository.apache.org/content/repositories/orgapachecassandra-$3/org/apache/cassandra/cassandra-all/$2"
38+
debian_url="https://dist.apache.org/repos/dist/dev/cassandra/${2}/debian/"
39+
redhat_url="https://dist.apache.org/repos/dist/dev/cassandra/${2}/redhat/"
40+
fi
41+
(curl --output /dev/null --silent --head --fail "${dist_url}") || { echo >&2 "Not Found: ${dist_url}"; exit 1; }
42+
(curl --output /dev/null --silent --head --fail "${maven_repo_url}") || { echo >&2 "Not found: ${maven_repo_url}"; exit 1; }
3043

3144
###################
3245

33-
mkdir -p /tmp/$1
34-
cd /tmp/$1
46+
idx=`expr index "$2" -`
47+
if [ $idx -eq 0 ] ; then
48+
release_short=${2}
49+
else
50+
release_short=${2:0:$((idx-1))}
51+
fi
52+
packaging_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"
53+
54+
mkdir -p /tmp/$2
55+
cd /tmp/$2
3556
echo "Downloading KEYS"
3657
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/
58+
echo "Downloading ${maven_repo_url}"
59+
wget -Nqnd -e robots=off --recursive --no-parent ${maven_repo_url}
60+
echo "Downloading ${dist_url}"
61+
wget -Nqe robots=off --recursive --no-parent ${dist_url}
62+
if [ -z "$3" ] ; then
63+
mkdir dist.apache.org/repos/dist/release/cassandra/$2/{debian,redhat}
64+
echo "Downloading ${debian_url}/pool/main/c/cassandra/*${2/-/\~}/*.deb"
65+
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/
66+
echo "Downloading ${redhat_url}/${packaging_series}/**/*${2/-/\~}*.rpm"
67+
wget -Nqe robots=off --recursive --no-parent -A "*${2/-/\~}*.rpm" -P dist.apache.org/repos/dist/release/cassandra/$2/redhat ${redhat_url}/${packaging_series}/
68+
fi
4169

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

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

6290
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
91+
rm -fR apache-cassandra-$2-src
92+
tar -xzf apache-cassandra-$2-src.tar.gz
93+
rm -fR apache-cassandra-$2
94+
tar -xzf apache-cassandra-$2-bin.tar.gz
6795

6896
JDKS="8"
69-
if [[ $1 =~ [4]\. ]] ; then
97+
if [[ $2 =~ [4]\. ]] ; then
7098
JDKS=("8" "11")
71-
elif [[ $1 =~ [5]\. ]] ; then
99+
elif [[ $2 =~ [5]\. ]] ; then
72100
JDKS=("11" "17")
73101
fi
102+
TIMEOUT=2160
74103

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

@@ -82,10 +111,10 @@ for JDK in ${JDKS[@]} ; do
82111
echo
83112
rm -f procfifo
84113
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 "
114+
docker run -i -v `pwd`/apache-cassandra-$2-src:/apache-cassandra-$2-src openjdk:${JDK}-jdk-slim-buster timeout ${TIMEOUT} /bin/bash -c "
86115
( apt -qq update;
87116
apt -qq install -y ant build-essential git python procps ) 2>&1 >/dev/null;
88-
cd apache-cassandra-$1-src ;
117+
cd apache-cassandra-$2-src ;
89118
ant artifacts ${BUILD_OPT}" 2>&1 >procfifo &
90119

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

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

164193
# test deb repository startup
165194

166-
idx=`expr index "$1" -`
167-
if [ $idx -eq 0 ]
168-
then
169-
release_short=${1}
170-
else
171-
release_short=${1:0:$((idx-1))}
172-
fi
173-
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"
174-
175195
echo
176196
rm -f procfifo
177197
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 ;
198+
docker run -i ${DEBIAN_IMAGE} timeout ${TIMEOUT} /bin/bash -c "
199+
( echo 'deb ${debian_url} ${packaging_series} main' | tee -a /etc/apt/sources.list.d/cassandra.sources.list ;
180200
apt -qq update ;
181201
apt -qq install -y curl gnupg2 ;
182202
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
@@ -207,30 +227,28 @@ for JDK in ${JDKS[@]} ; do
207227
fi
208228

209229
RH_DISTS="almalinux"
210-
if ! [[ $1 =~ [23]\. ]] ; then
211-
RH_DISTS=("almalinux" "centos:7")
230+
if ! [[ $2 =~ [23]\. ]] ; then
231+
RH_DISTS=("almalinux" "noboolean")
212232
fi
213233
for RH_DIST in ${RH_DISTS[@]} ; do
214234

215235
NOBOOLEAN_REPO=""
216-
if [ "$RH_DIST" == "centos:7" ] ; then
236+
if [ "$RH_DIST" == "noboolean" ] ; then
217237
NOBOOLEAN_REPO="/noboolean"
218238
fi
239+
REPO_VERSION=""
240+
if [ "released" == "$1" ] ; then
241+
REPO_VERSION="${packaging_series}"
242+
fi
219243

220244
# test rpm package startup
221245

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

@@ -255,10 +273,10 @@ for JDK in ${JDKS[@]} ; do
255273
rm -f procfifo
256274
mkfifo procfifo
257275
# 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 "(
276+
docker run -i almalinux timeout ${TIMEOUT} /bin/bash -c "(
259277
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
260278
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 ;
279+
echo 'baseurl=${redhat_url}${REPO_VERSION}${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
262280
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
263281
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
264282
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;

0 commit comments

Comments
 (0)