From 109ac55b2aea35b48ebd09766e1c28ad77d6182c Mon Sep 17 00:00:00 2001 From: dormando Date: Wed, 19 Apr 2023 14:23:50 -0700 Subject: vendor: improve fetch script allow using a pre-existing tarball instead of fetching from github, and also test the sha before using it. --- vendor/fetch.sh | 25 +++++++++++++++++++++---- 1 file 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 -- cgit v1.2.1