Include build type in version

This commit is contained in:
Łukasz Magiera 2020-06-01 20:43:51 +02:00
parent e67253b6a8
commit 64f4e80446
15 changed files with 40 additions and 13 deletions

View File

@ -17,7 +17,7 @@ MODULES:=
CLEAN:= CLEAN:=
BINS:= BINS:=
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit='+git$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))' ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
ifneq ($(strip $(LDFLAGS)),) ifneq ($(strip $(LDFLAGS)),)
ldflags+=-extldflags=$(LDFLAGS) ldflags+=-extldflags=$(LDFLAGS)
endif endif

View File

@ -16,6 +16,8 @@ func init() {
abi.RegisteredProof_StackedDRG2KiBSeal: {}, abi.RegisteredProof_StackedDRG2KiBSeal: {},
} }
verifreg.MinVerifiedDealSize = big.NewInt(256) verifreg.MinVerifiedDealSize = big.NewInt(256)
BuildType |= Build2k
} }
// Seconds // Seconds

View File

@ -4,6 +4,7 @@ package build
func init() { func init() {
InsecurePoStValidation = true InsecurePoStValidation = true
BuildType |= BuildDebug
} }
// NOTE: Also includes settings from params_2k // NOTE: Also includes settings from params_2k

View File

@ -3,11 +3,33 @@ package build
import "fmt" import "fmt"
var CurrentCommit string var CurrentCommit string
var BuildType int
const (
BuildDefault = 0
Build2k = 0x1
BuildDebug = 0x3
)
func buildType() string {
switch BuildType {
case BuildDefault:
return "+default"
case BuildDebug:
return "+debug"
case Build2k:
return "+2k"
default:
return "+huh?"
}
}
// BuildVersion is the local build version, set by build system // BuildVersion is the local build version, set by build system
const BuildVersion = "0.4.0" const BuildVersion = "0.4.0"
var UserVersion = BuildVersion + CurrentCommit func UserVersion() string {
return BuildVersion + buildType() + CurrentCommit
}
type Version uint32 type Version uint32

View File

@ -23,7 +23,9 @@ var versionCmd = &cli.Command{
if err != nil { if err != nil {
return err return err
} }
fmt.Println(v) fmt.Println("Daemon: ", v)
fmt.Print("Local: ")
cli.VersionPrinter(cctx) cli.VersionPrinter(cctx)
return nil return nil
}, },

View File

@ -78,7 +78,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-bench", Name: "lotus-bench",
Usage: "Benchmark performance of lotus on your hardware", Usage: "Benchmark performance of lotus on your hardware",
Version: build.UserVersion, Version: build.UserVersion(),
Commands: []*cli.Command{ Commands: []*cli.Command{
proveCmd, proveCmd,
sealBenchCmd, sealBenchCmd,

View File

@ -29,7 +29,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-chainwatch", Name: "lotus-chainwatch",
Usage: "Devnet token distribution utility", Usage: "Devnet token distribution utility",
Version: build.UserVersion, Version: build.UserVersion(),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "repo", Name: "repo",

View File

@ -46,7 +46,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-fountain", Name: "lotus-fountain",
Usage: "Devnet token distribution utility", Usage: "Devnet token distribution utility",
Version: build.UserVersion, Version: build.UserVersion(),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "repo", Name: "repo",

View File

@ -36,7 +36,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-health", Name: "lotus-health",
Usage: "Tools for monitoring lotus daemon health", Usage: "Tools for monitoring lotus daemon health",
Version: build.UserVersion, Version: build.UserVersion(),
Commands: local, Commands: local,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -47,7 +47,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-seal-worker", Name: "lotus-seal-worker",
Usage: "Remote storage miner worker", Usage: "Remote storage miner worker",
Version: build.UserVersion, Version: build.UserVersion(),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: FlagStorageRepo, Name: FlagStorageRepo,

View File

@ -39,7 +39,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-seed", Name: "lotus-seed",
Usage: "Seal sectors for genesis miner", Usage: "Seal sectors for genesis miner",
Version: build.UserVersion, Version: build.UserVersion(),
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "sector-dir", Name: "sector-dir",

View File

@ -57,7 +57,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus-storage-miner", Name: "lotus-storage-miner",
Usage: "Filecoin decentralized storage network storage miner", Usage: "Filecoin decentralized storage network storage miner",
Version: build.UserVersion, Version: build.UserVersion(),
EnableShellCompletion: true, EnableShellCompletion: true,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -52,7 +52,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "lotus", Name: "lotus",
Usage: "Filecoin decentralized storage network client", Usage: "Filecoin decentralized storage network client",
Version: build.UserVersion, Version: build.UserVersion(),
EnableShellCompletion: true, EnableShellCompletion: true,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -100,7 +100,7 @@ func (a *CommonAPI) ID(context.Context) (peer.ID, error) {
func (a *CommonAPI) Version(context.Context) (api.Version, error) { func (a *CommonAPI) Version(context.Context) (api.Version, error) {
return api.Version{ return api.Version{
Version: build.UserVersion, Version: build.UserVersion(),
APIVersion: build.APIVersion, APIVersion: build.APIVersion,
BlockDelay: build.BlockDelay, BlockDelay: build.BlockDelay,

View File

@ -46,7 +46,7 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (RawHost,
libp2p.Peerstore(params.Peerstore), libp2p.Peerstore(params.Peerstore),
libp2p.NoListenAddrs, libp2p.NoListenAddrs,
libp2p.Ping(true), libp2p.Ping(true),
libp2p.UserAgent("lotus-" + build.UserVersion), libp2p.UserAgent("lotus-" + build.UserVersion()),
} }
for _, o := range params.Opts { for _, o := range params.Opts {
opts = append(opts, o...) opts = append(opts, o...)