Skip to content

Commit 4e9e211

Browse files
committed
cmd/release: don't include a godoc shortcut in Windows installer
Fixes golang/go#34892 Change-Id: I9dc14575677c3a4d75a12556896dbed340d442cc Reviewed-on: https://go-review.googlesource.com/c/build/+/201201 Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 09c7190 commit 4e9e211

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

cmd/release/releaselet.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,21 @@ func archDir() string {
7777
return ""
7878
}
7979

80+
// includesGodoc reports whether we should include the godoc binary in this release.
81+
// We only include it in go1.12.x and earlier releases; see issue 30029.
82+
func includesGodoc() bool {
83+
_, version, _ := environ()
84+
verMajor, verMinor, _ := splitVersion(version)
85+
return verMajor == 1 && verMinor < 13
86+
}
87+
8088
// godoc copies the godoc binary into place for Go 1.12 and earlier.
8189
//
8290
// TODO: remove this function once Go 1.14 is released (when Go 1.12
8391
// is no longer supported).
8492
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
93+
if !includesGodoc() {
94+
return nil
8995
}
9096

9197
// Pre Go 1.7, the godoc binary is placed here by cmd/go.
@@ -247,6 +253,9 @@ func windowsMSI() error {
247253
// Write out windows data that is used by the packaging process.
248254
win := filepath.Join(cwd, "windows")
249255
defer os.RemoveAll(win)
256+
if !includesGodoc() {
257+
removeGodocShortcut()
258+
}
250259
if err := writeDataFiles(windowsData, win); err != nil {
251260
return err
252261
}
@@ -575,6 +584,13 @@ function installCheck() {
575584
"Resources/bg.png": storageBase + "darwin/bg.png",
576585
}
577586

587+
// removeGodocShortcut removes the GODOC_SHORTCUT part out of the
588+
// installer.wxs file contents.
589+
func removeGodocShortcut() {
590+
rx := regexp.MustCompile(`(?s)<!--GODOC_SHORTCUT-->.*<!--END_GODOC_SHORTCUT-->`)
591+
windowsData["installer.wxs"] = rx.ReplaceAllString(windowsData["installer.wxs"], "")
592+
}
593+
578594
var windowsData = map[string]string{
579595

580596
"installer.wxs": `<?xml version="1.0" encoding="UTF-8"?>
@@ -658,14 +674,15 @@ var windowsData = map[string]string{
658674
<!-- Programs Menu Shortcuts -->
659675
<DirectoryRef Id="GoProgramShortcutsDir">
660676
<Component Id="Component_GoProgramShortCuts" Guid="{f5fbfb5e-6c5c-423b-9298-21b0e3c98f4b}">
677+
<!--GODOC_SHORTCUT-->
661678
<Shortcut
662679
Id="GoDocServerStartMenuShortcut"
663680
Name="GoDocServer"
664681
Description="Starts the Go documentation server (http://localhost:6060)"
665682
Show="minimized"
666683
Arguments='/c start "Godoc Server http://localhost:6060" "[INSTALLDIR]bin\godoc.exe" -http=localhost:6060 -goroot="[INSTALLDIR]." &amp;&amp; start http://localhost:6060'
667684
Icon="gopher.ico"
668-
Target="[%ComSpec]" />
685+
Target="[%ComSpec]" /><!--END_GODOC_SHORTCUT-->
669686
<Shortcut
670687
Id="UninstallShortcut"
671688
Name="Uninstall Go"
@@ -878,5 +895,13 @@ func runSelfTests() {
878895
}
879896
}
880897

898+
if !strings.Contains(windowsData["installer.wxs"], "GODOC_SHORTCUT") {
899+
log.Fatal("expected GODOC_SHORTCUT to be present")
900+
}
901+
removeGodocShortcut()
902+
if strings.Contains(windowsData["installer.wxs"], "GODOC_SHORTCUT") {
903+
log.Fatal("expected GODOC_SHORTCUT to be gone")
904+
}
905+
881906
fmt.Println("ok")
882907
}

0 commit comments

Comments
 (0)