From 1f7d347bb167d896648e415fa856c6a6b85f1df5 Mon Sep 17 00:00:00 2001 From: Luis Medel Date: Wed, 16 Oct 2024 23:10:59 +0200 Subject: [PATCH] Add cask support --- .bluish/bluish.yaml | 2 +- src/bluish/process.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.bluish/bluish.yaml b/.bluish/bluish.yaml index 94330bf..6b6701c 100644 --- a/.bluish/bluish.yaml +++ b/.bluish/bluish.yaml @@ -1,6 +1,6 @@ var: - project_version: "0.7.0" + project_version: "0.7.1" python_version: "3.12" jobs: diff --git a/src/bluish/process.py b/src/bluish/process.py index 027ae42..adba60d 100644 --- a/src/bluish/process.py +++ b/src/bluish/process.py @@ -208,6 +208,8 @@ def install_package( """Installs a package on a host.""" package_list = " ".join(packages) + if not packages: + raise ValueError("Empty package list") flavor = get_flavor(host_opts) if flavor == "auto" else flavor if flavor in ("alpine", "alpine-edge"): @@ -223,6 +225,18 @@ def install_package( elif flavor in ("gentoo"): return run(f"emerge -v {package_list}", host_opts) elif flavor in ("macos"): - return run(f"HOMEBREW_NO_AUTO_UPDATE=1 brew install {package_list}", host_opts) + brew_install_cmd = ( + "HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install" + ) + + package_list = " ".join(p for p in packages if not p.startswith("cask:")) + if package_list: + result = run(f"{brew_install_cmd} {package_list}", host_opts) + + cask_list = " ".join(p[5:] for p in packages if not p.startswith("cask:")) + if cask_list: + result = run(f"{brew_install_cmd} --cask {cask_list}", host_opts) + + return result else: raise ValueError(f"Unsupported flavor: {flavor}")