Skip to content

Commit

Permalink
fix(swift): prevent swift from using linux platforms that are not ava…
Browse files Browse the repository at this point in the history
…ilable (#3583)
  • Loading branch information
jdx authored Dec 15, 2024
1 parent 80d5b8d commit ca33329
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@
"gpg_verify": {
"description": "Use gpg to verify swift tool signatures.",
"type": "boolean"
},
"platform": {
"description": "Override the platform to use for precompiled binaries.",
"type": "string"
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,13 @@ type = "Bool"
optional = true
description = "Use gpg to verify swift tool signatures."

[swift.platform]
env = "MISE_SWIFT_PLATFORM"
type = "String"
optional = true
description = "Override the platform to use for precompiled binaries."
default_docs = '"osx" | "windows10" | "ubuntu20.04" | "ubuntu22.04" | "ubuntu24.04" | "amazonlinux2" | "ubi9" | "fedora39"'

[system_config_file]
env = "MISE_SYSTEM_CONFIG_FILE"
type = "Path"
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/core/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,25 @@ fn platform_directory() -> String {
}

fn platform() -> String {
if let Some(platform) = &SETTINGS.swift.platform {
return platform.clone();
}
if cfg!(macos) {
"osx".to_string()
} else if cfg!(windows) {
"windows10".to_string()
} else if let Ok(os_release) = &*os_release::OS_RELEASE {
if os_release.id == "amzn" {
format!("amazonlinux{}", os_release.version_id)
} else if os_release.id == "ubi" {
"ubi9".to_string() // only 9 is available
} else if os_release.id == "fedora" {
"fedora39".to_string() // only 39 is available
} else {
format!("{}{}", os_release.id, os_release.version_id)
}
} else {
"ubi".to_string()
"ubi9".to_string()
}
}

Expand Down

0 comments on commit ca33329

Please sign in to comment.