build, internal, version: break ci.go/version->common dependency (#30638)
This PR tries to break the ci.go to common dependency by moving the version number out of params.
This commit is contained in:
parent
5c3b792e61
commit
dac54e31a7
22
build/ci.go
22
build/ci.go
@ -56,7 +56,7 @@ import (
|
|||||||
"github.com/cespare/cp"
|
"github.com/cespare/cp"
|
||||||
"github.com/ethereum/go-ethereum/crypto/signify"
|
"github.com/ethereum/go-ethereum/crypto/signify"
|
||||||
"github.com/ethereum/go-ethereum/internal/build"
|
"github.com/ethereum/go-ethereum/internal/build"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -108,7 +108,7 @@ var (
|
|||||||
// A debian package is created for all executables listed here.
|
// A debian package is created for all executables listed here.
|
||||||
debEthereum = debPackage{
|
debEthereum = debPackage{
|
||||||
Name: "ethereum",
|
Name: "ethereum",
|
||||||
Version: params.Version,
|
Version: version.Semantic,
|
||||||
Executables: debExecutables,
|
Executables: debExecutables,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ func doArchive(cmdline []string) {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
env = build.Env()
|
env = build.Env()
|
||||||
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
basegeth = archiveBasename(*arch, version.Archive(env.Commit))
|
||||||
geth = "geth-" + basegeth + ext
|
geth = "geth-" + basegeth + ext
|
||||||
alltools = "geth-alltools-" + basegeth + ext
|
alltools = "geth-alltools-" + basegeth + ext
|
||||||
)
|
)
|
||||||
@ -751,7 +751,7 @@ func doDockerBuildx(cmdline []string) {
|
|||||||
case env.Branch == "master":
|
case env.Branch == "master":
|
||||||
tags = []string{"latest"}
|
tags = []string{"latest"}
|
||||||
case strings.HasPrefix(env.Tag, "v1."):
|
case strings.HasPrefix(env.Tag, "v1."):
|
||||||
tags = []string{"stable", fmt.Sprintf("release-1.%d", params.VersionMinor), "v" + params.Version}
|
tags = []string{"stable", fmt.Sprintf("release-%v", version.Family), "v" + version.Semantic}
|
||||||
}
|
}
|
||||||
// Need to create a mult-arch builder
|
// Need to create a mult-arch builder
|
||||||
build.MustRunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform)
|
build.MustRunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform)
|
||||||
@ -767,7 +767,7 @@ func doDockerBuildx(cmdline []string) {
|
|||||||
gethImage := fmt.Sprintf("%s%s", spec.base, tag)
|
gethImage := fmt.Sprintf("%s%s", spec.base, tag)
|
||||||
build.MustRunCommand("docker", "buildx", "build",
|
build.MustRunCommand("docker", "buildx", "build",
|
||||||
"--build-arg", "COMMIT="+env.Commit,
|
"--build-arg", "COMMIT="+env.Commit,
|
||||||
"--build-arg", "VERSION="+params.VersionWithMeta,
|
"--build-arg", "VERSION="+version.WithMeta,
|
||||||
"--build-arg", "BUILDNUM="+env.Buildnum,
|
"--build-arg", "BUILDNUM="+env.Buildnum,
|
||||||
"--tag", gethImage,
|
"--tag", gethImage,
|
||||||
"--platform", *platform,
|
"--platform", *platform,
|
||||||
@ -1139,19 +1139,19 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
// Build the installer. This assumes that all the needed files have been previously
|
// Build the installer. This assumes that all the needed files have been previously
|
||||||
// built (don't mix building and packaging to keep cross compilation complexity to a
|
// built (don't mix building and packaging to keep cross compilation complexity to a
|
||||||
// minimum).
|
// minimum).
|
||||||
version := strings.Split(params.Version, ".")
|
ver := strings.Split(version.Semantic, ".")
|
||||||
if env.Commit != "" {
|
if env.Commit != "" {
|
||||||
version[2] += "-" + env.Commit[:8]
|
ver[2] += "-" + env.Commit[:8]
|
||||||
}
|
}
|
||||||
installer, err := filepath.Abs("geth-" + archiveBasename(*arch, params.ArchiveVersion(env.Commit)) + ".exe")
|
installer, err := filepath.Abs("geth-" + archiveBasename(*arch, version.Archive(env.Commit)) + ".exe")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to convert installer file path: %v", err)
|
log.Fatalf("Failed to convert installer file path: %v", err)
|
||||||
}
|
}
|
||||||
build.MustRunCommand("makensis.exe",
|
build.MustRunCommand("makensis.exe",
|
||||||
"/DOUTPUTFILE="+installer,
|
"/DOUTPUTFILE="+installer,
|
||||||
"/DMAJORVERSION="+version[0],
|
"/DMAJORVERSION="+ver[0],
|
||||||
"/DMINORVERSION="+version[1],
|
"/DMINORVERSION="+ver[1],
|
||||||
"/DBUILDVERSION="+version[2],
|
"/DBUILDVERSION="+ver[2],
|
||||||
"/DARCH="+*arch,
|
"/DARCH="+*arch,
|
||||||
filepath.Join(*workdir, "geth.nsi"),
|
filepath.Join(*workdir, "geth.nsi"),
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/naoina/toml"
|
"github.com/naoina/toml"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -130,7 +129,7 @@ func defaultNodeConfig() node.Config {
|
|||||||
git, _ := version.VCS()
|
git, _ := version.VCS()
|
||||||
cfg := node.DefaultConfig
|
cfg := node.DefaultConfig
|
||||||
cfg.Name = clientIdentifier
|
cfg.Name = clientIdentifier
|
||||||
cfg.Version = params.VersionWithCommit(git.Commit, git.Date)
|
cfg.Version = version.WithCommit(git.Commit, git.Date)
|
||||||
cfg.HTTPModules = append(cfg.HTTPModules, "eth")
|
cfg.HTTPModules = append(cfg.HTTPModules, "eth")
|
||||||
cfg.WSModules = append(cfg.WSModules, "eth")
|
cfg.WSModules = append(cfg.WSModules, "eth")
|
||||||
cfg.IPCPath = "geth.ipc"
|
cfg.IPCPath = "geth.ipc"
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -60,7 +60,7 @@ func TestConsoleWelcome(t *testing.T) {
|
|||||||
geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
||||||
geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
geth.SetTemplateFunc("gover", runtime.Version)
|
geth.SetTemplateFunc("gover", runtime.Version)
|
||||||
geth.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
|
geth.SetTemplateFunc("gethver", func() string { return version.WithCommit("", "") })
|
||||||
geth.SetTemplateFunc("niltime", func() string {
|
geth.SetTemplateFunc("niltime", func() string {
|
||||||
return time.Unix(1695902100, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
return time.Unix(1695902100, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
||||||
})
|
})
|
||||||
@ -129,7 +129,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
|
|||||||
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
||||||
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
attach.SetTemplateFunc("gover", runtime.Version)
|
attach.SetTemplateFunc("gover", runtime.Version)
|
||||||
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
|
attach.SetTemplateFunc("gethver", func() string { return version.WithCommit("", "") })
|
||||||
attach.SetTemplateFunc("niltime", func() string {
|
attach.SetTemplateFunc("niltime", func() string {
|
||||||
return time.Unix(1695902100, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
return time.Unix(1695902100, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/version"
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ func printVersion(ctx *cli.Context) error {
|
|||||||
git, _ := version.VCS()
|
git, _ := version.VCS()
|
||||||
|
|
||||||
fmt.Println(strings.Title(clientIdentifier))
|
fmt.Println(strings.Title(clientIdentifier))
|
||||||
fmt.Println("Version:", params.VersionWithMeta)
|
fmt.Println("Version:", version.WithMeta)
|
||||||
if git.Commit != "" {
|
if git.Commit != "" {
|
||||||
fmt.Println("Git Commit:", git.Commit)
|
fmt.Println("Git Commit:", git.Commit)
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/internal/shutdowncheck"
|
"github.com/ethereum/go-ethereum/internal/shutdowncheck"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/miner"
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
@ -56,6 +57,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
gethversion "github.com/ethereum/go-ethereum/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains the configuration options of the ETH protocol.
|
// Config contains the configuration options of the ETH protocol.
|
||||||
@ -172,7 +174,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
|
|
||||||
if !config.SkipBcVersionCheck {
|
if !config.SkipBcVersionCheck {
|
||||||
if bcVersion != nil && *bcVersion > core.BlockChainVersion {
|
if bcVersion != nil && *bcVersion > core.BlockChainVersion {
|
||||||
return nil, fmt.Errorf("database version is v%d, Geth %s only supports v%d", *bcVersion, params.VersionWithMeta, core.BlockChainVersion)
|
return nil, fmt.Errorf("database version is v%d, Geth %s only supports v%d", *bcVersion, version.WithMeta, core.BlockChainVersion)
|
||||||
} else if bcVersion == nil || *bcVersion < core.BlockChainVersion {
|
} else if bcVersion == nil || *bcVersion < core.BlockChainVersion {
|
||||||
if bcVersion != nil { // only print warning on upgrade, not on init
|
if bcVersion != nil { // only print warning on upgrade, not on init
|
||||||
log.Warn("Upgrade blockchain database version", "from", dbVer, "to", core.BlockChainVersion)
|
log.Warn("Upgrade blockchain database version", "from", dbVer, "to", core.BlockChainVersion)
|
||||||
@ -278,7 +280,7 @@ func makeExtraData(extra []byte) []byte {
|
|||||||
if len(extra) == 0 {
|
if len(extra) == 0 {
|
||||||
// create default extradata
|
// create default extradata
|
||||||
extra, _ = rlp.EncodeToBytes([]interface{}{
|
extra, _ = rlp.EncodeToBytes([]interface{}{
|
||||||
uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch),
|
uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch),
|
||||||
"geth",
|
"geth",
|
||||||
runtime.Version(),
|
runtime.Version(),
|
||||||
runtime.GOOS,
|
runtime.GOOS,
|
||||||
|
@ -37,7 +37,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/miner"
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/params/forks"
|
"github.com/ethereum/go-ethereum/params/forks"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
@ -1194,7 +1193,7 @@ func (api *ConsensusAPI) GetClientVersionV1(info engine.ClientVersionV1) []engin
|
|||||||
{
|
{
|
||||||
Code: engine.ClientCode,
|
Code: engine.ClientCode,
|
||||||
Name: engine.ClientName,
|
Name: engine.ClientName,
|
||||||
Version: params.VersionWithMeta,
|
Version: version.WithMeta,
|
||||||
Commit: hexutil.Encode(commit),
|
Commit: hexutil.Encode(commit),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
"github.com/ethereum/go-ethereum/miner"
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
@ -1823,7 +1824,7 @@ func TestGetClientVersion(t *testing.T) {
|
|||||||
t.Fatalf("expected only one returned client version, got %d", len(infos))
|
t.Fatalf("expected only one returned client version, got %d", len(infos))
|
||||||
}
|
}
|
||||||
info = infos[0]
|
info = infos[0]
|
||||||
if info.Code != engine.ClientCode || info.Name != engine.ClientName || info.Version != params.VersionWithMeta {
|
if info.Code != engine.ClientCode || info.Name != engine.ClientName || info.Version != version.WithMeta {
|
||||||
t.Fatalf("client info does match expected, got %s", info.String())
|
t.Fatalf("client info does match expected, got %s", info.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/version"
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@ -39,7 +38,7 @@ func NewApp(usage string) *cli.App {
|
|||||||
git, _ := version.VCS()
|
git, _ := version.VCS()
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Version = params.VersionWithCommit(git.Commit, git.Date)
|
app.Version = version.WithCommit(git.Commit, git.Date)
|
||||||
app.Usage = usage
|
app.Usage = usage
|
||||||
app.Copyright = "Copyright 2013-2024 The go-ethereum Authors"
|
app.Copyright = "Copyright 2013-2024 The go-ethereum Authors"
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
|
@ -28,6 +28,31 @@ const (
|
|||||||
ourTimeLayout = "20060102"
|
ourTimeLayout = "20060102"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// These variables are set at build-time by the linker when the build is
|
||||||
|
// done by build/ci.go.
|
||||||
|
var gitCommit, gitDate string
|
||||||
|
|
||||||
|
// VCSInfo represents the git repository state.
|
||||||
|
type VCSInfo struct {
|
||||||
|
Commit string // head commit hash
|
||||||
|
Date string // commit time in YYYYMMDD format
|
||||||
|
Dirty bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// VCS returns version control information of the current executable.
|
||||||
|
func VCS() (VCSInfo, bool) {
|
||||||
|
if gitCommit != "" {
|
||||||
|
// Use information set by the build script if present.
|
||||||
|
return VCSInfo{Commit: gitCommit, Date: gitDate}, true
|
||||||
|
}
|
||||||
|
if buildInfo, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
if buildInfo.Main.Path == ourPath {
|
||||||
|
return buildInfoVCS(buildInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return VCSInfo{}, false
|
||||||
|
}
|
||||||
|
|
||||||
// buildInfoVCS returns VCS information of the build.
|
// buildInfoVCS returns VCS information of the build.
|
||||||
func buildInfoVCS(info *debug.BuildInfo) (s VCSInfo, ok bool) {
|
func buildInfoVCS(info *debug.BuildInfo) (s VCSInfo, ok bool) {
|
||||||
for _, v := range info.Settings {
|
for _, v := range info.Settings {
|
||||||
|
@ -23,34 +23,49 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ourPath = "github.com/ethereum/go-ethereum" // Path to our module
|
const ourPath = "github.com/ethereum/go-ethereum" // Path to our module
|
||||||
|
|
||||||
// These variables are set at build-time by the linker when the build is
|
// Family holds the textual version string for major.minor
|
||||||
// done by build/ci.go.
|
var Family = fmt.Sprintf("%d.%d", version.Major, version.Minor)
|
||||||
var gitCommit, gitDate string
|
|
||||||
|
|
||||||
// VCSInfo represents the git repository state.
|
// Semantic holds the textual version string for major.minor.patch.
|
||||||
type VCSInfo struct {
|
var Semantic = fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch)
|
||||||
Commit string // head commit hash
|
|
||||||
Date string // commit time in YYYYMMDD format
|
// WithMeta holds the textual version string including the metadata.
|
||||||
Dirty bool
|
var WithMeta = func() string {
|
||||||
|
v := Semantic
|
||||||
|
if version.Meta != "" {
|
||||||
|
v += "-" + version.Meta
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}()
|
||||||
|
|
||||||
|
func WithCommit(gitCommit, gitDate string) string {
|
||||||
|
vsn := WithMeta
|
||||||
|
if len(gitCommit) >= 8 {
|
||||||
|
vsn += "-" + gitCommit[:8]
|
||||||
|
}
|
||||||
|
if (version.Meta != "stable") && (gitDate != "") {
|
||||||
|
vsn += "-" + gitDate
|
||||||
|
}
|
||||||
|
return vsn
|
||||||
}
|
}
|
||||||
|
|
||||||
// VCS returns version control information of the current executable.
|
// Archive holds the textual version string used for Geth archives. e.g.
|
||||||
func VCS() (VCSInfo, bool) {
|
// "1.8.11-dea1ce05" for stable releases, or "1.8.13-unstable-21c059b6" for unstable
|
||||||
if gitCommit != "" {
|
// releases.
|
||||||
// Use information set by the build script if present.
|
func Archive(gitCommit string) string {
|
||||||
return VCSInfo{Commit: gitCommit, Date: gitDate}, true
|
vsn := Semantic
|
||||||
|
if version.Meta != "stable" {
|
||||||
|
vsn += "-" + version.Meta
|
||||||
}
|
}
|
||||||
if buildInfo, ok := debug.ReadBuildInfo(); ok {
|
if len(gitCommit) >= 8 {
|
||||||
if buildInfo.Main.Path == ourPath {
|
vsn += "-" + gitCommit[:8]
|
||||||
return buildInfoVCS(buildInfo)
|
|
||||||
}
|
}
|
||||||
}
|
return vsn
|
||||||
return VCSInfo{}, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientName creates a software name/version identifier according to common
|
// ClientName creates a software name/version identifier according to common
|
||||||
@ -59,7 +74,7 @@ func ClientName(clientIdentifier string) string {
|
|||||||
git, _ := VCS()
|
git, _ := VCS()
|
||||||
return fmt.Sprintf("%s/v%v/%v-%v/%v",
|
return fmt.Sprintf("%s/v%v/%v-%v/%v",
|
||||||
strings.Title(clientIdentifier),
|
strings.Title(clientIdentifier),
|
||||||
params.VersionWithCommit(git.Commit, git.Date),
|
WithCommit(git.Commit, git.Date),
|
||||||
runtime.GOOS, runtime.GOARCH,
|
runtime.GOOS, runtime.GOARCH,
|
||||||
runtime.Version(),
|
runtime.Version(),
|
||||||
)
|
)
|
||||||
@ -72,7 +87,7 @@ func ClientName(clientIdentifier string) string {
|
|||||||
// it will assume it's imported by a third-party and will return the imported
|
// it will assume it's imported by a third-party and will return the imported
|
||||||
// version and whether it was replaced by another module.
|
// version and whether it was replaced by another module.
|
||||||
func Info() (version, vcs string) {
|
func Info() (version, vcs string) {
|
||||||
version = params.VersionWithMeta
|
version = WithMeta
|
||||||
buildInfo, ok := debug.ReadBuildInfo()
|
buildInfo, ok := debug.ReadBuildInfo()
|
||||||
if !ok {
|
if !ok {
|
||||||
return version, ""
|
return version, ""
|
||||||
@ -115,7 +130,7 @@ func versionInfo(info *debug.BuildInfo) string {
|
|||||||
// If our module path wasn't imported, it's unclear which
|
// If our module path wasn't imported, it's unclear which
|
||||||
// version of our code they are running. Fallback to hardcoded
|
// version of our code they are running. Fallback to hardcoded
|
||||||
// version.
|
// version.
|
||||||
return version + fmt.Sprintf("geth %s", params.VersionWithMeta)
|
return version + fmt.Sprintf("geth %s", WithMeta)
|
||||||
}
|
}
|
||||||
// Our package is a dependency for the main module. Return path and
|
// Our package is a dependency for the main module. Return path and
|
||||||
// version data for both.
|
// version data for both.
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
// Copyright 2016 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package params
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
VersionMajor = 1 // Major version component of the current release
|
|
||||||
VersionMinor = 14 // Minor version component of the current release
|
|
||||||
VersionPatch = 12 // Patch version component of the current release
|
|
||||||
VersionMeta = "unstable" // Version metadata to append to the version string
|
|
||||||
)
|
|
||||||
|
|
||||||
// Version holds the textual version string.
|
|
||||||
var Version = func() string {
|
|
||||||
return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// VersionWithMeta holds the textual version string including the metadata.
|
|
||||||
var VersionWithMeta = func() string {
|
|
||||||
v := Version
|
|
||||||
if VersionMeta != "" {
|
|
||||||
v += "-" + VersionMeta
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}()
|
|
||||||
|
|
||||||
// ArchiveVersion holds the textual version string used for Geth archives. e.g.
|
|
||||||
// "1.8.11-dea1ce05" for stable releases, or "1.8.13-unstable-21c059b6" for unstable
|
|
||||||
// releases.
|
|
||||||
func ArchiveVersion(gitCommit string) string {
|
|
||||||
vsn := Version
|
|
||||||
if VersionMeta != "stable" {
|
|
||||||
vsn += "-" + VersionMeta
|
|
||||||
}
|
|
||||||
if len(gitCommit) >= 8 {
|
|
||||||
vsn += "-" + gitCommit[:8]
|
|
||||||
}
|
|
||||||
return vsn
|
|
||||||
}
|
|
||||||
|
|
||||||
func VersionWithCommit(gitCommit, gitDate string) string {
|
|
||||||
vsn := VersionWithMeta
|
|
||||||
if len(gitCommit) >= 8 {
|
|
||||||
vsn += "-" + gitCommit[:8]
|
|
||||||
}
|
|
||||||
if (VersionMeta != "stable") && (gitDate != "") {
|
|
||||||
vsn += "-" + gitDate
|
|
||||||
}
|
|
||||||
return vsn
|
|
||||||
}
|
|
24
version/version.go
Normal file
24
version/version.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package version
|
||||||
|
|
||||||
|
const (
|
||||||
|
Major = 1 // Major version component of the current release
|
||||||
|
Minor = 14 // Minor version component of the current release
|
||||||
|
Patch = 12 // Patch version component of the current release
|
||||||
|
Meta = "unstable" // Version metadata to append to the version string
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user