make.go: do not recodesign when rebuilding (#3639)
This commit is contained in:
parent
1b201c3184
commit
dab870bd96
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -54,7 +55,7 @@ func NewMakeCommands() *cobra.Command {
|
||||
} else {
|
||||
execute("go", "build", "-ldflags", "-extldflags -static", tagFlags(), buildFlags(), DelveMainPackagePath)
|
||||
}
|
||||
if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() {
|
||||
if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() && !isCodesigned("./dlv") {
|
||||
codesign("./dlv")
|
||||
}
|
||||
},
|
||||
@ -70,7 +71,7 @@ func NewMakeCommands() *cobra.Command {
|
||||
Short: "Installs delve",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
execute("go", "install", tagFlags(), buildFlags(), DelveMainPackagePath)
|
||||
if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() {
|
||||
if runtime.GOOS == "darwin" && os.Getenv("CERT") != "" && canMacnative() && !isCodesigned(installedExecutablePath()) {
|
||||
codesign(installedExecutablePath())
|
||||
}
|
||||
},
|
||||
@ -225,6 +226,15 @@ func getoutput(cmd string, args ...interface{}) string {
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func isCodesigned(path string) bool {
|
||||
x := exec.Command("codesign", "--verify", path)
|
||||
x.Stdout = io.Discard
|
||||
x.Stderr = io.Discard
|
||||
x.Env = os.Environ()
|
||||
err := x.Run()
|
||||
return err == nil && x.ProcessState != nil && x.ProcessState.Success()
|
||||
}
|
||||
|
||||
func codesign(path string) {
|
||||
execute("codesign", "-s", os.Getenv("CERT"), path)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user