зеркало из https://github.com/golang/build.git
cmd/release: locate releaselet source in workspace
This allows the release command to be run from any directory. Change-Id: Ia0cac8ad32fb5a232bdf429ec2d8901ffd773d57 Reviewed-on: https://go-review.googlesource.com/12915 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
Родитель
d719d266c7
Коммит
106fbe96e4
|
@ -14,6 +14,7 @@ import (
|
|||
"compress/gzip"
|
||||
"flag"
|
||||
"fmt"
|
||||
gobuild "go/build"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -46,8 +47,6 @@ var (
|
|||
|
||||
var coordClient *buildlet.CoordinatorClient
|
||||
|
||||
const releaselet = "releaselet.go"
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
|
@ -58,8 +57,8 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
if _, err := os.Stat(releaselet); err != nil {
|
||||
log.Fatalf("couldn't locate %q: %v", releaselet, err)
|
||||
if err := findReleaselet(); err != nil {
|
||||
log.Fatalf("couldn't find releaselet source: %v", err)
|
||||
}
|
||||
|
||||
if *rev == "" {
|
||||
|
@ -94,6 +93,28 @@ func main() {
|
|||
wg.Wait()
|
||||
}
|
||||
|
||||
var releaselet = "releaselet.go"
|
||||
|
||||
func findReleaselet() error {
|
||||
// First try the working directory.
|
||||
if _, err := os.Stat(releaselet); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Then, try to locate the release command in the workspace.
|
||||
const importPath = "golang.org/x/build/cmd/release"
|
||||
pkg, err := gobuild.Import(importPath, "", gobuild.FindOnly)
|
||||
if err != nil {
|
||||
return fmt.Errorf("finding %q: %v", importPath, err)
|
||||
}
|
||||
r := filepath.Join(pkg.Dir, releaselet)
|
||||
if _, err := os.Stat(r); err != nil {
|
||||
return err
|
||||
}
|
||||
releaselet = r
|
||||
return nil
|
||||
}
|
||||
|
||||
type Build struct {
|
||||
OS, Arch string
|
||||
Source bool
|
||||
|
@ -362,7 +383,6 @@ func (b *Build) make() error {
|
|||
}
|
||||
|
||||
b.logf("Pushing and running releaselet.")
|
||||
// TODO(adg): locate releaselet.go in GOPATH
|
||||
f, err := os.Open(releaselet)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Загрузка…
Ссылка в новой задаче