build, internal/build: misc improvements (#3229)

* travis.yml: don't create darwin/386 builds

* build: remove godep remains

* internal/build: improve archives

- enable compression for zip files
- don't write half-complete archives

* build: add -unstable to archive names
This commit is contained in:
Felix Lange 2016-11-03 13:44:16 +01:00 committed by Péter Szilágyi
parent d0c820acd6
commit ed2bc7fbe9
6 changed files with 33 additions and 24 deletions

@ -45,9 +45,7 @@ matrix:
- azure-osx
script:
- go run build/ci.go install
- go run build/ci.go archive -type zip -signer OSX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go install -arch 386
- go run build/ci.go archive -arch 386 -type zip -signer OSX_SIGNING_KEY -upload gethstore/builds
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -upload gethstore/builds
install:
- go get golang.org/x/tools/cmd/cover

@ -29,7 +29,7 @@ test: all
build/env.sh go run build/ci.go test
clean:
rm -fr build/_workspace/pkg/ Godeps/_workspace/pkg $(GOBIN)/*
rm -fr build/_workspace/pkg/ $(GOBIN)/*
# Cross Compilation Targets (xgo)

@ -296,18 +296,20 @@ func doArchive(cmdline []string) {
log.Fatal("unknown archive type: ", atype)
}
env := build.Env()
var (
env = build.Env()
base = archiveBasename(*arch, env)
geth = "geth-" + base + ext
alltools = "geth-alltools-" + base + ext
)
maybeSkipArchive(env)
base := archiveBasename(*arch, env)
if err := build.WriteArchive("geth-"+base, ext, gethArchiveFiles); err != nil {
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
log.Fatal(err)
}
if err := build.WriteArchive("geth-alltools-"+base, ext, allToolsArchiveFiles); err != nil {
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
log.Fatal(err)
}
for _, archive := range []string{"geth-" + base + ext, "geth-alltools-" + base + ext} {
for _, archive := range []string{geth, alltools} {
if err := archiveUpload(archive, *upload, *signer); err != nil {
log.Fatal(err)
}
@ -315,9 +317,11 @@ func doArchive(cmdline []string) {
}
func archiveBasename(arch string, env build.Environment) string {
// date := time.Now().UTC().Format("200601021504")
platform := runtime.GOOS + "-" + arch
archive := platform + "-" + build.VERSION()
if isUnstableBuild(env) {
archive += "-unstable"
}
if env.Commit != "" {
archive += "-" + env.Commit[:8]
}

@ -19,7 +19,6 @@ if [ ! -L "$ethdir/go-ethereum" ]; then
fi
# Set up the environment to use the workspace.
# Also add Godeps workspace so we build using canned dependencies.
GOPATH="$workspace"
export GOPATH

@ -45,7 +45,7 @@ var (
// paths with any of these prefixes will be skipped
skipPrefixes = []string{
// boring stuff
"Godeps/", "tests/files/", "build/",
"vendor/", "tests/files/", "build/",
// don't relicense vendored sources
"crypto/sha3/", "crypto/ecies/", "logger/glog/",
"crypto/secp256k1/curve.go",

@ -41,14 +41,14 @@ type Archive interface {
Close() error
}
func NewArchive(file *os.File) Archive {
func NewArchive(file *os.File) (Archive, string) {
switch {
case strings.HasSuffix(file.Name(), ".zip"):
return NewZipArchive(file)
return NewZipArchive(file), strings.TrimSuffix(file.Name(), ".zip")
case strings.HasSuffix(file.Name(), ".tar.gz"):
return NewTarballArchive(file)
return NewTarballArchive(file), strings.TrimSuffix(file.Name(), ".tar.gz")
default:
return nil
return nil, ""
}
}
@ -74,17 +74,24 @@ func AddFile(a Archive, file string) error {
}
// WriteArchive creates an archive containing the given files.
func WriteArchive(basename, ext string, files []string) error {
archfd, err := os.Create(basename + ext)
func WriteArchive(name string, files []string) (err error) {
archfd, err := os.Create(name)
if err != nil {
return err
}
defer archfd.Close()
archive := NewArchive(archfd)
if archive == nil {
return fmt.Errorf("unknown archive extension: %s", ext)
defer func() {
archfd.Close()
// Remove the half-written archive on failure.
if err != nil {
os.Remove(name)
}
fmt.Println(basename + ext)
}()
archive, basename := NewArchive(archfd)
if archive == nil {
return fmt.Errorf("unknown archive extension")
}
fmt.Println(name)
if err := archive.Directory(basename); err != nil {
return err
}
@ -118,6 +125,7 @@ func (a *ZipArchive) Header(fi os.FileInfo) (io.Writer, error) {
return nil, fmt.Errorf("can't make zip header: %v", err)
}
head.Name = a.dir + head.Name
head.Method = zip.Deflate
w, err := a.zipw.CreateHeader(head)
if err != nil {
return nil, fmt.Errorf("can't add zip header: %v", err)