Install brew through builder if not present
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 19 Jun 2024 09:47:56 +0000 (17:47 +0800)
committerClaudio Cambra <developer@claudiocambra.com>
Mon, 8 Jul 2024 07:41:45 +0000 (15:41 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/craft-client.swift

index e5e94f95f427d75700bd440826fe3ac913c65add..e5007bdefdb3a28d5efe0bc84f3c2366912a312b 100644 (file)
@@ -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.")
+}