[ubuntu] Fix error message redirection in install.sh (#9324)

This commit is contained in:
Shamil Mubarakshin
2024-02-15 18:55:11 +01:00
committed by GitHub
parent deba4d6cd5
commit ca82d0a325

View File

@@ -63,7 +63,7 @@ get_github_releases_by_version() {
json=$(curl -fsSL "https://api.github.com/repos/${repo}/releases?per_page=${page_size}") json=$(curl -fsSL "https://api.github.com/repos/${repo}/releases?per_page=${page_size}")
if [[ -z "$json" ]]; then if [[ -z "$json" ]]; then
echo "Failed to get releases" echo "Failed to get releases" >&2
exit 1 exit 1
fi fi
@@ -92,8 +92,8 @@ get_github_releases_by_version() {
fi fi
if [[ -z "$json_filtered" ]]; then if [[ -z "$json_filtered" ]]; then
echo "Failed to get releases from ${repo} matching version ${version}" echo "Failed to get releases from ${repo} matching version ${version}" >&2
echo "Available versions: $(echo "$json" | jq -r '.tag_name')" echo "Available versions: $(echo "$json" | jq -r '.tag_name')" >&2
exit 1 exit 1
fi fi
@@ -111,8 +111,8 @@ resolve_github_release_asset_url() {
matched_url=$(echo $matching_releases | jq -r ".assets[].browser_download_url | select(${url_filter})") matched_url=$(echo $matching_releases | jq -r ".assets[].browser_download_url | select(${url_filter})")
if [[ -z "$matched_url" ]]; then if [[ -z "$matched_url" ]]; then
echo "Found no download urls matching pattern: ${url_filter}" echo "Found no download urls matching pattern: ${url_filter}" >&2
echo "Available download urls: $(echo "$matching_releases" | jq -r '.assets[].browser_download_url')" echo "Available download urls: $(echo "$matching_releases" | jq -r '.assets[].browser_download_url')" >&2
exit 1 exit 1
fi fi
@@ -120,7 +120,7 @@ resolve_github_release_asset_url() {
if [[ $allow_multiple_matches == "true" ]]; then if [[ $allow_multiple_matches == "true" ]]; then
matched_url=$(echo "$matched_url" | tail -n 1) matched_url=$(echo "$matched_url" | tail -n 1)
else else
echo "Multiple matches found for ${version} version and ${url_filter} URL filter. Please make filters more specific" echo "Multiple matches found for ${version} version and ${url_filter} URL filter. Please make filters more specific" >&2
exit 1 exit 1
fi fi
fi fi
@@ -136,7 +136,7 @@ get_checksum_from_github_release() {
local allow_pre_release=${5:-false} local allow_pre_release=${5:-false}
if [[ -z "$file_name" ]]; then if [[ -z "$file_name" ]]; then
echo "File name is not specified." echo "File name is not specified." >&2
exit 1 exit 1
fi fi
@@ -145,7 +145,7 @@ get_checksum_from_github_release() {
elif [[ "$hash_type" == "SHA512" ]]; then elif [[ "$hash_type" == "SHA512" ]]; then
hash_pattern="[A-Fa-f0-9]{128}" hash_pattern="[A-Fa-f0-9]{128}"
else else
echo "Unknown hash type: ${hash_type}" echo "Unknown hash type: ${hash_type}" >&2
exit 1 exit 1
fi fi
@@ -153,19 +153,19 @@ get_checksum_from_github_release() {
matched_line=$(printf "$(echo $matching_releases | jq '.body')\n" | grep "$file_name") matched_line=$(printf "$(echo $matching_releases | jq '.body')\n" | grep "$file_name")
if [[ -z "$matched_line" ]]; then if [[ -z "$matched_line" ]]; then
echo "File name ${file_name} not found in release body" echo "File name ${file_name} not found in release body" >&2
exit 1 exit 1
fi fi
if [[ "$(echo "$matched_line" | wc -l)" -gt 1 ]]; then if [[ "$(echo "$matched_line" | wc -l)" -gt 1 ]]; then
echo "Multiple matches found for ${file_name} in release body: ${matched_line}" echo "Multiple matches found for ${file_name} in release body: ${matched_line}" >&2
exit 1 exit 1
fi fi
hash=$(echo $matched_line | grep -oP "$hash_pattern") hash=$(echo $matched_line | grep -oP "$hash_pattern")
if [[ -z "$hash" ]]; then if [[ -z "$hash" ]]; then
echo "Found ${file_name} in body of release, but failed to get hash from it: ${matched_line}" echo "Found ${file_name} in body of release, but failed to get hash from it: ${matched_line}" >&2
exit 1 exit 1
fi fi
@@ -185,7 +185,7 @@ get_checksum_from_url() {
elif [[ "$hash_type" == "SHA512" ]]; then elif [[ "$hash_type" == "SHA512" ]]; then
hash_pattern="[A-Fa-f0-9]{128}" hash_pattern="[A-Fa-f0-9]{128}"
else else
echo "Unknown hash type: ${hash_type}" echo "Unknown hash type: ${hash_type}" >&2
exit 1 exit 1
fi fi
@@ -196,12 +196,12 @@ get_checksum_from_url() {
matched_line=$(printf "$checksums\n" | grep "$file_name") matched_line=$(printf "$checksums\n" | grep "$file_name")
if [[ "$(echo "$matched_line" | wc -l)" -gt 1 ]]; then if [[ "$(echo "$matched_line" | wc -l)" -gt 1 ]]; then
echo "Found multiple lines matching file name ${file_name} in checksum file." echo "Found multiple lines matching file name ${file_name} in checksum file." >&2
exit 1 exit 1
fi fi
if [[ -z "$matched_line" ]]; then if [[ -z "$matched_line" ]]; then
echo "File name ${file_name} not found in checksum file." echo "File name ${file_name} not found in checksum file." >&2
exit 1 exit 1
fi fi
@@ -212,7 +212,7 @@ get_checksum_from_url() {
fi fi
if [[ -z "$hash" ]]; then if [[ -z "$hash" ]]; then
echo "Found ${file_name} in checksum file, but failed to get hash from it: ${matched_line}" echo "Found ${file_name} in checksum file, but failed to get hash from it: ${matched_line}" >&2
exit 1 exit 1
fi fi