зеркало из https://github.com/golang/build.git
cmd/gomote: put14 command, make puttar writes VERSION file & create lists types
Change-Id: I943570042206c60b2c4dac6907cb43170cdc9685 Reviewed-on: https://go-review.googlesource.com/3957 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Родитель
319667fbcf
Коммит
45156e8ff4
|
@ -17,11 +17,26 @@ import (
|
|||
"golang.org/x/build/dashboard"
|
||||
)
|
||||
|
||||
func vmTypes() (s []string) {
|
||||
for k, conf := range dashboard.Builders {
|
||||
if conf.UsesVM() {
|
||||
s = append(s, k)
|
||||
}
|
||||
}
|
||||
sort.Strings(s)
|
||||
return
|
||||
}
|
||||
|
||||
func create(args []string) error {
|
||||
fs := flag.NewFlagSet("create", flag.ContinueOnError)
|
||||
|
||||
fs.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "create usage: gomote create [create-opts] <type>\n\n")
|
||||
fmt.Fprintln(os.Stderr, "create usage: gomote create [create-opts] <type>\n")
|
||||
fs.PrintDefaults()
|
||||
fmt.Fprintln(os.Stderr, "\nValid types:\n")
|
||||
for _, t := range vmTypes() {
|
||||
fmt.Fprintf(os.Stderr, " * %s\n", t)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
var timeout time.Duration
|
||||
|
|
|
@ -79,6 +79,7 @@ func registerCommands() {
|
|||
registerCommand("run", "run a command on a buildlet", run)
|
||||
registerCommand("put", "put files on a buildlet", put)
|
||||
registerCommand("puttar", "extract a tar.gz to a buildlet", putTar)
|
||||
registerCommand("put14", "put Go 1.4 in place", put14)
|
||||
registerCommand("gettar", "extract a tar.gz from a buildlet", getTar)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/build/dashboard"
|
||||
"golang.org/x/build/tarutil"
|
||||
)
|
||||
|
||||
// put a .tar.gz
|
||||
|
@ -48,7 +53,23 @@ func putTar(args []string) error {
|
|||
if fs.NArg() != 1 {
|
||||
fs.Usage()
|
||||
}
|
||||
return bc.PutTarFromURL(tarURL, dir)
|
||||
if err := bc.PutTarFromURL(tarURL, dir); err != nil {
|
||||
return err
|
||||
}
|
||||
if rev != "" {
|
||||
// Put a VERSION file there too, to avoid git usage.
|
||||
version := strings.NewReader("devel " + rev)
|
||||
var vtar tarutil.FileList
|
||||
vtar.AddRegular(&tar.Header{
|
||||
Name: "VERSION",
|
||||
Mode: 0644,
|
||||
Size: int64(version.Len()),
|
||||
}, int64(version.Len()), version)
|
||||
tgz := vtar.TarGz()
|
||||
defer tgz.Close()
|
||||
return bc.PutTar(tgz, dir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var tgz io.Reader = os.Stdin
|
||||
|
@ -63,6 +84,34 @@ func putTar(args []string) error {
|
|||
return bc.PutTar(tgz, dir)
|
||||
}
|
||||
|
||||
// put go1.4 in the workdir
|
||||
func put14(args []string) error {
|
||||
fs := flag.NewFlagSet("put14", flag.ContinueOnError)
|
||||
fs.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "create usage: gomote put14 <buildlet-name>")
|
||||
fs.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
fs.Parse(args)
|
||||
if fs.NArg() != 1 {
|
||||
fs.Usage()
|
||||
}
|
||||
name := fs.Arg(0)
|
||||
conf, ok := dashboard.Builders[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("unknown builder %q", name)
|
||||
}
|
||||
if conf.Go14URL == "" {
|
||||
fmt.Println("No Go14URL field defined for %q; ignoring. (may be baked into image)", name)
|
||||
return nil
|
||||
}
|
||||
bc, err := namedClient(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bc.PutTarFromURL(conf.Go14URL, "go1.4")
|
||||
}
|
||||
|
||||
// put single files
|
||||
func put(args []string) error {
|
||||
fs := flag.NewFlagSet("put", flag.ContinueOnError)
|
||||
|
|
Загрузка…
Ссылка в новой задаче