Commit 08a5d739 authored by Andrew Gerrand's avatar Andrew Gerrand

misc/dist: produce a zip file under windows

Updates #3254.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/5783058
parent 6a19ae74
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
) )
...@@ -126,7 +127,7 @@ func (b *Build) Do() error { ...@@ -126,7 +127,7 @@ func (b *Build) Do() error {
version string // "weekly.2012-03-04" version string // "weekly.2012-03-04"
fullVersion []byte // "weekly.2012-03-04 9353aa1efdf3" fullVersion []byte // "weekly.2012-03-04 9353aa1efdf3"
) )
pat := filepath.Join(b.root, "pkg/tool/*/dist") pat := filepath.Join(b.root, "pkg/tool/*/dist*") // trailing * for .exe
m, err := filepath.Glob(pat) m, err := filepath.Glob(pat)
if err != nil { if err != nil {
return err return err
...@@ -158,15 +159,17 @@ func (b *Build) Do() error { ...@@ -158,15 +159,17 @@ func (b *Build) Do() error {
} }
// Create packages. // Create packages.
targ := fmt.Sprintf("go.%s.%s-%s", version, b.OS, b.Arch) base := fmt.Sprintf("go.%s.%s-%s", version, b.OS, b.Arch)
var targs []string
switch b.OS { switch b.OS {
case "linux", "freebsd", "": case "linux", "freebsd", "":
// build tarball // build tarball
targ := base + ".tar.gz"
if b.Source { if b.Source {
targ = fmt.Sprintf("go.%s.src", version) targ = fmt.Sprintf("go.%s.src", version)
} }
targ += ".tar.gz"
_, err = b.run("", "tar", "czf", targ, "-C", work, "go") _, err = b.run("", "tar", "czf", targ, "-C", work, "go")
targs = append(targs, targ)
case "darwin": case "darwin":
// arrange work so it's laid out as the dest filesystem // arrange work so it's laid out as the dest filesystem
etc := filepath.Join(b.root, "misc/dist/darwin/etc") etc := filepath.Join(b.root, "misc/dist/darwin/etc")
...@@ -191,7 +194,7 @@ func (b *Build) Do() error { ...@@ -191,7 +194,7 @@ func (b *Build) Do() error {
return errors.New("couldn't find PackageMaker") return errors.New("couldn't find PackageMaker")
} }
} }
targ += ".pkg" targ := base + ".pkg"
scripts := filepath.Join(work, "usr/local/go/misc/dist/darwin/scripts") scripts := filepath.Join(work, "usr/local/go/misc/dist/darwin/scripts")
_, err = b.run("", pm, "-v", _, err = b.run("", pm, "-v",
"-r", work, "-r", work,
...@@ -201,7 +204,20 @@ func (b *Build) Do() error { ...@@ -201,7 +204,20 @@ func (b *Build) Do() error {
"--title", "Go", "--title", "Go",
"--version", "1.0", "--version", "1.0",
"--target", "10.5") "--target", "10.5")
targs = append(targs, targ)
case "windows": case "windows":
// Create ZIP file.
zip := filepath.Join(work, base+".zip")
_, err = b.run(work, "7z", "a", "-tzip", zip, "go")
// Copy zip to target file.
targ := base + ".zip"
err = cp(targ, zip)
if err != nil {
return err
}
targs = append(targs, targ)
// Create MSI installer.
win := filepath.Join(b.root, "misc/dist/windows") win := filepath.Join(b.root, "misc/dist/windows")
installer := filepath.Join(win, "installer.wxs") installer := filepath.Join(win, "installer.wxs")
appfiles := filepath.Join(work, "AppFiles.wxs") appfiles := filepath.Join(work, "AppFiles.wxs")
...@@ -240,11 +256,17 @@ func (b *Build) Do() error { ...@@ -240,11 +256,17 @@ func (b *Build) Do() error {
return err return err
} }
// Copy installer to target file. // Copy installer to target file.
targ += ".msi" targ = base + ".msi"
err = cp(targ, msi) err = cp(targ, msi)
targs = append(targs, targ)
} }
if err == nil && password != "" { if err == nil && password != "" {
err = b.upload(version, targ) for _, targ := range targs {
err = b.upload(version, targ)
if err != nil {
return err
}
}
} }
return err return err
} }
...@@ -322,9 +344,19 @@ func (b *Build) upload(version string, filename string) error { ...@@ -322,9 +344,19 @@ func (b *Build) upload(version string, filename string) error {
labels = append(labels, "Type-Installer", "OpSys-OSX") labels = append(labels, "Type-Installer", "OpSys-OSX")
case "windows": case "windows":
os_ = "Windows" os_ = "Windows"
labels = append(labels, "Type-Installer", "OpSys-Windows") labels = append(labels, "OpSys-Windows")
} }
summary := fmt.Sprintf("Go %s %s (%s)", version, os_, arch) summary := fmt.Sprintf("Go %s %s (%s)", version, os_, arch)
if b.OS == "windows" {
switch {
case strings.HasSuffix(filename, ".msi"):
labels = append(labels, "Type-Installer")
summary += " MSI installer"
case strings.HasSuffix(filename, ".zip"):
labels = append(labels, "Type-Archive")
summary += " ZIP archive"
}
}
if b.Source { if b.Source {
labels = append(labels, "Type-Source") labels = append(labels, "Type-Source")
summary = fmt.Sprintf("Go %s (source only)", version) summary = fmt.Sprintf("Go %s (source only)", version)
...@@ -398,7 +430,11 @@ func exists(path string) bool { ...@@ -398,7 +430,11 @@ func exists(path string) bool {
} }
func readCredentials() error { func readCredentials() error {
name := filepath.Join(os.Getenv("HOME"), ".gobuildkey") name := os.Getenv("HOME")
if runtime.GOOS == "windows" {
name = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
}
name = filepath.Join(name, ".gobuildkey")
f, err := os.Open(name) f, err := os.Open(name)
if err != nil { if err != nil {
return err return err
......
...@@ -4,6 +4,7 @@ Windows build dependencies ...@@ -4,6 +4,7 @@ Windows build dependencies
- Mercurial (hg): http://mercurial.selenic.com/ - Mercurial (hg): http://mercurial.selenic.com/
- MinGW: http://www.mingw.org/ - MinGW: http://www.mingw.org/
- Windows Installer XML (WiX) toolset: http://wix.sourceforge.net/ - Windows Installer XML (WiX) toolset: http://wix.sourceforge.net/
- 7zip
Packaging Packaging
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment