Documentation,Makefile: better error when gencert.sh fails

Fixes #1378
This commit is contained in:
aarzilli 2018-10-18 17:25:39 +02:00 committed by Derek Parker
parent ff760d87aa
commit d0f0a872a7
2 changed files with 19 additions and 6 deletions

@ -21,6 +21,6 @@ Only do this if you have a valid reason to use the native backend.
1. Run `xcode-select --install` 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` 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` 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. The makefile will take care of creating and installing a self-signed certificate automatically.

@ -105,22 +105,33 @@ This option can only be specified if testset is basic or a single package.`)
return RootCommand 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 we're on OSX make sure the proper CERT env var is set.
if os.Getenv("TRAVIS") == "true" || runtime.GOOS != "darwin" || os.Getenv("CERT") != "" { if os.Getenv("TRAVIS") == "true" || runtime.GOOS != "darwin" || os.Getenv("CERT") != "" {
return return true
} }
x := exec.Command("scripts/gencert.sh") x := exec.Command("scripts/gencert.sh")
x.Stdout = os.Stdout
x.Stderr = os.Stderr
x.Env = os.Environ()
err := x.Run() err := x.Run()
if x.ProcessState != nil && !x.ProcessState.Success() { if x.ProcessState != nil && !x.ProcessState.Success() {
fmt.Printf("An error occurred when generating and installing a new certificate\n") fmt.Printf("An error occurred when generating and installing a new certificate\n")
os.Exit(1) return false
} }
if err != nil { 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") os.Setenv("CERT", "dlv-cert")
return true
}
func checkCertCmd(cmd *cobra.Command, args []string) {
if !checkCert() {
os.Exit(1)
}
} }
func strflatten(v []interface{}) []string { func strflatten(v []interface{}) []string {
@ -214,7 +225,9 @@ func prepareMacnative() string {
if !canMacnative() { if !canMacnative() {
return "" return ""
} }
checkCertCmd(nil, nil) if !checkCert() {
return ""
}
return "-tags=macnative" return "-tags=macnative"
} }