Skip to content
Draft
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions Sources/LinuxPlatform/Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct Linux: Platform {
.rhel9,
.amazonlinux2,
.debian12,
.gentoo,
]

public init() {}
Expand Down Expand Up @@ -227,6 +228,25 @@ public struct Linux: Platform {
"gcc",
"libstdc++-12-dev",
]
case "gentoo":
[
"dev-vcs/git",
"app-arch/unzip",
"app-crypt/gnupg",
"net-misc/curl",
"dev-libs/libxml2",
"sys-libs/readline",
"dev-db/sqlite",
"sys-devel/binutils",
"sys-devel/gcc",
"sys-libs/glibc",
"dev-lang/python",
"sys-apps/util-linux",
"sys-libs/zlib",
"sys-libs/ncurses",
"dev-libs/icu",
"dev-util/pkgconf",
]
default:
[]
}
Expand All @@ -250,6 +270,8 @@ public struct Linux: Platform {
"yum"
case "debian12":
"apt-get"
case "gentoo":
"emerge"
default:
nil
}
Expand Down Expand Up @@ -323,6 +345,10 @@ public struct Linux: Platform {
case "yum":
try self.runProgram("yum", "list", "installed", package, quiet: true)
return true
case "emerge":
// Use portage's qlist to check if package is installed
try self.runProgram("qlist", "-I", package, quiet: true)
return true
default:
return true
}
Expand Down Expand Up @@ -586,6 +612,8 @@ public struct Linux: Platform {
}

return .rhel9
} else if id == "gentoo" || (idlike ?? "").contains("gentoo") {
return .gentoo
} else if let pd = [
PlatformDefinition.ubuntu1804, .ubuntu2004, .ubuntu2204, .ubuntu2404, .debian12, .fedora39,
].first(where: { $0.name == id + versionID }) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftlyCore/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public struct SwiftlyHTTPClient: Sendable {
{
// These are new platforms that aren't yet in the list of known platforms in the OpenAPI schema
case PlatformDefinition.ubuntu2404.name, PlatformDefinition.debian12.name,
PlatformDefinition.fedora39.name:
PlatformDefinition.fedora39.name, PlatformDefinition.gentoo.name:
.init(platform.name)

case PlatformDefinition.ubuntu2204.name:
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftlyCore/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public struct PlatformDefinition: Codable, Equatable, Sendable {
public static let debian12 = PlatformDefinition(
name: "debian12", nameFull: "debian12", namePretty: "Debian GNU/Linux 12"
)
public static let gentoo = PlatformDefinition(
name: "gentoo", nameFull: "gentoo", namePretty: "Gentoo Linux"
)
}

public struct RunProgramError: Swift.Error {
Expand Down