Check shasum/sha256sum in PATH on install script (#1108)
* Check shasum/sha256sum in PATH on install script * Fix typo in .github/pull_request_template.md
This commit is contained in:
parent
1c217a7157
commit
4ed7cd5aea
2 changed files with 14 additions and 2 deletions
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
|
|
@ -2,7 +2,7 @@ Please answer the following questions and leave the below in as part of your PR.
|
|||
|
||||
- [ ] I have read the [developer documentation](https://github.com/babashka/babashka/blob/master/doc/dev.md).
|
||||
|
||||
- [ ] This PR correponds to an [issue with a clear problem statement](https://github.com/babashka/babashka/blob/master/doc/dev.md#start-with-an-issue-before-writing-code).
|
||||
- [ ] This PR corresponds to an [issue with a clear problem statement](https://github.com/babashka/babashka/blob/master/doc/dev.md#start-with-an-issue-before-writing-code).
|
||||
|
||||
- [ ] This PR contains a [test](https://github.com/babashka/babashka/blob/master/doc/dev.md#tests) to prevent against future regressions
|
||||
|
||||
|
|
|
|||
14
install
14
install
|
|
@ -111,6 +111,18 @@ esac
|
|||
|
||||
download_url="https://github.com/babashka/babashka/releases/download/v$version/$filename"
|
||||
|
||||
# macOS only have shasum available by default
|
||||
# Some Linux distros (RHEL-like) only have sha256sum avaiable by default (others have both)
|
||||
if command -v sha256sum >/dev/null; then
|
||||
sha256sum_cmd="sha256sum"
|
||||
elif command -v shasum >/dev/null; then
|
||||
sha256sum_cmd="shasum -a 256"
|
||||
else
|
||||
>&2 echo "Either 'sha256sum' or 'shasum' needs to be on PATH for '--checksum' flag!"
|
||||
>&2 echo "Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Running this part in a subshell so when it finishes we go back to the previous directory
|
||||
mkdir -p "$download_dir" && (
|
||||
cd "$download_dir"
|
||||
|
|
@ -118,7 +130,7 @@ mkdir -p "$download_dir" && (
|
|||
|
||||
curl -o "$filename" -sL "$download_url"
|
||||
if [[ -n "$checksum" ]]; then
|
||||
if ! echo "$checksum *$filename" | shasum -a 256 --check --status; then
|
||||
if ! echo "$checksum *$filename" | $sha256sum_cmd --check --status; then
|
||||
>&2 echo "Failed checksum on $filename"
|
||||
>&2 echo "Got: $(shasum -a 256 "$filename" | cut -d' ' -f1)"
|
||||
>&2 echo "Expected: $checksum"
|
||||
|
|
|
|||
Loading…
Reference in a new issue