@@ -73,9 +73,24 @@ if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then
7373 log " Additional build flags: $SWIFT_BUILD_FLAGS "
7474fi
7575
76+ # Detect package manager
77+ if command -v apt > /dev/null 2>&1 ; then
78+ INSTALL_PACKAGE_COMMAND=" apt update -q && apt install -yq"
79+ elif command -v dnf > /dev/null 2>&1 ; then
80+ INSTALL_PACKAGE_COMMAND=" dnf install -y"
81+ elif command -v yum > /dev/null 2>&1 ; then
82+ INSTALL_PACKAGE_COMMAND=" yum install -y"
83+ else
84+ fatal " No supported package manager found"
85+ fi
86+
87+ install_package () {
88+ eval " $INSTALL_PACKAGE_COMMAND $1 "
89+ }
90+
7691# Install dependencies
77- command -v curl > /dev/null || (apt update -q && apt install -yq curl)
78- command -v jq > /dev/null || (apt update -q && apt install -yq jq)
92+ command -v curl > /dev/null || install_package curl
93+ command -v jq > /dev/null || install_package jq
7994
8095SWIFT_API_INSTALL_ROOT=" https://www.swift.org/api/v1/install"
8196
@@ -295,8 +310,18 @@ initialize_os_info() {
295310 fi
296311
297312 log " ✅ Detected OS from /etc/os-release: ${os_id}${version_id} "
298- OS_NAME=" ${os_id}${version_id} "
299- OS_NAME_NO_DOT=" ${os_id} $( echo " $version_id " | tr -d ' .' ) "
313+ if [[ " $os_id " == " rhel" && " $version_id " == 9* ]]; then
314+ OS_NAME=" ubi9"
315+ OS_NAME_NO_DOT=" ubi9"
316+ elif [[ " $os_id " == " amzn" && " $version_id " == " 2" ]]; then
317+ OS_NAME=" amazonlinux2"
318+ OS_NAME_NO_DOT=" amazonlinux2"
319+ else
320+ # Ubuntu, Debian, Fedora
321+ OS_NAME=" ${os_id}${version_id} "
322+ OS_NAME_NO_DOT=" ${os_id} $( echo " $version_id " | tr -d ' .' ) "
323+ fi
324+ log " Using OS name: $OS_NAME "
300325
301326 local arch
302327 arch=$( uname -m)
@@ -341,6 +366,8 @@ download_and_verify() {
341366 rm -rf " $GNUPGHOME " " $temp_sig "
342367}
343368
369+ readonly EXIT_TOOLCHAIN_NOT_FOUND=44
370+
344371# Downloads and extracts the Swift toolchain for the given snapshot tag
345372#
346373# $1 (string): A snapshot tag, e.g. "swift-6.2-DEVELOPMENT-SNAPSHOT-2025-07-29-a"
@@ -368,7 +395,7 @@ download_and_extract_toolchain() {
368395 log " Toolchain not found: ${toolchain_filename} "
369396 log " Exiting workflow..."
370397 # Don't fail the workflow if we can't find the right toolchain
371- exit 0
398+ exit $EXIT_TOOLCHAIN_NOT_FOUND
372399 fi
373400
374401 # Create toolchain directory
@@ -418,6 +445,10 @@ if [[ "$INSTALL_STATIC_LINUX" == true ]]; then
418445 log " Installing Swift toolchain to match Static Linux Swift SDK snapshot: $STATIC_LINUX_SDK_TAG "
419446 initialize_os_info
420447 SWIFT_EXECUTABLE_FOR_STATIC_LINUX_SDK=$( download_and_extract_toolchain " $STATIC_LINUX_SDK_TAG " )
448+ if [[ $? -eq $EXIT_TOOLCHAIN_NOT_FOUND ]]; then
449+ # Don't fail the workflow if we can't find the right toolchain
450+ exit 0
451+ fi
421452 fi
422453fi
423454
@@ -429,6 +460,10 @@ if [[ "$INSTALL_WASM" == true ]]; then
429460 log " Installing Swift toolchain to match Wasm Swift SDK snapshot: $WASM_SDK_TAG "
430461 initialize_os_info
431462 SWIFT_EXECUTABLE_FOR_WASM_SDK=$( download_and_extract_toolchain " $WASM_SDK_TAG " )
463+ if [[ $? -eq $EXIT_TOOLCHAIN_NOT_FOUND ]]; then
464+ # Don't fail the workflow if we can't find the right toolchain
465+ exit 0
466+ fi
432467 fi
433468fi
434469
0 commit comments