Skip to content

Commit

Permalink
add version check (#332)
Browse files Browse the repository at this point in the history
#### What this PR does / why we need it:
add version check to be able to install versions < 0.15.0
  • Loading branch information
morri-son authored Oct 2, 2024
1 parent 909d213 commit 75000f7
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions static/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,22 @@ vercomp () {

# Download hash from Github URL
download_hash() {
HASH_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION_OCM}/ocm-${VERSION_OCM}-${OS}-${ARCH}.tar.gz.sha256"
info "Downloading hash ${HASH_URL}"
download "${TMP_HASH}" "${HASH_URL}"
info "ocm-${OS}-${ARCH}.tar.gz"
HASH_EXPECTED=$(cat "${TMP_HASH}")
HASH_EXPECTED=${HASH_EXPECTED%%[[:blank:]]*}
# check for versions < 0.15.0
if [ "$(printf '%s\n' "0.15.0" "$VERSION_OCM" | sort -V | head -n1)" = "$VERSION_OCM" ] && [ "$VERSION_OCM" != "0.15.0" ]; then
HASH_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION_OCM}/ocm_${VERSION_OCM}_checksums.txt"
info "Downloading hash ${HASH_URL}"
download "${TMP_HASH}" "${HASH_URL}"
info "ocm-${OS}-${ARCH}.tar.gz"
HASH_EXPECTED=$(grep " ocm-${VERSION_OCM}-${OS}-${ARCH}.tar.gz$" "${TMP_HASH}")
HASH_EXPECTED=${HASH_EXPECTED%%[[:blank:]]*}
else
HASH_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION_OCM}/ocm-${VERSION_OCM}-${OS}-${ARCH}.tar.gz.sha256"
info "Downloading hash ${HASH_URL}"
download "${TMP_HASH}" "${HASH_URL}"
info "ocm-${OS}-${ARCH}.tar.gz"
HASH_EXPECTED=$(cat "${TMP_HASH}")
HASH_EXPECTED=${HASH_EXPECTED%%[[:blank:]]*}
fi
}

# Download binary from Github URL
Expand Down

0 comments on commit 75000f7

Please sign in to comment.