diff --git a/Changes.md b/Changes.md index 59efc75..f08982f 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,7 @@ +## 0.2.2 + +- Added a `is_musl` method to the `UbiBuilder` struct to allow setting this manually. + ## 0.2.1 - 2024-10-27 - When running on Linux, `ubi` now checks to see if the platform is using `musl` and will prefer a diff --git a/ubi/src/lib.rs b/ubi/src/lib.rs index 9aeb757..89d0a85 100644 --- a/ubi/src/lib.rs +++ b/ubi/src/lib.rs @@ -72,6 +72,7 @@ pub struct UbiBuilder<'a> { exe: Option<&'a str>, github_token: Option<&'a str>, platform: Option<&'a Platform>, + is_musl: Option, github_api_url_base: Option, } @@ -156,6 +157,15 @@ impl<'a> UbiBuilder<'a> { self } + /// Set whether or not the platform uses musl as its libc. This is only relevant for Linux + /// platforms. If this isn't set then it will be determined based on the current platform's + /// libc. You cannot set this to `true` on a non-Linux platform. + #[must_use] + pub fn is_musl(mut self, is_musl: bool) -> Self { + self.is_musl = Some(is_musl); + self + } + /// Set the base URL for the GitHub API. This is useful for testing or if you want to operate /// against a GitHub Enterprise installation. #[must_use] @@ -194,6 +204,13 @@ impl<'a> UbiBuilder<'a> { ))? }; + if self.is_musl.unwrap_or_default() && platform.target_os != OS::Linux { + return Err(anyhow!( + "You cannot set is_musl to true on a non-Linux platform - the current platform is {}", + platform.target_os, + )); + } + Ubi::new( self.project, self.tag, @@ -203,7 +220,10 @@ impl<'a> UbiBuilder<'a> { self.exe, self.github_token, platform, - platform_is_musl(platform), + match self.is_musl { + Some(m) => m, + None => platform_is_musl(platform), + }, self.github_api_url_base, ) }