@@ -15,7 +15,6 @@ hasPython2=$?
1515DISTRIBUTION=" debian"
1616CODENAME=" bullseye"
1717ARCHITECTURE=" "
18- WITH_QT5=false
1918
2019BASE_PATH=' .'
2120
3534 exit 1
3635fi
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
5489done
5590shift $(( OPTIND - 1 ))
@@ -103,19 +138,7 @@ if [ $? -ne 0 ]; then
103138 exit 1
104139else
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 "
119142fi
120143
121144# Determine if PR number exists
0 commit comments