Skip to content

Commit a85ea6c

Browse files
sondavidbaustinvazquez
authored andcommitted
Fine-tune shell scripts
Added some modularity in our installation scripts by moving versions into their own variable. Also added an integrity check for cmake, as well as TODO comments for the other scripts. Signed-off-by: David Son <[email protected]>
1 parent 373be7f commit a85ea6c

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

scripts/install-dep.sh

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,72 @@ set -eux -o pipefail
2222
TMPDIR=$(mktemp -d)
2323
pushd "${TMPDIR}"
2424

25+
arch="$(uname -m)"
26+
2527
# install cmake
28+
cmake_ver="3.24.1"
2629
if ! command -v cmake &> /dev/null
2730
then
28-
wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-Linux-x86_64.sh -O cmake.sh
31+
wget https://github.com/Kitware/CMake/releases/download/v"${cmake_ver}"/cmake-"${cmake_ver}"-Linux-"${arch}".sh -O cmake.sh
32+
wget https://github.com/Kitware/CMake/releases/download/v"${cmake_ver}"/cmake-"${cmake_ver}"-SHA-256.txt -O shasums.txt
33+
34+
# Verify integrity
35+
36+
# The sha256sum will come in the format like the following:
37+
# sha256hash filename
38+
# Since we rename the script for convenience purposes,
39+
# we only want to compare hashes to verify file integrity.
40+
cmake_expected_shasum="$(grep "${arch}".sh < shasums.txt | awk '{print $1}')"
41+
cmake_actual_shasum="$(sha256sum cmake.sh | awk '{print $1}')"
42+
if [ "${cmake_expected_shasum}" != "${cmake_actual_shasum}" ]
43+
then
44+
echo "error: cmake sha256sum did not match"
45+
exit 1
46+
fi
47+
2948
sh cmake.sh --prefix=/usr/local/ --exclude-subdir
3049
rm -rf cmake.sh
3150
else
3251
echo "cmake is installed, skip..."
3352
fi
3453

3554
# install flatc
55+
flatc_ver="2.0.8"
56+
flatc_expected_shasum="f97965a727d26386afaefff950badef2db3ab6af9afe23ed6d94bfb65f95f37e"
3657
if ! command -v flatc &> /dev/null
3758
then
38-
wget https://github.com/google/flatbuffers/archive/refs/tags/v2.0.8.tar.gz -O flatbuffers.tar.gz
59+
wget https://github.com/google/flatbuffers/archive/refs/tags/v"${flatc_ver}".tar.gz -O flatbuffers.tar.gz
60+
61+
flatc_actual_shasum="$(sha256sum flatbuffers.tar.gz | awk '{print $1}')"
62+
if [ "${flatc_expected_shasum}" != "${flatc_actual_shasum}" ]
63+
then
64+
echo "error: flatc sha256sum did not match"
65+
exit 1
66+
fi
67+
3968
tar xzvf flatbuffers.tar.gz
40-
cd flatbuffers-2.0.8 && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && make && sudo make install && cd ..
69+
cd flatbuffers-"${flatc_ver}" && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && make && sudo make install && cd ..
4170
rm -f flatbuffers.tar.gz
42-
rm -rf flatbuffers-2.0.8
71+
rm -rf flatbuffers-"${flatc_ver}"
4372
else
4473
echo "flatc is installed, skip..."
4574
fi
4675

4776
# install-zlib
48-
wget https://zlib.net/fossils/zlib-1.2.12.tar.gz
49-
tar xzvf zlib-1.2.12.tar.gz
50-
cd zlib-1.2.12 && ./configure && sudo make install && cd ..
51-
rm -rf zlib-1.2.12
52-
rm -f zlib-1.2.12.tar.gz
77+
zlib_ver="1.2.12"
78+
zlib_expected_shasum="91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9"
79+
80+
wget https://zlib.net/fossils/zlib-"${zlib_ver}".tar.gz -O zlib.tar.gz
81+
zmake_actual_shasum="$(sha256sum zlib.tar.gz | awk '{print $1}')"
82+
if [ "${zlib_expected_shasum}" != "${zmake_actual_shasum}" ]
83+
then
84+
echo "error: zmake sha256sum did not match"
85+
exit 1
86+
fi
87+
88+
tar xzvf zlib.tar.gz
89+
cd zlib-"${zlib_ver}" && ./configure && sudo make install && cd ..
90+
rm -rf zlib-"${zlib_ver}"
91+
rm -f zlib.tar.gz
5392

5493
popd

0 commit comments

Comments
 (0)