forked from redhat-developer/odo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-bit-verification.sh
executable file
·92 lines (74 loc) · 2.16 KB
/
release-bit-verification.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/sh
############################################################################
# PREREQUISITES FOR THIS SCRIPT
# 1. Redistributable-binary(.rpm) should be passed as the first argument
# 2. Login to the cluster should be done prior to running this script
# 3. The cluster should be in a state where it can be used for testing
#
# USAGE:
# ./release-bit-verification.sh redistributable-binary
#
# Example: ./release-bit-verification.sh ~/Downloads/odo-redistributable-2.4.3-1.el8.x86_64.rpm
#
#For erroring out in case of error
set -eo pipefail
shout() {
echo "--------------------------------$1------------------------------------------"
}
# Check SHASUM for all the binary files and there should be no difference
# Checking for no or invaild arguments
if [ "$#" -lt 1 ]
then
echo "No arguments supplied"
exit 1
fi
if [ ! -f ${1} ];
then
echo "Please enter a valid filepath";
exit 1
fi
#Creating an Temp directory
WORKING_DIR=$(mktemp -d)
shout "WORKING_DIR=$WORKING_DIR"
export REPO_URL=${REPO_URL:-"https://github.com/redhat-developer/odo.git"}
# Extract from rpm file
rpm2cpio ${1} | cpio -idmvD $WORKING_DIR
pushd $WORKING_DIR/usr/share/odo-redistributable/
# Check sha256sum for all the files
while IFS= read -r line; do
read -r SHA FILE <<<"$line"
read -r SHATOCHECK FILE <<<$(sha256sum $FILE)
if [[ $SHA == $SHATOCHECK ]]; then
# Print if the file is correct
printf '%-50s\U0002705\n' $FILE
fi
done <SHA256_SUM
shout
# Copy binary for testing purpose
OS=$(uname -s)
ARCH=$(uname -m)
if [[ $OS == "Linux" ]]; then
if [[ $ARCH == "x86_64" ]]; then
cp ./odo-linux-amd64 odo
PATH=$(pwd):$PATH
fi
fi
# Check odo verion and if it is correct
VERSION=$(cat VERSION)
ODOVERSIONCHECK=$(odo version)
if [[ "$ODOVERSIONCHECK" == *"$VERSION"* ]]; then
echo "odo binary is installed correctly"
else
echo "odo binary is not installed correctly"
exit 1
fi
#clone repo for testing and checkout release tag
pushd $WORKING_DIR
if [ -d "odo" ]; then
rm -rf odo
fi
git clone $REPO_URL odo && cd $WORKING_DIR/odo && git checkout "v$VERSION"
#Run tests
make test-e2e
# Cleanup
rm -rf "$WORKING_DIR"