web.sh: add alternative shasum command (perl)

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2024-02-18 10:11:25 +03:00
parent c31f86b104
commit beb4b46caf
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C

23
web.sh Normal file → Executable file
View file

@ -19,9 +19,24 @@ requireCommands() {
done done
} }
requireCommands uname sha256sum cut dd chmod rm realpath expr requireCommands uname cut dd chmod rm realpath expr
if [ "$(realpath $(command -v sha256sum))" = "/bin/busybox" ]; then # Finding alternative, but supported sha256sums
SHA256SUM=""
if command -v sha256sum &> /dev/null; then
export SHA256SUM="sha256sum"
else
if command -v shasum &> /dev/null; then
SHASUMVER=$(shasum -v | cut -c 1)
if [ $SHASUMVER -ge 6 ]; then
export SHA256SUM="shasum -a 256"
fi
else
fail "Could not find sha256sum executable"
fi
fi
if [ "$(realpath $SHA256SUM)" = "/bin/busybox" ]; then
fail "Busybox sha256sum detected, will not work. Refusing to continue" fail "Busybox sha256sum detected, will not work. Refusing to continue"
fi fi
@ -60,7 +75,7 @@ cd $DIR
print ":: Downloading manifest" print ":: Downloading manifest"
$DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/manifest $OUTPUT_ARG manifest $DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/manifest $OUTPUT_ARG manifest
MANIFEST_HASHSUM=$(sha256sum manifest) MANIFEST_HASHSUM=$($SHA256SUM manifest)
if [ ! -z $KEY ]; then if [ ! -z $KEY ]; then
if [ ! $KEY = "$(echo $MANIFEST_HASHSUM | cut -c 1-${#KEY})" ]; then if [ ! $KEY = "$(echo $MANIFEST_HASHSUM | cut -c 1-${#KEY})" ]; then
@ -80,7 +95,7 @@ print ":: Downloading runner"
$DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/runner-$PLATFORM-$ARCH $OUTPUT_ARG "runner-$PLATFORM-$ARCH" $DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/runner-$PLATFORM-$ARCH $OUTPUT_ARG "runner-$PLATFORM-$ARCH"
if ! sha256sum -c hashes --ignore-missing; then if ! $SHA256SUM -c hashes --ignore-missing >&2 ; then
fail "Incorrect hashsum of runner" fail "Incorrect hashsum of runner"
fi fi