Skip to content

Commit c5eaf98

Browse files
committed
Align install_pr script working with default Qt6 builds & show authentication failures (#1871)
1 parent 0e31904 commit c5eaf98

File tree

2 files changed

+49
-19
lines changed

2 files changed

+49
-19
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### ⚠️ Breaking Changes
1010

11+
---
12+
1113
### ✨ Added
1214

15+
---
16+
1317
### 🔧 Changed
1418

1519
- **Fixes:**
1620
- WebUI unreachable via IPv6 (#1871)
21+
- Align install_pr script working with default Qt6 builds & show authentication failures (#1871)
22+
23+
---
1724

1825
### 🗑️ Removed
1926

bin/scripts/install_pr.sh

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ hasPython2=$?
1515
DISTRIBUTION="debian"
1616
CODENAME="bullseye"
1717
ARCHITECTURE=""
18-
WITH_QT5=false
1918

2019
BASE_PATH='.'
2120

@@ -35,21 +34,57 @@ else
3534
exit 1
3635
fi
3736

38-
function request_call() {
37+
request_call() {
38+
local url="$1"
39+
local response body status_code
40+
3941
if [ $hasWget -eq 0 ]; then
40-
echo $(wget --quiet --header="Authorization: token ${PR_TOKEN}" -O - $1)
42+
# Use a temp file to store headers
43+
local headers_file=$(mktemp)
44+
body=$(wget --quiet --server-response --header="Authorization: token ${PR_TOKEN}" -O - "$url" 2> "$headers_file")
45+
status_code=$(awk '/^ HTTP/{code=$2} END{print code}' "$headers_file")
46+
rm -f "$headers_file"
47+
4148
elif [ $hasCurl -eq 0 ]; then
42-
echo $(curl -skH "Authorization: token ${PR_TOKEN}" $1)
49+
# Append status code at the end of the response
50+
response=$(curl -sk -w "\n%{http_code}" -H "Authorization: token ${PR_TOKEN}" "$url")
51+
body=$(echo "$response" | sed '$d') # All but last line
52+
status_code=$(echo "$response" | tail -n1) # Last line = status code
53+
else
54+
echo "---> Neither wget nor curl is available." >&2
55+
exit 1
4356
fi
57+
58+
# Handle common HTTP errors
59+
case "$status_code" in
60+
401)
61+
echo "---> Error: 401 Unauthorized. Check your token." >&2
62+
exit 1
63+
;;
64+
403)
65+
echo "---> Error: 403 Forbidden. You might be rate-limited or lack permissions." >&2
66+
exit 1
67+
;;
68+
404)
69+
echo "---> Error: 404 Not Found. URL is incorrect or resource doesn't exist." >&2
70+
exit 1
71+
;;
72+
5*)
73+
echo "---> Error: Server error ($status_code). Try again later." >&2
74+
exit 1
75+
;;
76+
esac
77+
78+
# Success: print response body
79+
echo "$body"
4480
}
4581

46-
while getopts ":a:c:r:t:5" opt; do
82+
while getopts ":a:c:r:t:" opt; do
4783
case "$opt" in
4884
a) ARCHITECTURE=$OPTARG ;;
4985
c) CONFIGDIR=$OPTARG ;;
5086
r) run_id=$OPTARG ;;
5187
t) PR_TOKEN=$OPTARG ;;
52-
5) WITH_QT5=true ;;
5388
esac
5489
done
5590
shift $((OPTIND - 1))
@@ -103,19 +138,7 @@ if [ $? -ne 0 ]; then
103138
exit 1
104139
else
105140
PACKAGE="${ARCHITECTURE}"
106-
107-
# armv6 has no Qt6 support yet
108-
if [[ "${PACKAGE}" == "armv6" ]]; then
109-
WITH_QT5=true
110-
fi
111-
112-
QTVERSION="5"
113-
if [ ${WITH_QT5} == false ]; then
114-
QTVERSION="6"
115-
PACKAGE="${PACKAGE}_qt6"
116-
fi
117-
118-
echo "---> Download package for identified runtime architecture: $ARCHITECTURE and Qt$QTVERSION"
141+
echo "---> Download package for identified runtime architecture: $ARCHITECTURE"
119142
fi
120143

121144
# Determine if PR number exists

0 commit comments

Comments
 (0)