feat(brew): add Homebrew cask support for Linux (#1539)
This commit is contained in:
@@ -694,6 +694,14 @@ _version: 2
|
|||||||
zh_CN: "不是专用的 macOS brew"
|
zh_CN: "不是专用的 macOS brew"
|
||||||
zh_TW: "不是專門的 macOS brew"
|
zh_TW: "不是專門的 macOS brew"
|
||||||
de: "Kein angepasstes Brew für macOS"
|
de: "Kein angepasstes Brew für macOS"
|
||||||
|
"Homebrew cask support on Linux requires Homebrew 4.5.0 or later (found {version})":
|
||||||
|
en: "Homebrew cask support on Linux requires Homebrew 4.5.0 or later (found %{version})"
|
||||||
|
lt: "Homebrew cask palaikymas Linux sistemoje reikalauja Homebrew 4.5.0 arba naujesnes versijos (rasta %{version})"
|
||||||
|
es: "El soporte de cask de Homebrew en Linux requiere Homebrew 4.5.0 o posterior (encontrado %{version})"
|
||||||
|
fr: "Le support de cask Homebrew sur Linux nécessite Homebrew 4.5.0 ou supérieur (trouvé %{version})"
|
||||||
|
zh_CN: "Linux 上的 Homebrew cask 支持需要 Homebrew 4.5.0 或更高版本(找到 %{version})"
|
||||||
|
zh_TW: "Linux 上的 Homebrew cask 支援需要 Homebrew 4.5.0 或更高版本(找到 %{version})"
|
||||||
|
de: "Homebrew-Cask-Unterstützung unter Linux erfordert Homebrew 4.5.0 oder höher (gefunden %{version})"
|
||||||
"Guix Pull Failed, Skipping":
|
"Guix Pull Failed, Skipping":
|
||||||
en: "Guix Pull Failed, Skipping"
|
en: "Guix Pull Failed, Skipping"
|
||||||
lt: "Guix traukti nepavyko, praleidžiama"
|
lt: "Guix traukti nepavyko, praleidžiama"
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ impl Step {
|
|||||||
Bin => runner.execute(*self, "bin", || generic::bin_update(ctx))?,
|
Bin => runner.execute(*self, "bin", || generic::bin_update(ctx))?,
|
||||||
Bob => runner.execute(*self, "Bob", || generic::run_bob(ctx))?,
|
Bob => runner.execute(*self, "Bob", || generic::run_bob(ctx))?,
|
||||||
BrewCask => {
|
BrewCask => {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
runner.execute(*self, "Brew Cask", || unix::run_brew_cask(ctx, unix::BrewVariant::Path))?;
|
runner.execute(*self, "Brew Cask", || unix::run_brew_cask(ctx, unix::BrewVariant::Path))?;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
runner.execute(*self, "Brew Cask (Intel)", || {
|
runner.execute(*self, "Brew Cask (Intel)", || {
|
||||||
@@ -750,6 +750,7 @@ pub(crate) fn default_steps() -> Vec<Step> {
|
|||||||
Restarts,
|
Restarts,
|
||||||
Flatpak,
|
Flatpak,
|
||||||
BrewFormula,
|
BrewFormula,
|
||||||
|
BrewCask,
|
||||||
Lure,
|
Lure,
|
||||||
Waydroid,
|
Waydroid,
|
||||||
AutoCpufreq,
|
AutoCpufreq,
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ impl BrewVariant {
|
|||||||
/// Execute an "internal" brew command, i.e. one that should always be run
|
/// Execute an "internal" brew command, i.e. one that should always be run
|
||||||
/// even when dry-running. Basically just a wrapper around [`Command::new`]
|
/// even when dry-running. Basically just a wrapper around [`Command::new`]
|
||||||
/// that uses `arch` to run using the correct architecture if needed.
|
/// that uses `arch` to run using the correct architecture if needed.
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
fn execute_internal(self) -> Command {
|
fn execute_internal(self) -> Command {
|
||||||
match self {
|
match self {
|
||||||
BrewVariant::MacIntel if cfg!(target_arch = "aarch64") => {
|
BrewVariant::MacIntel if cfg!(target_arch = "aarch64") => {
|
||||||
@@ -365,12 +364,48 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||||
let binary_name = require(variant.binary_name())?;
|
let binary_name = require(variant.binary_name())?;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
if variant.is_path() && !BrewVariant::is_macos_custom(binary_name) {
|
if variant.is_path() && !BrewVariant::is_macos_custom(binary_name) {
|
||||||
return Err(SkipStep(t!("Not a custom brew for macOS").to_string()).into());
|
return Err(SkipStep(t!("Not a custom brew for macOS").to_string()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
// Homebrew cask support was added in version 4.5.0
|
||||||
|
let version_output = Command::new(&binary_name).arg("--version").output_checked_utf8()?;
|
||||||
|
|
||||||
|
let version_line = version_output
|
||||||
|
.stdout
|
||||||
|
.lines()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| eyre!(output_changed_message!("brew --version", "no output lines")))?;
|
||||||
|
|
||||||
|
let version_str = version_line.split_whitespace().nth(1).ok_or_else(|| {
|
||||||
|
eyre!(output_changed_message!(
|
||||||
|
"brew --version",
|
||||||
|
"Expected version after 'Homebrew'"
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let version = Version::parse(version_str)
|
||||||
|
.wrap_err_with(|| output_changed_message!("brew --version", "Invalid version"))?;
|
||||||
|
|
||||||
|
if version < Version::new(4, 5, 0) {
|
||||||
|
return Err(SkipStep(
|
||||||
|
t!(
|
||||||
|
"Homebrew cask support on Linux requires Homebrew 4.5.0 or later (found {version})",
|
||||||
|
version = version
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_separator(format!("{} - Cask", variant.step_title()));
|
print_separator(format!("{} - Cask", variant.step_title()));
|
||||||
|
|
||||||
let cask_upgrade_exists = variant
|
let cask_upgrade_exists = variant
|
||||||
|
|||||||
Reference in New Issue
Block a user