From 705cb09d8d5508d1b8ccf79939debd2121721d11 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 19 Jun 2024 17:47:56 +0800 Subject: [PATCH] Install brew through builder if not present Signed-off-by: Claudio Cambra --- admin/osx/craft-client.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/admin/osx/craft-client.swift b/admin/osx/craft-client.swift index e5e94f95f..e5007bdef 100644 --- a/admin/osx/craft-client.swift +++ b/admin/osx/craft-client.swift @@ -44,3 +44,19 @@ func shell(_ commands: String..., env: [String: String]? = nil, quiet: Bool = fa func commandExists(_ command: String) -> Bool { return run("/usr/bin/type", command, quiet: true) == 0 } + +print("Configuring build tooling.") + +if commandExists("brew") { + print("Brew is installed.") +} else { + print("Installing Homebrew...") + guard shell( + "curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash", + env: ["NONINTERACTIVE": "1"] + ) == 0 else { + print("Failed to install Homebrew.") + exit(1) + } + print("Brew installed.") +} -- 2.30.2