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 7432a47
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions install-ninja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ 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 = $(cygpath -u $GITHUB_ACTION_PATH)
echo pwd = $(pwd)

if [ "$RUNNER_OS" != "Windows" ]; then
# We do our own SHA512 check on Windows when running get-ninja
# actions, as it looks like sha512sum --check is not working in that
# specific case.
if [[ "$RUNNER_OS" == "Windows" && $(cygpath -u $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
else
if ! $checksum --ignore-missing --check $GITHUB_ACTION_PATH/checksums.txt ; then
echo "Invalid SHA512 checksum"
exit 4
Expand Down

0 comments on commit 7432a47

Please sign in to comment.