cmd/updatestd: check that the bundle command is what we want
At least on macOS, there is /usr/bin/bundle which is not what we
want. So, besides making sure "bundle" is in PATH, make sure it is
the one we want.
Change-Id: I17bca55f18f384051372ee32eeaa104003476046
Reviewed-on: https://go-review.googlesource.com/c/build/+/452768
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/cmd/updatestd/updatestd.go b/cmd/updatestd/updatestd.go
index f1d917c..d1eefd1 100644
--- a/cmd/updatestd/updatestd.go
+++ b/cmd/updatestd/updatestd.go
@@ -11,6 +11,7 @@
import (
"bytes"
"context"
+ "debug/buildinfo"
"encoding/json"
"errors"
"flag"
@@ -61,6 +62,10 @@
if err != nil {
log.Fatalln("can't find bundle in PATH; did you run 'go install golang.org/x/tools/cmd/bundle@latest' and add it to PATH?")
}
+ if bi, err := buildinfo.ReadFile(bundlePath); err != nil || bi.Path != "golang.org/x/tools/cmd/bundle" {
+ // Not the bundle command we want.
+ log.Fatalln("unexpected bundle command in PATH; did you run 'go install golang.org/x/tools/cmd/bundle@latest' and add it to PATH?")
+ }
// Fetch latest hashes of Go projects from Gerrit,
// using the specified branch name.