Skip to content

Commit 72fda04

Browse files
committed
Fix up change-yaml.sh to generate md5 sum for spark
This is transitional while we wait for sha512 support in cekit.
1 parent 7684e50 commit 72fda04

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

change-yaml.sh

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,52 @@ fi
7070
# Change spark distro
7171
if [ ! -z ${SPARK+x} ]; then
7272

73-
# Change the md5sum for pyspark and java, update base image for scala
74-
wget https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-hadoop${HVER}.tgz.md5 -O /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz.md5
75-
if [ "$?" -eq 0 ]; then
76-
sum=$(cat /tmp/spark-${SPARK}-bin-hadoop2.7.tgz.md5 | cut -d':' -f 2 | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
77-
if [[ "$OSTYPE" == "darwin"* ]]; then
78-
# Mac OSX
79-
# Fix the url references
80-
gsed -i "s@https://archive.apache.org/dist/spark/spark-.*/spark-.*-bin-@https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-@" image.*.yaml
81-
# Fix the md5 sum references on the line following the url
82-
gsed -i '\@url: https://archive.apache.org/dist/spark/@!b;n;s/md5.*/md5: '$sum'/' image.*.yaml
83-
else
84-
# Fix the url references
85-
sed -i "s@https://archive.apache.org/dist/spark/spark-.*/spark-.*-bin-@https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-@" image.*.yaml
86-
# Fix the md5 sum references on the line following the url
87-
sed -i '\@url: https://archive.apache.org/dist/spark/@!b;n;s/md5.*/md5: '$sum'/' image.*.yaml
88-
fi
73+
# TODO remove this download when sha512 support lands in upstream cekit (tmckay)
74+
# Since this is big let's see if it's already there
75+
if [ -f "/tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz" ]; then
76+
echo
77+
echo Using existing "/tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz", if this is not what you want delete it and run again
78+
echo
8979
else
90-
echo "Failed to get the md5 sum for the specified spark version, the version $SPARK may not be a real version"
80+
wget https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-hadoop${HVER}.tgz -O /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz
81+
if [ "$?" -ne 0 ]; then
82+
echo "Failed to download the specified version Spark archive"
83+
exit 1
84+
fi
85+
fi
86+
87+
wget https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-hadoop${HVER}.tgz.sha512 -O /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz.sha512
88+
if [ "$?" -ne 0 ]; then
89+
echo "Failed to download the sha512 sum for the specified Spark version"
90+
exit 1
91+
fi
92+
93+
# TODO remove this checksum calculation when sha512 support lands in upstream cekit (tmckay)
94+
calcsum=$(sha512sum /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz | cut -d" " -f1)
95+
sum=$(cat /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz.sha512 | tr -d [:space:] | cut -d: -f2 | tr [:upper:] [:lower:])
96+
if [ "$calcsum" != "$sum" ]; then
97+
echo "Failed to confirm authenticity of Spark archive, checksum mismatch"
98+
echo "sha512sum : ${calcsum}"
99+
echo ".sha512 file: ${sum}"
91100
exit 1
92101
fi
93102

94-
#change the spark version in the env var
95103
if [[ "$OSTYPE" == "darwin"* ]]; then
96-
gsed -i '\@name: SPARK_VERSION@!b;n;s/value:.*/value: '$SPARK'/' image.java.yaml
104+
SED=gsed
97105
else
98-
sed -i '\@name: SPARK_VERSION@!b;n;s/value:.*/value: '$SPARK'/' image.java.yaml
106+
SED=sed
99107
fi
108+
109+
# Fix the url references
110+
$SED -i "s@https://archive.apache.org/dist/spark/spark-.*/spark-.*-bin-@https://archive.apache.org/dist/spark/spark-${SPARK}/spark-${SPARK}-bin-@" image.*.yaml
111+
112+
# Fix the md5 sum references on the line following the url
113+
# TODO replace this with sha512 when it lands in upstream cekit (tmckay)
114+
calcsum=$(md5sum /tmp/spark-${SPARK}-bin-hadoop${HVER}.tgz | cut -d" " -f1)
115+
$SED -i '\@url: https://archive.apache.org/dist/spark/@!b;n;s/md5.*/md5: '$calcsum'/' image.*.yaml
116+
117+
#change the spark version in the env var
118+
$SED -i '\@name: SPARK_VERSION@!b;n;s/value:.*/value: '$SPARK'/' image.java.yaml
100119
fi
101120

102121
# Add any changes for commit

0 commit comments

Comments
 (0)