Skip to content

Commit

Permalink
Fix checksum verification
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Apr 26, 2024
1 parent 6fb0be6 commit e4e9581
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions install-ninja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,30 @@ if ! $wget -q "https://github.com/ninja-build/ninja/releases/download/v1.12.0/$f
exit 2
fi

# We do our own SHA512 check as on Windows it looks like sha512sum
# --check is not working.
expected=$(cat checksums.txt | grep $filename | cut -d ' ' -f 1)
actual=$($checksum $filename | cut -d ' ' -f 1)
echo expected SHA512 $expected $filename
echo actual SHA512 $actual $filename
if [[ "$expected" == "" || "$actual" == "" || "$expected" != "$actual" ]] ; then
echo "Invalid SHA512 checksum"
exit 3
fi
echo GITHUB_ACTION_PATH = $GITHUB_ACTION_PATH
echo pwd = $(pwd)

if [ "$RUNNER_OS" != "Windows" ]; then
# We do our own SHA512 check on Windows as it looks like sha512sum
# --check is not working when running from get-ninja actions.
if [ "$GITHUB_ACTION_PATH" == $(pwd) ] ; then
expected=$(cat checksums.txt | grep $filename | cut -d ' ' -f 1)
actual=$($checksum $filename | cut -d ' ' -f 1)
echo expected SHA512 $expected $filename
echo actual SHA512 $actual $filename
if [[ "$expected" == "" || "$actual" == "" || "$expected" != "$actual" ]] ; then
echo "Invalid SHA512 checksum"
exit 3
fi
if [ "$RUNNER_OS" != "Windows" ]; then
if ! $checksum --ignore-missing --check $GITHUB_ACTION_PATH/checksums.txt ; then
echo "Invalid SHA512 checksum"
exit 4
fi
fi
else
if ! $checksum --ignore-missing --check $GITHUB_ACTION_PATH/checksums.txt ; then
echo "Invalid SHA512 checksum"
exit 4
exit 5
fi
fi

Expand Down

0 comments on commit e4e9581

Please sign in to comment.