Fallback on source code build when no binary available (#207)

This commit is contained in:
Pascal Martel 2021-10-29 21:40:13 -04:00 committed by GitHub
parent 794b653b2a
commit 1bc55cb601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,10 +36,24 @@ install_canon_version() {
local archive_path
archive_path="${tmp_download_dir}/$(get_archive_file_name "$install_type" "$version")"
download_file "$(get_download_url "$install_type" "$version")" "${archive_path}" \
|| die "Binary not found for version $version"
verify_archive "$tmp_download_dir"
local download_result=0
download_file "$(get_download_url "$install_type" "$version")" "${archive_path}" \
|| download_result=$?
if [ $download_result != 0 ]; then
if [ "$install_type" = "ref" ]; then
die "Source code not found for version $version"
fi
echo "Binary not found for version $version. Falling back to source code"
install_type="ref"
download_file "$(get_download_url "$install_type" "$version")" "${archive_path}" \
|| die "Source code not found for version $version"
else
verify_archive "$tmp_download_dir"
fi
# running this in a subshell
# we don't want to disturb current working dir
@ -66,7 +80,6 @@ install_canon_version() {
)
}
install_aliased_version() {
local version=$1
local version_query=$2
@ -146,7 +159,7 @@ download_file() {
local download_url="$1"
local download_path="$2"
STATUSCODE=$(curl --write-out "%{http_code}" -Lo "$download_path" -C - "$download_url")
STATUSCODE=$(curl --write-out "%{http_code}" -Lo "$download_path" "$download_url")
if test $STATUSCODE -eq 404; then
return 1
@ -163,7 +176,7 @@ get_archive_file_name() {
if [ "$install_type" = "version" ]; then
pkg_name="node-v${version}-$(uname -s | tr '[:upper:]' '[:lower:]')-$(get_nodejs_machine_hardware_name)"
else
pkg_name="${version}"
pkg_name="v${version}"
fi
echo "${pkg_name}.tar.gz"