summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-04-19 14:23:50 -0700
committerdormando <dormando@rydia.net>2023-04-19 14:23:50 -0700
commit109ac55b2aea35b48ebd09766e1c28ad77d6182c (patch)
treed01033a7725208bcd55156fefdd085b64586e5b0
parent6a27618a0b2112b6f773d82887cff5c5b55f6dd5 (diff)
downloadmemcached-109ac55b2aea35b48ebd09766e1c28ad77d6182c.tar.gz
vendor: improve fetch script
allow using a pre-existing tarball instead of fetching from github, and also test the sha before using it.
-rwxr-xr-xvendor/fetch.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/vendor/fetch.sh b/vendor/fetch.sh
index 2d54142..369bb62 100755
--- a/vendor/fetch.sh
+++ b/vendor/fetch.sh
@@ -1,5 +1,22 @@
#!/bin/sh
-HASH="44a55dee1d41c3ae92524df9f0dd8a747db79f04"
-wget https://github.com/memcached/memcached-vendor/archive/${HASH}.tar.gz
-tar -zxf ./${HASH}.tar.gz --strip-components=1
-rm ${HASH}.tar.gz
+GITHASH="44a55dee1d41c3ae92524df9f0dd8a747db79f04"
+SHA="8d79b8f096c68ed827743dfded55981f1c7f297d"
+FILE="${GITHASH}.tar.gz"
+
+if ! command -v shasum >/dev/null 2>&1; then
+ echo "missing command: shasum"
+ exit 1
+fi
+
+if [ ! -f "$FILE" ]; then
+ wget https://github.com/memcached/memcached-vendor/archive/$FILE
+fi
+
+hash=$(shasum "$FILE" | awk '{print $1}')
+if [ "$SHA" = "$hash" ]; then
+ tar -zxf ./$FILE --strip-components=1
+ rm $FILE
+else
+ echo "vendor file hash did not match"
+ exit 1
+fi