Skip to content

Commit

Permalink
cmd/release, cmd/releasebot: clean up unused code
Browse files Browse the repository at this point in the history
+ The .pkg installer is now constructed by an internal process,
  since the binaries within the installer need to be signed using
  internal-only certs
+ 1.11 is no longer supported, so the tour is no longer shipped
  with the release

Updates golang/go#34986

Change-Id: Ic05198dec2fdbfb26d9011944051a97c777e3898
Reviewed-on: https://go-review.googlesource.com/c/build/+/208266
Run-TryBot: Andrew Bonventre <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
andybons committed Nov 22, 2019
1 parent 99fc19b commit 5de71fd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 198 deletions.
13 changes: 1 addition & 12 deletions cmd/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,7 @@ func (b *Build) make() error {
return filepath.Join(stagingDir, *version+"."+b.String()+ext+".untested")
}

switch b.OS {
case "darwin":
untested := stagingFile(".pkg")
if err := b.fetchFile(client, untested, "pkg"); err != nil {
return err
}
releases = append(releases, releaseFile{
Untested: untested,
Final: *version + "." + b.String() + ".pkg",
})
cleanFiles = append(cleanFiles, "pkg")
case "windows":
if b.OS == "windows" {
untested := stagingFile(".msi")
if err := b.fetchFile(client, untested, "msi"); err != nil {
return err
Expand Down
187 changes: 4 additions & 183 deletions cmd/release/releaselet.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ func main() {
if err := godoc(); err != nil {
log.Fatal(err)
}
if err := tour(); err != nil {
log.Fatal(err)
}
if dir := archDir(); dir != "" {
if err := cp("go/bin/go", "go/bin/"+dir+"/go"); err != nil {
log.Fatal(err)
Expand All @@ -51,22 +48,17 @@ func main() {
os.RemoveAll("go/pkg/tool/linux_amd64")
}
os.RemoveAll("go/pkg/obj")
var err error
switch runtime.GOOS {
case "windows":
if runtime.GOOS == "windows" {
// Clean up .exe~ files; golang.org/issue/23894
filepath.Walk("go", func(path string, fi os.FileInfo, err error) error {
if strings.HasSuffix(path, ".exe~") {
os.Remove(path)
}
return nil
})
err = windowsMSI()
case "darwin":
err = darwinPKG()
}
if err != nil {
log.Fatal(err)
if err := windowsMSI(); err != nil {
log.Fatal(err)
}
}
}

Expand Down Expand Up @@ -109,51 +101,6 @@ func godoc() error {
)
}

const tourPath = "golang.org/x/tour"

var tourContent = []string{
"content",
"solutions",
"static",
"template",
}

var tourPackages = []string{
"pic",
"reader",
"tree",
"wc",
}

// TODO: Remove after Go 1.13 is released, and Go 1.11 is no longer supported.
func tour() error {
_, version, _ := environ()
verMajor, verMinor, _ := splitVersion(version)
if verMajor > 1 || verMinor >= 12 {
return nil // Only include the tour in go1.11.x and earlier releases.
}

tourSrc := filepath.Join("gopath/src", tourPath)
contentDir := filepath.FromSlash("go/misc/tour")

// Copy all the tour content to $GOROOT/misc/tour.
if err := cpAllDir(contentDir, tourSrc, tourContent...); err != nil {
return err
}

// Copy the tour source code so it's accessible with $GOPATH pointing to $GOROOT/misc/tour.
tourPKGDir := filepath.Join(contentDir, "src", tourPath)
if err := cpAllDir(tourPKGDir, tourSrc, tourPackages...); err != nil {
return err
}

// Copy the tour binary to the tool directory, invoked as "go tool tour".
return cp(
filepath.FromSlash("go/pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH+"/tour"+ext()),
filepath.FromSlash("gopath/bin/"+archDir()+"/tour"+ext()),
)
}

func environ() (cwd, version string, err error) {
cwd, err = os.Getwd()
if err != nil {
Expand All @@ -168,75 +115,6 @@ func environ() (cwd, version string, err error) {
return
}

func darwinPKG() error {
cwd, version, err := environ()
if err != nil {
return err
}

// Write out darwin data that is used by the packaging process.
defer os.RemoveAll("darwin")
if err := writeDataFiles(darwinData, "darwin"); err != nil {
return err
}

// Create a work directory and place inside the files as they should
// be on the destination file system.
work := filepath.Join(cwd, "darwinpkg")
if err := os.MkdirAll(work, 0755); err != nil {
return err
}
defer os.RemoveAll(work)

// Write out /etc/paths.d/go.
const pathsBody = "/usr/local/go/bin"
pathsDir := filepath.Join(work, "etc/paths.d")
pathsFile := filepath.Join(pathsDir, "go")
if err := os.MkdirAll(pathsDir, 0755); err != nil {
return err
}
if err = ioutil.WriteFile(pathsFile, []byte(pathsBody), 0644); err != nil {
return err
}

// Copy Go installation to /usr/local/go.
goDir := filepath.Join(work, "usr/local/go")
if err := os.MkdirAll(goDir, 0755); err != nil {
return err
}
if err := cpDir(goDir, "go"); err != nil {
return err
}

// Build the package file.
dest := "package"
if err := os.Mkdir(dest, 0755); err != nil {
return err
}
defer os.RemoveAll(dest)

if err := run("pkgbuild",
"--identifier", "com.googlecode.go",
"--version", version,
"--scripts", "darwin/scripts",
"--root", work,
filepath.Join(dest, "com.googlecode.go.pkg"),
); err != nil {
return err
}

const pkg = "pkg" // known to cmd/release
if err := os.Mkdir(pkg, 0755); err != nil {
return err
}
return run("productbuild",
"--distribution", "darwin/Distribution",
"--resources", "darwin/Resources",
"--package-path", dest,
filepath.Join(cwd, pkg, "go.pkg"), // file name irrelevant
)
}

func windowsMSI() error {
cwd, version, err := environ()
if err != nil {
Expand Down Expand Up @@ -527,63 +405,6 @@ func writeDataFiles(data map[string]string, base string) error {
return nil
}

var darwinData = map[string]string{

"scripts/postinstall": `#!/bin/bash
GOROOT=/usr/local/go
echo "Fixing permissions"
cd $GOROOT
find . -exec chmod ugo+r \{\} \;
find bin -exec chmod ugo+rx \{\} \;
find . -type d -exec chmod ugo+rx \{\} \;
chmod o-w .
`,

"scripts/preinstall": `#!/bin/bash
GOROOT=/usr/local/go
echo "Removing previous installation"
if [ -d $GOROOT ]; then
rm -r $GOROOT
fi
`,

"Distribution": `<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-script minSpecVersion="1.000000">
<title>Go</title>
<background mime-type="image/png" file="bg.png"/>
<options customize="never" allow-external-scripts="no"/>
<domains enable_localSystem="true" />
<installation-check script="installCheck();"/>
<script>
function installCheck() {
if(!(system.compareVersions(system.version.ProductVersion, '10.6.0') >= 0)) {
my.result.title = 'Unable to install';
my.result.message = 'Go requires Mac OS X 10.6 or later.';
my.result.type = 'Fatal';
return false;
}
if(system.files.fileExistsAtPath('/usr/local/go/bin/go')) {
my.result.title = 'Previous Installation Detected';
my.result.message = 'A previous installation of Go exists at /usr/local/go. This installer will remove the previous installation prior to installing. Please back up any data before proceeding.';
my.result.type = 'Warning';
return false;
}
return true;
}
</script>
<choices-outline>
<line choice="com.googlecode.go.choice"/>
</choices-outline>
<choice id="com.googlecode.go.choice" title="Go">
<pkg-ref id="com.googlecode.go.pkg"/>
</choice>
<pkg-ref id="com.googlecode.go.pkg" auth="Root">com.googlecode.go.pkg</pkg-ref>
</installer-script>
`,

"Resources/bg.png": storageBase + "darwin/bg.png",
}

// removeGodocShortcut removes the GODOC_SHORTCUT part out of the
// installer.wxs file contents.
func removeGodocShortcut() {
Expand Down
Loading

0 comments on commit 5de71fd

Please sign in to comment.