@@ -67,9 +67,24 @@ if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then
6767 log " Additional build flags: $SWIFT_BUILD_FLAGS "
6868fi
6969
70+ # Detect package manager
71+ if command -v apt > /dev/null 2>&1 ; then
72+ INSTALL_PACKAGE_COMMAND=" apt update -q && apt install -yq"
73+ elif command -v dnf > /dev/null 2>&1 ; then
74+ INSTALL_PACKAGE_COMMAND=" dnf install -y"
75+ elif command -v yum > /dev/null 2>&1 ; then
76+ INSTALL_PACKAGE_COMMAND=" yum install -y"
77+ else
78+ fatal " No supported package manager found"
79+ fi
80+
81+ install_package () {
82+ eval " $INSTALL_PACKAGE_COMMAND $1 "
83+ }
84+
7085# Install dependencies
71- command -v curl > /dev/null || (apt update -q && apt install -yq curl)
72- command -v jq > /dev/null || (apt update -q && apt install -yq jq)
86+ command -v curl > /dev/null || install_package curl
87+ command -v jq > /dev/null || install_package jq
7388
7489SWIFT_API_INSTALL_ROOT=" https://www.swift.org/api/v1/install"
7590
@@ -289,8 +304,18 @@ initialize_os_info() {
289304 fi
290305
291306 log " ✅ Detected OS from /etc/os-release: ${os_id}${version_id} "
292- OS_NAME=" ${os_id}${version_id} "
293- OS_NAME_NO_DOT=" ${os_id} $( echo " $version_id " | tr -d ' .' ) "
307+ if [[ " $os_id " == " rhel" && " $version_id " == 9* ]]; then
308+ OS_NAME=" ubi9"
309+ OS_NAME_NO_DOT=" ubi9"
310+ elif [[ " $os_id " == " amzn" && " $version_id " == " 2" ]]; then
311+ OS_NAME=" amazonlinux2"
312+ OS_NAME_NO_DOT=" amazonlinux2"
313+ else
314+ # Ubuntu, Debian, Fedora
315+ OS_NAME=" ${os_id}${version_id} "
316+ OS_NAME_NO_DOT=" ${os_id} $( echo " $version_id " | tr -d ' .' ) "
317+ fi
318+ log " Using OS name: $OS_NAME "
294319
295320 local arch
296321 arch=$( uname -m)
@@ -335,6 +360,8 @@ download_and_verify() {
335360 rm -rf " $GNUPGHOME " " $temp_sig "
336361}
337362
363+ readonly EXIT_TOOLCHAIN_NOT_FOUND=44
364+
338365# Downloads and extracts the Swift toolchain for the given snapshot tag
339366#
340367# $1 (string): A snapshot tag, e.g. "swift-6.2-DEVELOPMENT-SNAPSHOT-2025-07-29-a"
@@ -362,7 +389,7 @@ download_and_extract_toolchain() {
362389 log " Toolchain not found: ${toolchain_filename} "
363390 log " Exiting workflow..."
364391 # Don't fail the workflow if we can't find the right toolchain
365- exit 0
392+ exit $EXIT_TOOLCHAIN_NOT_FOUND
366393 fi
367394
368395 # Create toolchain directory
@@ -412,6 +439,10 @@ if [[ "$INSTALL_STATIC" == true ]]; then
412439 log " Installing Swift toolchain to match static SDK snapshot: $STATIC_SDK_TAG "
413440 initialize_os_info
414441 SWIFT_EXECUTABLE_FOR_STATIC_SDK=$( download_and_extract_toolchain " $STATIC_SDK_TAG " )
442+ if [[ $? -eq $EXIT_TOOLCHAIN_NOT_FOUND ]]; then
443+ # Don't fail the workflow if we can't find the right toolchain
444+ exit 0
445+ fi
415446 fi
416447fi
417448
@@ -423,6 +454,10 @@ if [[ "$INSTALL_WASM" == true ]]; then
423454 log " Installing Swift toolchain to match Wasm SDK snapshot: $WASM_SDK_TAG "
424455 initialize_os_info
425456 SWIFT_EXECUTABLE_FOR_WASM_SDK=$( download_and_extract_toolchain " $WASM_SDK_TAG " )
457+ if [[ $? -eq $EXIT_TOOLCHAIN_NOT_FOUND ]]; then
458+ # Don't fail the workflow if we can't find the right toolchain
459+ exit 0
460+ fi
426461 fi
427462fi
428463
0 commit comments