Skip to content

use Ubuntu 22.04 artifact on Ubuntu 24.04 #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions Sources/SwiftToolchain/ToolchainManagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public class ToolchainSystem {
#if os(macOS)
let platformSuffixes = ["osx", "catalina", "macos"]
#elseif os(Linux)
let platformSuffixes = ["linux", try self.inferLinuxDistributionSuffix()]
let platformSuffixes = ["linux", try self.inferLinuxAssetSuffix()]
#endif

terminal.logLookup(
Expand All @@ -227,7 +227,7 @@ public class ToolchainSystem {
}.first
}

private func inferLinuxDistributionSuffix() throws -> String {
private func inferLinuxAssetSuffix() throws -> String {
guard
let releaseFile = [
URL(fileURLWithPath: "/etc/lsb-release"),
Expand All @@ -237,18 +237,32 @@ public class ToolchainSystem {
throw ToolchainError.unsupportedOperatingSystem
}

let releaseData = try String(contentsOf: releaseFile)
if releaseData.contains("DISTRIB_RELEASE=18.04") {
return "ubuntu18.04"
} else if releaseData.contains("DISTRIB_RELEASE=20.04") {
return "ubuntu20.04"
} else if releaseData.contains("DISTRIB_RELEASE=22.04") {
return "ubuntu22.04"
} else if releaseData.contains(#"PRETTY_NAME="Amazon Linux 2""#) {
let releaseData = try String(contentsOf: releaseFile).split(whereSeparator: \.isNewline)
if releaseData.contains(#"PRETTY_NAME="Amazon Linux 2""#) {
return "amazonlinux2"
} else {
} else if releaseData.contains("DISTRIB_ID=Ubuntu") {
for line in releaseData {
if let equals = line.firstIndex(of: "="),
case "DISTRIB_RELEASE" = line[..<equals]
{
let number = line[line.index(after: equals)...]
switch number {
case "18.04":
return "ubuntu18.04"
case "20.04":
return "ubuntu20.04"
case "22.04":
return "ubuntu22.04"
case "24.04":
return "ubuntu22.04"
default:
throw ToolchainError.unsupportedOperatingSystem
}
}
}
}

throw ToolchainError.unsupportedOperatingSystem
}

public struct SwiftPath {
Expand Down