Skip to content

Commit b3d6304

Browse files
committed
travis, build: aggregate and upload go mod dependencies for PPA
1 parent f4ec854 commit b3d6304

4 files changed

Lines changed: 42 additions & 3 deletions

File tree

‎.travis.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ jobs:
9191
- python-bzrlib
9292
- python-paramiko
9393
script:
94+
# Build once locally to download all the go modeule dependencies
95+
- go run build/ci.go install
96+
97+
# Assemble the sources, dependencies and Go SDK into a deb source and upload to Launchpad
9498
- echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts
9599
- 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>"
96100

‎build/ci.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"encoding/base64"
4747
"flag"
4848
"fmt"
49+
gobuild "go/build"
4950
"go/parser"
5051
"go/token"
5152
"io/ioutil"
@@ -507,13 +508,15 @@ func doDebianSource(cmdline []string) {
507508
meta := newDebMetadata(distro, goboot, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables)
508509
pkgdir := stageDebianSource(*workdir, meta)
509510

510-
// Add Go source code.
511+
// Add Go source code
511512
if err := build.ExtractTarballArchive(gobundle, pkgdir); err != nil {
512513
log.Fatalf("Failed to extract Go sources: %v", err)
513514
}
514515
if err := os.Rename(filepath.Join(pkgdir, "go"), filepath.Join(pkgdir, ".go")); err != nil {
515516
log.Fatalf("Failed to rename Go source folder: %v", err)
516517
}
518+
// Add all dependency modules in compressed form
519+
build.CopyFolder(filepath.Join(pkgdir, ".mod", "cache", "download"), filepath.Join(gobuild.Default.GOPATH, "pkg", "mod", "cache", "download"), 0755)
517520

518521
// Run the packaging and upload to the PPA
519522
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d", "-Zxz")

‎build/deb/ethereum/deb.rules‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ export GOCACHE=/tmp/go-build
99
export GOROOT_BOOTSTRAP={{.GoBootPath}}
1010

1111
override_dh_auto_build:
12-
(cd .go/src && ./make.bash)
13-
build/env.sh .go/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
12+
# We can't download a fresh Go within Launchpad, so we're shipping and building
13+
# one on the fly. However, we can't build it inside the go-ethereum folder as
14+
# bootstrapping clashes with go modules, so build in a sibling folder.
15+
(mv .go ../ && cd ../.go/src && ./make.bash)
16+
17+
# We can't download external go modules within Launchpad, so we're shipping the
18+
# entire dependency source cache with go-ethereum.
19+
(mkdir -p build/_workspace/pkg/mod && mv .mod/* build/_workspace/pkg/mod)
20+
21+
# A fresh Go was built, all dependency downloads faked, hope build works now
22+
build/env.sh ../.go/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
1423

1524
override_dh_auto_test:
1625

‎internal/build/util.go‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ func CopyFile(dst, src string, mode os.FileMode) {
140140
}
141141
}
142142

143+
// CopyFolder copies a folder.
144+
func CopyFolder(dst, src string, mode os.FileMode) {
145+
if err := os.MkdirAll(dst, mode); err != nil {
146+
log.Fatal(err)
147+
}
148+
dir, _ := os.Open(src)
149+
150+
objects, err := dir.Readdir(-1)
151+
if err != nil {
152+
log.Fatal(err)
153+
}
154+
for _, obj := range objects {
155+
srcPath := filepath.Join(src, obj.Name())
156+
dstPath := filepath.Join(dst, obj.Name())
157+
158+
if obj.IsDir() {
159+
CopyFolder(dstPath, srcPath, mode)
160+
} else {
161+
CopyFile(dstPath, srcPath, mode)
162+
}
163+
}
164+
}
165+
143166
// GoTool returns the command that runs a go tool. This uses go from GOROOT instead of PATH
144167
// so that go commands executed by build use the same version of Go as the 'host' that runs
145168
// build code. e.g.

0 commit comments

Comments
 (0)