Skip to content

Commit 6f6fc39

Browse files
committed
fix(install): improve install scripts for unsupported platform
1 parent 6654979 commit 6f6fc39

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

scripts/install.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,15 @@ function Download($download_url, $platforms) {
189189
if ($auth_token) {
190190
$wc.Headers["Authorization"] = "Bearer $auth_token"
191191
}
192-
$wc.downloadFile($url, $dir_path)
192+
try {
193+
$wc.DownloadFile($url, $dir_path)
194+
} catch [System.Net.WebException] {
195+
$statusCode = [int]$_.Exception.Response.StatusCode
196+
if ($statusCode -eq 403) {
197+
throw "Error: No package available for your platform ($arch). Please contact [email protected] for assistance."
198+
}
199+
throw "Error: Failed to download $url. HTTP Status Code: $statusCode"
200+
}
193201

194202
Write-Verbose "Unpacking to $tmp"
195203

scripts/install.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,22 +1374,32 @@ downloader() {
13741374
else _dld='curl or wget' # to be used in error message of need_cmd
13751375
fi
13761376

1377+
SUCCESS=0
13771378
if [ "$1" = --check ]
13781379
then need_cmd "$_dld"
13791380
elif [ "$_dld" = curl ]; then
13801381
if [ -n "${AUTH_TOKEN:-}" ]; then
1381-
curl -sSfL --header "Authorization: Bearer ${AUTH_TOKEN}" "$1" -o "$2"
1382+
HTTP_STATUS=$(curl -sSfL --header "Authorization: Bearer ${AUTH_TOKEN}" "$1" -o "$2" -w "%{http_code}" 2> /dev/null)
1383+
SUCCESS=$?
13821384
else
1383-
curl -sSfL "$1" -o "$2"
1385+
HTTP_STATUS=$(curl -sSfL "$1" -o "$2" -w "%{http_code}" 2> /dev/null)
1386+
SUCCESS=$?
13841387
fi
13851388
elif [ "$_dld" = wget ]; then
13861389
if [ -n "${AUTH_TOKEN:-}" ]; then
1387-
wget --header "Authorization: Bearer ${AUTH_TOKEN}" "$1" -O "$2"
1390+
HTTP_STATUS=$(wget -NS --header "Authorization: Bearer ${AUTH_TOKEN}" "$1" -O "$2" 2>&1 | grep "HTTP/" | awk '{print $2}')
1391+
SUCCESS=$?
13881392
else
1389-
wget "$1" -O "$2"
1393+
HTTP_STATUS=$(wget -NS "$1" -O "$2" 2>&1 | grep "HTTP/" | awk '{print $2}')
1394+
SUCCESS=$?
13901395
fi
13911396
else err "Unknown downloader" # should not reach here
13921397
fi
1398+
1399+
if [ "$SUCCESS" -ne 0 ] || [ "$HTTP_STATUS" -eq 403 ]; then
1400+
say "Error: No package available for your platform ($2). Please contact [email protected] for assistance."
1401+
exit 1
1402+
fi
13931403
}
13941404

13951405
download_binary_and_run_installer "$@" || exit 1

0 commit comments

Comments
 (0)