1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:30:22 -07:00

misc/dist: add 'label' part of distro name, include blog content

This will allow us to cut binaries with names like:
        go1.2rc1.darwin-amd64-osx10.6.pkg
        go1.2rc1.darwin-amd64-osx10.8.pkg

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13629045
This commit is contained in:
Andrew Gerrand 2013-09-19 16:51:29 +10:00
parent c742179c49
commit 5ec8698862

65
misc/dist/bindist.go vendored
View File

@ -44,8 +44,9 @@ var (
const ( const (
uploadURL = "https://go.googlecode.com/files" uploadURL = "https://go.googlecode.com/files"
tourPath = "code.google.com/p/go-tour" blogPath = "code.google.com/p/go.blog"
toolPath = "code.google.com/p/go.tools" toolPath = "code.google.com/p/go.tools"
tourPath = "code.google.com/p/go-tour"
defaultToolTag = "tip" // TOOD(adg): set this once Go 1.2 settles defaultToolTag = "tip" // TOOD(adg): set this once Go 1.2 settles
) )
@ -93,6 +94,11 @@ var tourContent = []string{
"template", "template",
} }
var blogContent = []string{
"content",
"template",
}
// The os-arches that support the race toolchain. // The os-arches that support the race toolchain.
var raceAvailable = []string{ var raceAvailable = []string{
"darwin-amd64", "darwin-amd64",
@ -100,7 +106,8 @@ var raceAvailable = []string{
"windows-amd64", "windows-amd64",
} }
var fileRe = regexp.MustCompile(`^(go[a-z0-9-.]+)\.(src|([a-z0-9]+)-([a-z0-9]+))\.`) var fileRe = regexp.MustCompile(
`^(go[a-z0-9-.]+)\.(src|([a-z0-9]+)-([a-z0-9]+)(?:-([a-z0-9.]))?)\.`)
func main() { func main() {
flag.Usage = func() { flag.Usage = func() {
@ -131,6 +138,7 @@ func main() {
} else { } else {
b.OS = m[3] b.OS = m[3]
b.Arch = m[4] b.Arch = m[4]
b.Label = m[5]
} }
if !*upload { if !*upload {
log.Printf("%s: -upload=false, skipping", targ) log.Printf("%s: -upload=false, skipping", targ)
@ -144,13 +152,16 @@ func main() {
if targ == "source" { if targ == "source" {
b.Source = true b.Source = true
} else { } else {
p := strings.SplitN(targ, "-", 2) p := strings.SplitN(targ, "-", 3)
if len(p) != 2 { if len(p) < 2 {
log.Println("Ignoring unrecognized target:", targ) log.Println("Ignoring unrecognized target:", targ)
continue continue
} }
b.OS = p[0] b.OS = p[0]
b.Arch = p[1] b.Arch = p[1]
if len(p) >= 3 {
b.Label = p[2]
}
if *includeRace { if *includeRace {
for _, t := range raceAvailable { for _, t := range raceAvailable {
if t == targ { if t == targ {
@ -170,6 +181,7 @@ type Build struct {
Race bool // build race toolchain Race bool // build race toolchain
OS string OS string
Arch string Arch string
Label string
root string root string
gopath string gopath string
} }
@ -241,6 +253,10 @@ func (b *Build) Do() error {
if err != nil { if err != nil {
return err return err
} }
err = b.blog()
if err != nil {
return err
}
err = b.tour() err = b.tour()
} }
if err != nil { if err != nil {
@ -289,6 +305,9 @@ func (b *Build) Do() error {
// Create packages. // Create packages.
base := fmt.Sprintf("%s.%s-%s", version, b.OS, b.Arch) base := fmt.Sprintf("%s.%s-%s", version, b.OS, b.Arch)
if b.Label != "" {
base += "-" + b.Label
}
if !strings.HasPrefix(base, "go") { if !strings.HasPrefix(base, "go") {
base = "go." + base base = "go." + base
} }
@ -424,12 +443,7 @@ func (b *Build) Do() error {
} }
func (b *Build) tools() error { func (b *Build) tools() error {
defer func() { defer b.cleanGopath()
// Clean work files from GOPATH directory.
for _, d := range []string{"bin", "pkg", "src"} {
os.RemoveAll(filepath.Join(b.gopath, d))
}
}()
// Fetch the tool packages (without building/installing). // Fetch the tool packages (without building/installing).
args := append([]string{"get", "-d"}, toolPaths...) args := append([]string{"get", "-d"}, toolPaths...)
@ -451,13 +465,23 @@ func (b *Build) tools() error {
return err return err
} }
func (b *Build) blog() error {
defer b.cleanGopath()
// Fetch the blog repository.
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", "-d", blogPath+"/blog")
if err != nil {
return err
}
// Copy blog content to $GOROOT/blog.
blogSrc := filepath.Join(b.gopath, "src", filepath.FromSlash(blogPath))
contentDir := filepath.Join(b.root, "blog")
return cpAllDir(contentDir, blogSrc, blogContent...)
}
func (b *Build) tour() error { func (b *Build) tour() error {
defer func() { defer b.cleanGopath()
// Clean work files from GOPATH directory.
for _, d := range []string{"bin", "pkg", "src"} {
os.RemoveAll(filepath.Join(b.gopath, d))
}
}()
// go get the gotour package. // go get the gotour package.
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", tourPath+"/gotour") _, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", tourPath+"/gotour")
@ -485,6 +509,12 @@ func (b *Build) tour() error {
) )
} }
func (b *Build) cleanGopath() {
for _, d := range []string{"bin", "pkg", "src"} {
os.RemoveAll(filepath.Join(b.gopath, d))
}
}
func ext() string { func ext() string {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return ".exe" return ".exe"
@ -611,6 +641,9 @@ func (b *Build) Upload(version string, filename string) error {
if ftype != "" { if ftype != "" {
labels = append(labels, "Type-"+ftype) labels = append(labels, "Type-"+ftype)
} }
if b.Label != "" {
labels = append(labels, b.Label)
}
if *addLabel != "" { if *addLabel != "" {
labels = append(labels, *addLabel) labels = append(labels, *addLabel)
} }