Commit 70a8948a authored by Andrew Gerrand's avatar Andrew Gerrand

misc/dist: support upload only (no build)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5940050
parent 16fd9fd6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// This is a tool for packaging binary releases. // This is a tool for packaging binary releases.
// It supports FreeBSD, Linux, and OS X. // It supports FreeBSD, Linux, OS X, and Windows.
package main package main
import ( import (
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"regexp"
"runtime" "runtime"
"strings" "strings"
) )
...@@ -34,6 +35,7 @@ var ( ...@@ -34,6 +35,7 @@ var (
verbose = flag.Bool("v", false, "verbose output") verbose = flag.Bool("v", false, "verbose output")
upload = flag.Bool("upload", true, "upload resulting files to Google Code") upload = flag.Bool("upload", true, "upload resulting files to Google Code")
wxsFile = flag.String("wxs", "", "path to custom installer.wxs") wxsFile = flag.String("wxs", "", "path to custom installer.wxs")
addLabel = flag.String("label", "", "additional label to apply to file hwhen uploading")
username, password string // for Google Code upload username, password string // for Google Code upload
) )
...@@ -64,6 +66,8 @@ var sourceCleanFiles = []string{ ...@@ -64,6 +66,8 @@ var sourceCleanFiles = []string{
"pkg", "pkg",
} }
var fileRe = regexp.MustCompile(`^go\.([a-z0-9-.]+)\.(src|([a-z0-9]+)-([a-z0-9]+))\.`)
func main() { func main() {
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: %s [flags] targets...\n", os.Args[0]) fmt.Fprintf(os.Stderr, "usage: %s [flags] targets...\n", os.Args[0])
...@@ -85,6 +89,24 @@ func main() { ...@@ -85,6 +89,24 @@ func main() {
} }
for _, targ := range flag.Args() { for _, targ := range flag.Args() {
var b Build var b Build
if m := fileRe.FindStringSubmatch(targ); m != nil {
// targ is a file name; upload it to googlecode.
version := m[1]
if m[2] == "src" {
b.Source = true
} else {
b.OS = m[3]
b.Arch = m[4]
}
if !*upload {
log.Printf("%s: -upload=false, skipping", targ)
continue
}
if err := b.Upload(version, targ); err != nil {
log.Printf("%s: %v", targ, err)
}
continue
}
if targ == "source" { if targ == "source" {
b.Source = true b.Source = true
} else { } else {
...@@ -296,7 +318,7 @@ func (b *Build) Do() error { ...@@ -296,7 +318,7 @@ func (b *Build) Do() error {
} }
if err == nil && *upload { if err == nil && *upload {
for _, targ := range targs { for _, targ := range targs {
err = b.upload(version, targ) err = b.Upload(version, targ)
if err != nil { if err != nil {
return err return err
} }
...@@ -362,7 +384,7 @@ func (b *Build) env() []string { ...@@ -362,7 +384,7 @@ func (b *Build) env() []string {
return env return env
} }
func (b *Build) upload(version string, filename string) error { func (b *Build) Upload(version string, filename string) error {
// Prepare upload metadata. // Prepare upload metadata.
var labels []string var labels []string
os_, arch := b.OS, b.Arch os_, arch := b.OS, b.Arch
...@@ -389,7 +411,7 @@ func (b *Build) upload(version string, filename string) error { ...@@ -389,7 +411,7 @@ func (b *Build) upload(version string, filename string) error {
os_ = "Windows" os_ = "Windows"
labels = append(labels, "OpSys-Windows") labels = append(labels, "OpSys-Windows")
} }
summary := fmt.Sprintf("Go %s %s (%s)", version, os_, arch) summary := fmt.Sprintf("%s %s (%s)", version, os_, arch)
if b.OS == "windows" { if b.OS == "windows" {
switch { switch {
case strings.HasSuffix(filename, ".msi"): case strings.HasSuffix(filename, ".msi"):
...@@ -402,7 +424,14 @@ func (b *Build) upload(version string, filename string) error { ...@@ -402,7 +424,14 @@ func (b *Build) upload(version string, filename string) error {
} }
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("%s (source only)", version)
}
if *addLabel != "" {
labels = append(labels, *addLabel)
}
// Put "Go" prefix on summary when it doesn't already begin with "go".
if !strings.HasPrefix(strings.ToLower(summary), "go") {
summary = "Go " + summary
} }
// Open file to upload. // Open file to upload.
......
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