From 75e029db8b18f3ef020110e7947a5f42e417c35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 20 Nov 2019 14:56:07 +0200 Subject: [PATCH] build, travis: use ephemeral debsrc GOPATH to get mod deps --- .travis.yml | 4 ---- build/ci.go | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 469aeb688..9568c13ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -91,10 +91,6 @@ jobs: - python-bzrlib - python-paramiko script: - # Fake building locally to download all the go module dependencies - - go install -n ./... - - # Assemble the sources, dependencies and Go SDK into a deb source and upload to Launchpad - echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts - go run build/ci.go debsrc -goversion 1.13.4 -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder " diff --git a/build/ci.go b/build/ci.go index 1059878ad..018985aa1 100644 --- a/build/ci.go +++ b/build/ci.go @@ -46,7 +46,6 @@ import ( "encoding/base64" "flag" "fmt" - gobuild "go/build" "go/parser" "go/token" "io/ioutil" @@ -502,6 +501,11 @@ func doDebianSource(cmdline []string) { // Download and verify the Go source package. gobundle := downloadGoSources(*goversion, *cachedir) + // Download all the dependencies needed to build the sources + depfetch := goTool("install", "-n", "./...") + depfetch.Env = append(os.Environ(), "GOPATH="+filepath.Join(*workdir, "modgopath")) + build.MustRun(depfetch) + // Create Debian packages and upload them. for _, pkg := range debPackages { for distro, goboot := range debDistroGoBoots { @@ -517,7 +521,8 @@ func doDebianSource(cmdline []string) { log.Fatalf("Failed to rename Go source folder: %v", err) } // Add all dependency modules in compressed form - if err := cp.CopyAll(filepath.Join(pkgdir, ".mod", "cache", "download"), filepath.Join(gobuild.Default.GOPATH, "pkg", "mod", "cache", "download")); err != nil { + os.MkdirAll(filepath.Join(pkgdir, ".mod", "cache"), 0755) + if err := cp.CopyAll(filepath.Join(pkgdir, ".mod", "cache", "download"), filepath.Join(*workdir, "modgopath", "pkg", "mod", "cache", "download")); err != nil { log.Fatalf("Failed to copy Go module dependencies: %v", err) } // Run the packaging and upload to the PPA @@ -1067,16 +1072,11 @@ func doXgo(cmdline []string) { func xgoTool(args []string) *exec.Cmd { cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...) - cmd.Env = []string{ + cmd.Env = os.Environ() + cmd.Env = append(cmd.Env, []string{ "GOPATH=" + build.GOPATH(), "GOBIN=" + GOBIN, - } - for _, e := range os.Environ() { - if strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "GOBIN=") { - continue - } - cmd.Env = append(cmd.Env, e) - } + }...) return cmd }