Skip to content

Commit

Permalink
Fix sha256sum issue on Windows
Browse files Browse the repository at this point in the history
git was automatically converting `\n` lineendings to `\r\n`, which
confused `sha256sum`. By declaring `.sha256` files as binary
`.gitattributes` we avoid this issue.
  • Loading branch information
aherrmann authored and mergify-bot committed Feb 25, 2020
1 parent 39b10c8 commit 2a297e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 1 addition & 14 deletions .ci/fetch-bazel-bindist
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@ esac
VERSION=$(cat "$TOP/.ci/bazelversion")
INSTALL="$(mktemp -d)"
(cd "$INSTALL" && curl -LO "https://github.com/bazelbuild/bazel/releases/download/$VERSION/bazel-$VERSION-$OS$EXT" >&2)
if [[ $OS = windows-x86_64 ]]; then
# sha256sum -c does not behave as expected on Windows. It produces
#
# sha256sum: /d/a/1/s/.ci/bazel-sha256: no file was verified
#
# even when the hashes match upon manual inspection.
SHA256="$(cd "$INSTALL" && sha256sum --text bazel-$VERSION-$OS$EXT)"
if ! grep -q "$SHA256" "$TOP/.ci/bazel-$VERSION-$OS$EXT.sha256" >&2; then
echo "sha256 mismatch (compare .ci/bazel-sha256): $SHA256" >&2
exit 1
fi
else
(cd "$INSTALL" && sha256sum --quiet -c "$TOP/.ci/bazel-$VERSION-$OS$EXT.sha256") >&2
fi
(cd "$INSTALL" && sha256sum --quiet -c "$TOP/.ci/bazel-$VERSION-$OS$EXT.sha256") >&2
mv "$INSTALL/bazel-$VERSION-$OS$EXT" "$INSTALL/bazel$EXT"
chmod +x "$INSTALL/bazel$EXT"
echo -n "$INSTALL"
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Prevent git from automatically introducing \r characters in .sha256 files.
# Otherwise msys sha256sum fails.
*.sha256 binary

0 comments on commit 2a297e7

Please sign in to comment.