From 5ec86988625908d82453f2fcc6597234bfb29b30 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Thu, 19 Sep 2013 16:51:29 +1000 Subject: [PATCH] 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 --- misc/dist/bindist.go | 65 +++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/misc/dist/bindist.go b/misc/dist/bindist.go index c01274d71a..0ed7afeb9c 100644 --- a/misc/dist/bindist.go +++ b/misc/dist/bindist.go @@ -44,8 +44,9 @@ var ( const ( 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" + tourPath = "code.google.com/p/go-tour" defaultToolTag = "tip" // TOOD(adg): set this once Go 1.2 settles ) @@ -93,6 +94,11 @@ var tourContent = []string{ "template", } +var blogContent = []string{ + "content", + "template", +} + // The os-arches that support the race toolchain. var raceAvailable = []string{ "darwin-amd64", @@ -100,7 +106,8 @@ var raceAvailable = []string{ "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() { flag.Usage = func() { @@ -131,6 +138,7 @@ func main() { } else { b.OS = m[3] b.Arch = m[4] + b.Label = m[5] } if !*upload { log.Printf("%s: -upload=false, skipping", targ) @@ -144,13 +152,16 @@ func main() { if targ == "source" { b.Source = true } else { - p := strings.SplitN(targ, "-", 2) - if len(p) != 2 { + p := strings.SplitN(targ, "-", 3) + if len(p) < 2 { log.Println("Ignoring unrecognized target:", targ) continue } b.OS = p[0] b.Arch = p[1] + if len(p) >= 3 { + b.Label = p[2] + } if *includeRace { for _, t := range raceAvailable { if t == targ { @@ -170,6 +181,7 @@ type Build struct { Race bool // build race toolchain OS string Arch string + Label string root string gopath string } @@ -241,6 +253,10 @@ func (b *Build) Do() error { if err != nil { return err } + err = b.blog() + if err != nil { + return err + } err = b.tour() } if err != nil { @@ -289,6 +305,9 @@ func (b *Build) Do() error { // Create packages. base := fmt.Sprintf("%s.%s-%s", version, b.OS, b.Arch) + if b.Label != "" { + base += "-" + b.Label + } if !strings.HasPrefix(base, "go") { base = "go." + base } @@ -424,12 +443,7 @@ func (b *Build) Do() error { } func (b *Build) tools() error { - defer func() { - // Clean work files from GOPATH directory. - for _, d := range []string{"bin", "pkg", "src"} { - os.RemoveAll(filepath.Join(b.gopath, d)) - } - }() + defer b.cleanGopath() // Fetch the tool packages (without building/installing). args := append([]string{"get", "-d"}, toolPaths...) @@ -451,13 +465,23 @@ func (b *Build) tools() error { 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 { - defer func() { - // Clean work files from GOPATH directory. - for _, d := range []string{"bin", "pkg", "src"} { - os.RemoveAll(filepath.Join(b.gopath, d)) - } - }() + defer b.cleanGopath() // go get the gotour package. _, 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 { if runtime.GOOS == "windows" { return ".exe" @@ -611,6 +641,9 @@ func (b *Build) Upload(version string, filename string) error { if ftype != "" { labels = append(labels, "Type-"+ftype) } + if b.Label != "" { + labels = append(labels, b.Label) + } if *addLabel != "" { labels = append(labels, *addLabel) }