Skip to content

Commit

Permalink
Add cask support
Browse files Browse the repository at this point in the history
  • Loading branch information
luismedel committed Oct 16, 2024
1 parent 87fe9ea commit 1f7d347
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bluish/bluish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

var:
project_version: "0.7.0"
project_version: "0.7.1"
python_version: "3.12"

jobs:
Expand Down
16 changes: 15 additions & 1 deletion src/bluish/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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}")

0 comments on commit 1f7d347

Please sign in to comment.