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

View File

@ -45,9 +45,7 @@ matrix:
- azure-osx - azure-osx
script: script:
- go run build/ci.go install - 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 archive -type tar -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
install: install:
- go get golang.org/x/tools/cmd/cover - go get golang.org/x/tools/cmd/cover

View File

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

View File

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

View File

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

View File

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

View File

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