From d0f0a872a7ef545977dc7bc58c032b446a94a51b Mon Sep 17 00:00:00 2001 From: aarzilli Date: Thu, 18 Oct 2018 17:25:39 +0200 Subject: [PATCH] Documentation,Makefile: better error when gencert.sh fails Fixes #1378 --- Documentation/installation/osx/install.md | 2 +- scripts/make.go | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Documentation/installation/osx/install.md b/Documentation/installation/osx/install.md index 1f8fdffd..e9cc987a 100644 --- a/Documentation/installation/osx/install.md +++ b/Documentation/installation/osx/install.md @@ -21,6 +21,6 @@ Only do this if you have a valid reason to use the native backend. 1. Run `xcode-select --install` 2. On macOS 10.14 manually install the legacy include headers by running `/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg` 3. Clone the repo into `$GOPATH/src/github.com/derekparker/delve` -4. Run `make install` in that directory +4. Run `make install` in that directory (on some versions of macOS this requires being root, the first time you run it, to install a new certificate) The makefile will take care of creating and installing a self-signed certificate automatically. diff --git a/scripts/make.go b/scripts/make.go index 9940a7ef..82cff0d9 100644 --- a/scripts/make.go +++ b/scripts/make.go @@ -105,22 +105,33 @@ This option can only be specified if testset is basic or a single package.`) return RootCommand } -func checkCertCmd(cmd *cobra.Command, args []string) { +func checkCert() bool { // If we're on OSX make sure the proper CERT env var is set. if os.Getenv("TRAVIS") == "true" || runtime.GOOS != "darwin" || os.Getenv("CERT") != "" { - return + return true } x := exec.Command("scripts/gencert.sh") + x.Stdout = os.Stdout + x.Stderr = os.Stderr + x.Env = os.Environ() err := x.Run() if x.ProcessState != nil && !x.ProcessState.Success() { fmt.Printf("An error occurred when generating and installing a new certificate\n") - os.Exit(1) + return false } if err != nil { - log.Fatal(err) + fmt.Printf("An error occoured when generating and installing a new certificate: %v\n", err) + return false } os.Setenv("CERT", "dlv-cert") + return true +} + +func checkCertCmd(cmd *cobra.Command, args []string) { + if !checkCert() { + os.Exit(1) + } } func strflatten(v []interface{}) []string { @@ -214,7 +225,9 @@ func prepareMacnative() string { if !canMacnative() { return "" } - checkCertCmd(nil, nil) + if !checkCert() { + return "" + } return "-tags=macnative" }