@@ -58,6 +58,7 @@ import (
5858 "strings"
5959 "time"
6060
61+ "github.com/ethereum/go-ethereum/common/hexutil"
6162 "github.com/ethereum/go-ethereum/internal/build"
6263 "github.com/ethereum/go-ethereum/params"
6364)
@@ -138,7 +139,18 @@ var (
138139 // Note: zesty is unsupported because it was officially deprecated on Launchpad.
139140 // Note: artful is unsupported because it was officially deprecated on Launchpad.
140141 // Note: cosmic is unsupported because it was officially deprecated on Launchpad.
141- debDistros = []string {"trusty" , "xenial" , "bionic" , "disco" , "eoan" }
142+ debDistroGoBoots = map [string ]string {
143+ "trusty" : "golang-1.11" ,
144+ "xenial" : "golang-go" ,
145+ "bionic" : "golang-go" ,
146+ "disco" : "golang-go" ,
147+ "eoan" : "golang-go" ,
148+ }
149+
150+ debGoBootPaths = map [string ]string {
151+ "golang-1.11" : "/usr/lib/go-1.11" ,
152+ "golang-go" : "/usr/lib/go" ,
153+ }
142154)
143155
144156var GOBIN , _ = filepath .Abs (filepath .Join ("build" , "bin" ))
@@ -459,11 +471,14 @@ func maybeSkipArchive(env build.Environment) {
459471// Debian Packaging
460472func doDebianSource (cmdline []string ) {
461473 var (
462- signer = flag .String ("signer" , "" , `Signing key name, also used as package author` )
463- upload = flag .String ("upload" , "" , `Where to upload the source package (usually "ethereum/ethereum")` )
464- sshUser = flag .String ("sftp-user" , "" , `Username for SFTP upload (usually "geth-ci")` )
465- workdir = flag .String ("workdir" , "" , `Output directory for packages (uses temp dir if unset)` )
466- now = time .Now ()
474+ goversion = flag .String ("goversion" , "" , `Go version to build with (will be included in the source package)` )
475+ gobundle = flag .String ("gobundle" , "/tmp/go.tar.gz" , `Filesystem path to cache the downloaded Go bundles at` )
476+ gohash = flag .String ("gohash" , "" , `SHA256 checksum of the Go sources requested to build with` )
477+ signer = flag .String ("signer" , "" , `Signing key name, also used as package author` )
478+ upload = flag .String ("upload" , "" , `Where to upload the source package (usually "ethereum/ethereum")` )
479+ sshUser = flag .String ("sftp-user" , "" , `Username for SFTP upload (usually "geth-ci")` )
480+ workdir = flag .String ("workdir" , "" , `Output directory for packages (uses temp dir if unset)` )
481+ now = time .Now ()
467482 )
468483 flag .CommandLine .Parse (cmdline )
469484 * workdir = makeWorkdir (* workdir )
@@ -476,12 +491,25 @@ func doDebianSource(cmdline []string) {
476491 gpg .Stdin = bytes .NewReader (key )
477492 build .MustRun (gpg )
478493 }
479-
494+ // Download and verify the Go source package
495+ if err := build .EnsureGoSources (* goversion , hexutil .MustDecode ("0x" + * gohash ), * gobundle ); err != nil {
496+ log .Fatalf ("Failed to ensure Go source package: %v" , err )
497+ }
480498 // Create Debian packages and upload them
481499 for _ , pkg := range debPackages {
482- for _ , distro := range debDistros {
483- meta := newDebMetadata (distro , * signer , env , now , pkg .Name , pkg .Version , pkg .Executables )
500+ for distro , goboot := range debDistroGoBoots {
501+ // Prepare the debian package with the go-ethereum sources
502+ meta := newDebMetadata (distro , goboot , * signer , env , now , pkg .Name , pkg .Version , pkg .Executables )
484503 pkgdir := stageDebianSource (* workdir , meta )
504+
505+ // Ship the Go sources along so we have a proper thing to build with
506+ if err := build .ExtractTarballArchive (* gobundle , pkgdir ); err != nil {
507+ log .Fatalf ("Failed to extract Go sources: %v" , err )
508+ }
509+ if err := os .Rename (filepath .Join (pkgdir , "go" ), filepath .Join (pkgdir , ".go" )); err != nil {
510+ log .Fatalf ("Failed to rename Go source folder: %v" , err )
511+ }
512+ // Run the packaging and upload to the PPA
485513 debuild := exec .Command ("debuild" , "-S" , "-sa" , "-us" , "-uc" , "-d" , "-Zxz" )
486514 debuild .Dir = pkgdir
487515 build .MustRun (debuild )
@@ -561,7 +589,9 @@ type debPackage struct {
561589}
562590
563591type debMetadata struct {
564- Env build.Environment
592+ Env build.Environment
593+ GoBootPackage string
594+ GoBootPath string
565595
566596 PackageName string
567597
@@ -590,19 +620,21 @@ func (d debExecutable) Package() string {
590620 return d .BinaryName
591621}
592622
593- func newDebMetadata (distro , author string , env build.Environment , t time.Time , name string , version string , exes []debExecutable ) debMetadata {
623+ func newDebMetadata (distro , goboot , author string , env build.Environment , t time.Time , name string , version string , exes []debExecutable ) debMetadata {
594624 if author == "" {
595625 // No signing key, use default author.
596626 author = "Ethereum Builds <fjl@ethereum.org>"
597627 }
598628 return debMetadata {
599- PackageName : name ,
600- Env : env ,
601- Author : author ,
602- Distro : distro ,
603- Version : version ,
604- Time : t .Format (time .RFC1123Z ),
605- Executables : exes ,
629+ GoBootPackage : goboot ,
630+ GoBootPath : debGoBootPaths [goboot ],
631+ PackageName : name ,
632+ Env : env ,
633+ Author : author ,
634+ Distro : distro ,
635+ Version : version ,
636+ Time : t .Format (time .RFC1123Z ),
637+ Executables : exes ,
606638 }
607639}
608640
@@ -667,7 +699,6 @@ func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) {
667699 if err := os .Mkdir (pkgdir , 0755 ); err != nil {
668700 log .Fatal (err )
669701 }
670-
671702 // Copy the source code.
672703 build .MustRunCommand ("git" , "checkout-index" , "-a" , "--prefix" , pkgdir + string (filepath .Separator ))
673704
@@ -685,7 +716,6 @@ func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) {
685716 build .Render ("build/deb/" + meta .PackageName + "/deb.install" , install , 0644 , exe )
686717 build .Render ("build/deb/" + meta .PackageName + "/deb.docs" , docs , 0644 , exe )
687718 }
688-
689719 return pkgdir
690720}
691721
0 commit comments