@@ -26,63 +26,63 @@ public struct VersionsConfiguration: Sendable {
26
26
self . swiftVersion = swiftVersion
27
27
self . swiftBranch = swiftBranch ?? " swift- \( swiftVersion. lowercased ( ) ) "
28
28
self . lldVersion = lldVersion
29
- if case let . debian( debian) = linuxDistribution, debian. version == " 11 " {
30
- logger. warning (
31
- " Debian 11 selected but not officially supported by Swift, falling back on Ubuntu 20.04 toolchain... "
32
- )
33
- self . linuxDistribution = try . init( name: . ubuntu, version: " 20.04 " )
34
- } else {
35
- self . linuxDistribution = linuxDistribution
36
- }
29
+ self . linuxDistribution = linuxDistribution
37
30
self . linuxArchSuffix =
38
31
targetTriple. arch == . aarch64 ? " - \( Triple . Arch. aarch64. linuxConventionName) " : " "
32
+ self . logger = logger
39
33
}
40
34
41
35
let swiftVersion : String
42
36
let swiftBranch : String
43
37
let lldVersion : String
44
38
let linuxDistribution : LinuxDistribution
45
39
let linuxArchSuffix : String
40
+ private let logger : Logger
46
41
47
42
var swiftPlatform : String {
48
43
switch self . linuxDistribution {
49
44
case let . ubuntu( ubuntu) :
50
45
return " ubuntu \( ubuntu. version) \( self . linuxArchSuffix) "
51
46
case let . debian( debian) :
47
+ if debian. version == " 11 " {
48
+ logger. warning (
49
+ " Debian 11 selected but not officially supported by Swift, falling back on Ubuntu 20.04 toolchain... "
50
+ )
51
+ // Ubuntu 20.04 toolchain is binary compatible with Debian 11
52
+ return " ubuntu20.04 \( self . linuxArchSuffix) "
53
+ } else if self . swiftVersion. hasPrefix ( " 5.9 " ) || self . swiftVersion == " 5.10 " {
54
+ logger. warning (
55
+ " Debian 12 selected but not officially supported by Swift version, falling back on Ubuntu 22.04 toolchain... " ,
56
+ metadata: [ " swiftVersion " : . string( self . swiftVersion) ]
57
+ )
58
+ // Ubuntu 22.04 toolchain is binary compatible with Debian 12
59
+ return " ubuntu22.04 \( self . linuxArchSuffix) "
60
+ }
52
61
return " debian \( debian. version) \( self . linuxArchSuffix) "
53
62
case let . rhel( rhel) :
54
63
return " \( rhel. rawValue) \( self . linuxArchSuffix) "
55
64
}
56
65
}
57
66
58
67
func swiftDistributionName( platform: String ? = nil ) -> String {
59
- " swift- \( self . swiftVersion) - \( platform ?? self . swiftPlatform) "
68
+ return " swift- \( self . swiftVersion) - \( platform ?? self . swiftPlatform) "
60
69
}
61
70
62
71
func swiftDownloadURL(
63
72
subdirectory: String ? = nil ,
64
73
platform: String ? = nil ,
65
74
fileExtension: String = " tar.gz "
66
75
) -> URL {
67
- let computedSubdirectory : String
68
- switch self . linuxDistribution {
69
- case let . ubuntu( ubuntu) :
70
- computedSubdirectory =
71
- " ubuntu \( ubuntu. version. replacingOccurrences ( of: " . " , with: " " ) ) \( self . linuxArchSuffix) "
72
- case let . debian( debian) :
73
- computedSubdirectory =
74
- " debian \( debian. version. replacingOccurrences ( of: " . " , with: " " ) ) \( self . linuxArchSuffix) "
75
- case let . rhel( rhel) :
76
- computedSubdirectory = rhel. rawValue
77
- }
76
+ let computedPlatform = platform ?? self . swiftPlatform
77
+ let computedSubdirectory =
78
+ subdirectory ?? computedPlatform. replacingOccurrences ( of: " . " , with: " " )
78
79
79
80
return URL (
80
81
string: """
81
82
https://download.swift.org/ \(
82
83
self . swiftBranch
83
- ) / \(
84
- subdirectory ?? computedSubdirectory
85
- ) /swift- \( self . swiftVersion) / \( self . swiftDistributionName ( platform: platform) ) . \( fileExtension)
84
+ ) / \( computedSubdirectory) / \
85
+ swift- \( self . swiftVersion) / \( self . swiftDistributionName ( platform: computedPlatform) ) . \( fileExtension)
86
86
"""
87
87
) !
88
88
}
0 commit comments