From 772f0215a672988c844ea200033140ced12869c0 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 15 Dec 2023 20:26:30 +1100 Subject: [PATCH] Remove quarantine attribute from bindings + compiled binary (#3118) * Remove quarantine attribute from bindings + compiled binary --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- v2/pkg/commands/bindings/bindings.go | 8 ++++++++ v2/pkg/commands/build/build.go | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/v2/pkg/commands/bindings/bindings.go b/v2/pkg/commands/bindings/bindings.go index 310b1e9af..6ed2a27ba 100644 --- a/v2/pkg/commands/bindings/bindings.go +++ b/v2/pkg/commands/bindings/bindings.go @@ -57,6 +57,14 @@ func GenerateBindings(options Options) (string, error) { return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err) } + if runtime.GOOS == "darwin" { + // Remove quarantine attribute + stdout, stderr, err = shell.RunCommand(workingDirectory, "xattr", "-rc", filename) + if err != nil { + return stdout, fmt.Errorf("%s\n%s\n%s", stdout, stderr, err) + } + } + defer func() { // Best effort removal of temp file _ = os.Remove(filename) diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index 62c08e910..d061f2ce0 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -321,6 +321,20 @@ func execBuildApplication(builder Builder, options *Options) (string, error) { } } + if runtime.GOOS == "darwin" { + // Remove quarantine attribute + if _, err := os.Stat(options.CompiledBinary); os.IsNotExist(err) { + return "", fmt.Errorf("compiled binary does not exist at path: %s", options.CompiledBinary) + } + stdout, stderr, err := shell.RunCommand(options.BinDirectory, "xattr", "-rc", options.CompiledBinary) + if err != nil { + return "", fmt.Errorf("%s - %s", err.Error(), stderr) + } + if options.Verbosity == VERBOSE && stdout != "" { + pterm.Info.Println(stdout) + } + } + pterm.Println("Done.") // Do we need to pack the app for non-windows?