Sfoglia il codice sorgente

build, travis: use ephemeral debsrc GOPATH to get mod deps

Péter Szilágyi 6 anni fa
parent
commit
75e029db8b
2 ha cambiato i file con 10 aggiunte e 14 eliminazioni
  1. 0 4
      .travis.yml
  2. 10 10
      build/ci.go

+ 0 - 4
.travis.yml

@@ -91,10 +91,6 @@ jobs:
             - python-bzrlib
             - python-bzrlib
             - python-paramiko
             - python-paramiko
       script:
       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
         - 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 <geth-ci@ethereum.org>"
         - go run build/ci.go debsrc -goversion 1.13.4 -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
 
 

+ 10 - 10
build/ci.go

@@ -46,7 +46,6 @@ import (
 	"encoding/base64"
 	"encoding/base64"
 	"flag"
 	"flag"
 	"fmt"
 	"fmt"
-	gobuild "go/build"
 	"go/parser"
 	"go/parser"
 	"go/token"
 	"go/token"
 	"io/ioutil"
 	"io/ioutil"
@@ -502,6 +501,11 @@ func doDebianSource(cmdline []string) {
 	// Download and verify the Go source package.
 	// Download and verify the Go source package.
 	gobundle := downloadGoSources(*goversion, *cachedir)
 	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.
 	// Create Debian packages and upload them.
 	for _, pkg := range debPackages {
 	for _, pkg := range debPackages {
 		for distro, goboot := range debDistroGoBoots {
 		for distro, goboot := range debDistroGoBoots {
@@ -517,7 +521,8 @@ func doDebianSource(cmdline []string) {
 				log.Fatalf("Failed to rename Go source folder: %v", err)
 				log.Fatalf("Failed to rename Go source folder: %v", err)
 			}
 			}
 			// Add all dependency modules in compressed form
 			// 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)
 				log.Fatalf("Failed to copy Go module dependencies: %v", err)
 			}
 			}
 			// Run the packaging and upload to the PPA
 			// Run the packaging and upload to the PPA
@@ -1067,16 +1072,11 @@ func doXgo(cmdline []string) {
 
 
 func xgoTool(args []string) *exec.Cmd {
 func xgoTool(args []string) *exec.Cmd {
 	cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...)
 	cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...)
-	cmd.Env = []string{
+	cmd.Env = os.Environ()
+	cmd.Env = append(cmd.Env, []string{
 		"GOPATH=" + build.GOPATH(),
 		"GOPATH=" + build.GOPATH(),
 		"GOBIN=" + GOBIN,
 		"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
 	return cmd
 }
 }