Skip to content

Commit 5bd9893

Browse files
committed
cmd/release: don't include godoc in releases in Go 1.13+
Tested that it's still present in Go 1.12: $ release -version=go1.12.999 -target=linux-amd64 -watch -skip_tests -rev=release-branch.go1.12 -tools=release-branch.go1.12 -net=release-branch.go1.12 ... $ ls -lh go1.12.999.linux-amd64.tar.gz -rw-r--r-- 1 bradfitz bradfitz 122M Apr 29 19:28 go1.12.999.linux-amd64.tar.gz $ tar -ztf go1.12.999.linux-amd64.tar.gz | grep godoc go/bin/godoc go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread.string But not with Go 1.13: $ release -version=go1.13beta0 -target=linux-amd64 -watch -skip_tests -rev=8c1f78524e421ac01e35e8805dd7a45bf98c2a79 ... $ ls -lh go1.13beta0.linux-amd64.tar.gz -rw-r--r-- 1 bradfitz bradfitz 115M Apr 29 19:00 go1.13beta0.linux-amd64.tar.gz $ tar -ztf go1.13beta0.linux-amd64.tar.gz | grep godoc $ Fixes golang/go#30029 Updates golang/go#27151 Change-Id: I9ac5c1b2bc76f184bf05fdcac86bb2e37b57c77c Reviewed-on: https://go-review.googlesource.com/c/build/+/174322 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 61a567e commit 5bd9893

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

cmd/release/release.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func main() {
7272
}
7373

7474
if (*rev == "" && *tarball == "") || (*rev != "" && *tarball != "") {
75-
log.Fatal("must specify one of -rev and -tarball")
76-
}
77-
if *toolsRev == "" {
78-
log.Fatal("must specify -tools flag")
75+
log.Fatal("must specify one of -rev or -tarball")
7976
}
8077
if *version == "" {
81-
log.Fatal("must specify -version flag")
78+
log.Fatal(`must specify -version flag (such as "go1.12" or "go1.13beta1")`)
79+
}
80+
if *toolsRev == "" && (versionIncludesGodoc(*version) || versionIncludesTour(*version)) {
81+
log.Fatal("must specify -tools flag")
8282
}
8383

8484
coordClient = coordinatorClient()
@@ -317,6 +317,9 @@ func (b *Build) make() error {
317317
if r.repo == "tour" && !versionIncludesTour(*version) {
318318
continue
319319
}
320+
if (r.repo == "net" || r.repo == "tools") && !versionIncludesGodoc(*version) {
321+
continue
322+
}
320323
dir := goPath + "/src/golang.org/x/" + r.repo
321324
tar := "https://go.googlesource.com/" + r.repo + "/+archive/" + r.rev + ".tar.gz"
322325
if err := client.PutTarFromURL(tar, dir); err != nil {
@@ -442,15 +445,18 @@ func (b *Build) make() error {
442445
}
443446
}
444447

445-
toolPaths := []string{
446-
"golang.org/x/tools/cmd/godoc",
448+
var toolPaths []string
449+
if versionIncludesGodoc(*version) {
450+
toolPaths = append(toolPaths, "golang.org/x/tools/cmd/godoc")
447451
}
448452
if versionIncludesTour(*version) {
449453
toolPaths = append(toolPaths, "golang.org/x/tour")
450454
}
451-
b.logf("Building %v.", strings.Join(toolPaths, ", "))
452-
if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
453-
return err
455+
if len(toolPaths) > 0 {
456+
b.logf("Building %v.", strings.Join(toolPaths, ", "))
457+
if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
458+
return err
459+
}
454460
}
455461

456462
// postBuildCleanFiles are the list of files to remove in the go/ directory
@@ -839,3 +845,13 @@ func versionIncludesTour(goVer string) bool {
839845
return strings.HasPrefix(goVer, "go1.10.") ||
840846
strings.HasPrefix(goVer, "go1.11.")
841847
}
848+
849+
// versionIncludesGodoc reports whether the provided Go version (of the
850+
// form "go1.N" or "go1.N.M" includes the godoc binary.
851+
func versionIncludesGodoc(goVer string) bool {
852+
// We don't do releases of Go 1.10 and earlier, so this only
853+
// needs to recognize the two current past releases. From Go
854+
// 1.13 and on, we won't ship the godoc binary (see Issue 30029).
855+
return strings.HasPrefix(goVer, "go1.11.") ||
856+
strings.HasPrefix(goVer, "go1.12.")
857+
}

cmd/release/releaselet.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ func archDir() string {
7777
return ""
7878
}
7979

80+
// godoc copies the godoc binary into place for Go 1.12 and earlier.
81+
//
82+
// TODO: remove this function once Go 1.14 is released (when Go 1.12
83+
// is no longer supported).
8084
func godoc() error {
85+
_, version, _ := environ()
86+
verMajor, verMinor, _ := splitVersion(version)
87+
if verMajor > 1 || verMinor >= 13 {
88+
return nil // Only include the godoc binary in go1.12.x and earlier releases; Issue 30029
89+
}
90+
8191
// Pre Go 1.7, the godoc binary is placed here by cmd/go.
8292
// After Go 1.7, we need to copy the binary from GOPATH/bin to GOROOT/bin.
8393
// TODO(cbro): Remove after Go 1.6 is no longer supported.

0 commit comments

Comments
 (0)