Skip to content

Commit a5d5609

Browse files
nonsensekaralabe
authored andcommitted
build: rename swarm deb package to ethereum-swarm; change swarm deb version from 1.8.x to 0.3.x (#16988)
* build: add support for different package and binary names * build: bump up copyright date * build: change default PackageName to empty string * build, internal, swarm: enhance build/release process * build: hack ethereum-swarm as a "depends" in deb package * build/ci: remove redundant variables * build, cmd, mobile, params, swarm: remove VERSION file; rename Version to VersionMeta; * internal: remove VERSION() method which reads VERSION file * build: fix VersionFilePath to Version * Makefile: remove clean_go_build_cache.sh until it works * Makefile: revert removal of clean_go_build_cache.sh
1 parent 93c0f17 commit a5d5609

26 files changed

Lines changed: 277 additions & 96 deletions

File tree

‎VERSION‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎build/ci.go‎

Lines changed: 123 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ import (
5959
"time"
6060

6161
"github.com/ethereum/go-ethereum/internal/build"
62+
"github.com/ethereum/go-ethereum/params"
63+
sv "github.com/ethereum/go-ethereum/swarm/version"
6264
)
6365

6466
var (
@@ -77,46 +79,74 @@ var (
7779
executablePath("geth"),
7880
executablePath("puppeth"),
7981
executablePath("rlpdump"),
80-
executablePath("swarm"),
8182
executablePath("wnode"),
8283
}
8384

85+
// Files that end up in the swarm*.zip archive.
86+
swarmArchiveFiles = []string{
87+
"COPYING",
88+
executablePath("swarm"),
89+
}
90+
8491
// A debian package is created for all executables listed here.
8592
debExecutables = []debExecutable{
8693
{
87-
Name: "abigen",
94+
BinaryName: "abigen",
8895
Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.",
8996
},
9097
{
91-
Name: "bootnode",
98+
BinaryName: "bootnode",
9299
Description: "Ethereum bootnode.",
93100
},
94101
{
95-
Name: "evm",
102+
BinaryName: "evm",
96103
Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.",
97104
},
98105
{
99-
Name: "geth",
106+
BinaryName: "geth",
100107
Description: "Ethereum CLI client.",
101108
},
102109
{
103-
Name: "puppeth",
110+
BinaryName: "puppeth",
104111
Description: "Ethereum private network manager.",
105112
},
106113
{
107-
Name: "rlpdump",
114+
BinaryName: "rlpdump",
108115
Description: "Developer utility tool that prints RLP structures.",
109116
},
110117
{
111-
Name: "swarm",
112-
Description: "Ethereum Swarm daemon and tools",
118+
BinaryName: "wnode",
119+
Description: "Ethereum Whisper diagnostic tool",
113120
},
121+
}
122+
123+
// A debian package is created for all executables listed here.
124+
debSwarmExecutables = []debExecutable{
114125
{
115-
Name: "wnode",
116-
Description: "Ethereum Whisper diagnostic tool",
126+
BinaryName: "swarm",
127+
PackageName: "ethereum-swarm",
128+
Description: "Ethereum Swarm daemon and tools",
117129
},
118130
}
119131

132+
debEthereum = debPackage{
133+
Name: "ethereum",
134+
Version: params.Version,
135+
Executables: debExecutables,
136+
}
137+
138+
debSwarm = debPackage{
139+
Name: "ethereum-swarm",
140+
Version: sv.Version,
141+
Executables: debSwarmExecutables,
142+
}
143+
144+
// Debian meta packages to build and push to Ubuntu PPA
145+
debPackages = []debPackage{
146+
debSwarm,
147+
debEthereum,
148+
}
149+
120150
// Distros for which packages are created.
121151
// Note: vivid is unsupported because there is no golang-1.6 package for it.
122152
// Note: wily is unsupported because it was officially deprecated on lanchpad.
@@ -351,7 +381,6 @@ func doLint(cmdline []string) {
351381
}
352382

353383
// Release Packaging
354-
355384
func doArchive(cmdline []string) {
356385
var (
357386
arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging")
@@ -371,10 +400,14 @@ func doArchive(cmdline []string) {
371400
}
372401

373402
var (
374-
env = build.Env()
375-
base = archiveBasename(*arch, env)
376-
geth = "geth-" + base + ext
377-
alltools = "geth-alltools-" + base + ext
403+
env = build.Env()
404+
405+
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
406+
geth = "geth-" + basegeth + ext
407+
alltools = "geth-alltools-" + basegeth + ext
408+
409+
baseswarm = archiveBasename(*arch, sv.ArchiveVersion(env.Commit))
410+
swarm = "swarm-" + baseswarm + ext
378411
)
379412
maybeSkipArchive(env)
380413
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
@@ -383,14 +416,17 @@ func doArchive(cmdline []string) {
383416
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
384417
log.Fatal(err)
385418
}
386-
for _, archive := range []string{geth, alltools} {
419+
if err := build.WriteArchive(swarm, swarmArchiveFiles); err != nil {
420+
log.Fatal(err)
421+
}
422+
for _, archive := range []string{geth, alltools, swarm} {
387423
if err := archiveUpload(archive, *upload, *signer); err != nil {
388424
log.Fatal(err)
389425
}
390426
}
391427
}
392428

393-
func archiveBasename(arch string, env build.Environment) string {
429+
func archiveBasename(arch string, archiveVersion string) string {
394430
platform := runtime.GOOS + "-" + arch
395431
if arch == "arm" {
396432
platform += os.Getenv("GOARM")
@@ -401,18 +437,7 @@ func archiveBasename(arch string, env build.Environment) string {
401437
if arch == "ios" {
402438
platform = "ios-all"
403439
}
404-
return platform + "-" + archiveVersion(env)
405-
}
406-
407-
func archiveVersion(env build.Environment) string {
408-
version := build.VERSION()
409-
if isUnstableBuild(env) {
410-
version += "-unstable"
411-
}
412-
if env.Commit != "" {
413-
version += "-" + env.Commit[:8]
414-
}
415-
return version
440+
return platform + "-" + archiveVersion
416441
}
417442

418443
func archiveUpload(archive string, blobstore string, signer string) error {
@@ -462,7 +487,6 @@ func maybeSkipArchive(env build.Environment) {
462487
}
463488

464489
// Debian Packaging
465-
466490
func doDebianSource(cmdline []string) {
467491
var (
468492
signer = flag.String("signer", "", `Signing key name, also used as package author`)
@@ -486,21 +510,23 @@ func doDebianSource(cmdline []string) {
486510
build.MustRun(gpg)
487511
}
488512

489-
// Create the packages.
490-
for _, distro := range debDistros {
491-
meta := newDebMetadata(distro, *signer, env, now)
492-
pkgdir := stageDebianSource(*workdir, meta)
493-
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc")
494-
debuild.Dir = pkgdir
495-
build.MustRun(debuild)
513+
// Create Debian packages and upload them
514+
for _, pkg := range debPackages {
515+
for _, distro := range debDistros {
516+
meta := newDebMetadata(distro, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables)
517+
pkgdir := stageDebianSource(*workdir, meta)
518+
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc")
519+
debuild.Dir = pkgdir
520+
build.MustRun(debuild)
496521

497-
changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString())
498-
changes = filepath.Join(*workdir, changes)
499-
if *signer != "" {
500-
build.MustRunCommand("debsign", changes)
501-
}
502-
if *upload != "" {
503-
build.MustRunCommand("dput", *upload, changes)
522+
changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString())
523+
changes = filepath.Join(*workdir, changes)
524+
if *signer != "" {
525+
build.MustRunCommand("debsign", changes)
526+
}
527+
if *upload != "" {
528+
build.MustRunCommand("dput", *upload, changes)
529+
}
504530
}
505531
}
506532
}
@@ -525,9 +551,17 @@ func isUnstableBuild(env build.Environment) bool {
525551
return true
526552
}
527553

554+
type debPackage struct {
555+
Name string // the name of the Debian package to produce, e.g. "ethereum", or "ethereum-swarm"
556+
Version string // the clean version of the debPackage, e.g. 1.8.12 or 0.3.0, without any metadata
557+
Executables []debExecutable // executables to be included in the package
558+
}
559+
528560
type debMetadata struct {
529561
Env build.Environment
530562

563+
PackageName string
564+
531565
// go-ethereum version being built. Note that this
532566
// is not the debian package version. The package version
533567
// is constructed by VersionString.
@@ -539,31 +573,43 @@ type debMetadata struct {
539573
}
540574

541575
type debExecutable struct {
542-
Name, Description string
576+
PackageName string
577+
BinaryName string
578+
Description string
579+
}
580+
581+
// Package returns the name of the package if present, or
582+
// fallbacks to BinaryName
583+
func (d debExecutable) Package() string {
584+
if d.PackageName != "" {
585+
return d.PackageName
586+
}
587+
return d.BinaryName
543588
}
544589

545-
func newDebMetadata(distro, author string, env build.Environment, t time.Time) debMetadata {
590+
func newDebMetadata(distro, author string, env build.Environment, t time.Time, name string, version string, exes []debExecutable) debMetadata {
546591
if author == "" {
547592
// No signing key, use default author.
548593
author = "Ethereum Builds <fjl@ethereum.org>"
549594
}
550595
return debMetadata{
596+
PackageName: name,
551597
Env: env,
552598
Author: author,
553599
Distro: distro,
554-
Version: build.VERSION(),
600+
Version: version,
555601
Time: t.Format(time.RFC1123Z),
556-
Executables: debExecutables,
602+
Executables: exes,
557603
}
558604
}
559605

560606
// Name returns the name of the metapackage that depends
561607
// on all executable packages.
562608
func (meta debMetadata) Name() string {
563609
if isUnstableBuild(meta.Env) {
564-
return "ethereum-unstable"
610+
return meta.PackageName + "-unstable"
565611
}
566-
return "ethereum"
612+
return meta.PackageName
567613
}
568614

569615
// VersionString returns the debian version of the packages.
@@ -590,9 +636,20 @@ func (meta debMetadata) ExeList() string {
590636
// ExeName returns the package name of an executable package.
591637
func (meta debMetadata) ExeName(exe debExecutable) string {
592638
if isUnstableBuild(meta.Env) {
593-
return exe.Name + "-unstable"
639+
return exe.Package() + "-unstable"
594640
}
595-
return exe.Name
641+
return exe.Package()
642+
}
643+
644+
// EthereumSwarmPackageName returns the name of the swarm package based on
645+
// environment, e.g. "ethereum-swarm-unstable", or "ethereum-swarm".
646+
// This is needed so that we make sure that "ethereum" package,
647+
// depends on and installs "ethereum-swarm"
648+
func (meta debMetadata) EthereumSwarmPackageName() string {
649+
if isUnstableBuild(meta.Env) {
650+
return debSwarm.Name + "-unstable"
651+
}
652+
return debSwarm.Name
596653
}
597654

598655
// ExeConflicts returns the content of the Conflicts field
@@ -607,7 +664,7 @@ func (meta debMetadata) ExeConflicts(exe debExecutable) string {
607664
// be preferred and the conflicting files should be handled via
608665
// alternates. We might do this eventually but using a conflict is
609666
// easier now.
610-
return "ethereum, " + exe.Name
667+
return "ethereum, " + exe.Package()
611668
}
612669
return ""
613670
}
@@ -624,24 +681,23 @@ func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) {
624681

625682
// Put the debian build files in place.
626683
debian := filepath.Join(pkgdir, "debian")
627-
build.Render("build/deb.rules", filepath.Join(debian, "rules"), 0755, meta)
628-
build.Render("build/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta)
629-
build.Render("build/deb.control", filepath.Join(debian, "control"), 0644, meta)
630-
build.Render("build/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta)
684+
build.Render("build/deb/"+meta.PackageName+"/deb.rules", filepath.Join(debian, "rules"), 0755, meta)
685+
build.Render("build/deb/"+meta.PackageName+"/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta)
686+
build.Render("build/deb/"+meta.PackageName+"/deb.control", filepath.Join(debian, "control"), 0644, meta)
687+
build.Render("build/deb/"+meta.PackageName+"/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta)
631688
build.RenderString("8\n", filepath.Join(debian, "compat"), 0644, meta)
632689
build.RenderString("3.0 (native)\n", filepath.Join(debian, "source/format"), 0644, meta)
633690
for _, exe := range meta.Executables {
634691
install := filepath.Join(debian, meta.ExeName(exe)+".install")
635692
docs := filepath.Join(debian, meta.ExeName(exe)+".docs")
636-
build.Render("build/deb.install", install, 0644, exe)
637-
build.Render("build/deb.docs", docs, 0644, exe)
693+
build.Render("build/deb/"+meta.PackageName+"/deb.install", install, 0644, exe)
694+
build.Render("build/deb/"+meta.PackageName+"/deb.docs", docs, 0644, exe)
638695
}
639696

640697
return pkgdir
641698
}
642699

643700
// Windows installer
644-
645701
func doWindowsInstaller(cmdline []string) {
646702
// Parse the flags and make skip installer generation on PRs
647703
var (
@@ -691,11 +747,11 @@ func doWindowsInstaller(cmdline []string) {
691747
// Build the installer. This assumes that all the needed files have been previously
692748
// built (don't mix building and packaging to keep cross compilation complexity to a
693749
// minimum).
694-
version := strings.Split(build.VERSION(), ".")
750+
version := strings.Split(params.Version, ".")
695751
if env.Commit != "" {
696752
version[2] += "-" + env.Commit[:8]
697753
}
698-
installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, env) + ".exe")
754+
installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, params.ArchiveVersion(env.Commit)) + ".exe")
699755
build.MustRunCommand("makensis.exe",
700756
"/DOUTPUTFILE="+installer,
701757
"/DMAJORVERSION="+version[0],
@@ -747,7 +803,7 @@ func doAndroidArchive(cmdline []string) {
747803
maybeSkipArchive(env)
748804

749805
// Sign and upload the archive to Azure
750-
archive := "geth-" + archiveBasename("android", env) + ".aar"
806+
archive := "geth-" + archiveBasename("android", params.ArchiveVersion(env.Commit)) + ".aar"
751807
os.Rename("geth.aar", archive)
752808

753809
if err := archiveUpload(archive, *upload, *signer); err != nil {
@@ -832,7 +888,7 @@ func newMavenMetadata(env build.Environment) mavenMetadata {
832888
}
833889
}
834890
// Render the version and package strings
835-
version := build.VERSION()
891+
version := params.Version
836892
if isUnstableBuild(env) {
837893
version += "-SNAPSHOT"
838894
}
@@ -867,7 +923,7 @@ func doXCodeFramework(cmdline []string) {
867923
build.MustRun(bind)
868924
return
869925
}
870-
archive := "geth-" + archiveBasename("ios", env)
926+
archive := "geth-" + archiveBasename("ios", params.ArchiveVersion(env.Commit))
871927
if err := os.Mkdir(archive, os.ModePerm); err != nil {
872928
log.Fatal(err)
873929
}
@@ -923,7 +979,7 @@ func newPodMetadata(env build.Environment, archive string) podMetadata {
923979
}
924980
}
925981
}
926-
version := build.VERSION()
982+
version := params.Version
927983
if isUnstableBuild(env) {
928984
version += "-unstable." + env.Buildnum
929985
}

‎build/deb.install‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)