From 551e7587a40d88cbdff899be5a341b45fb368ed0 Mon Sep 17 00:00:00 2001 From: nexustar Date: Thu, 2 Sep 2021 17:22:16 +0800 Subject: [PATCH] fix binpath not work (#1545) --- components/playground/main.go | 8 ++++---- pkg/exec/run.go | 28 ++++++++++++---------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/components/playground/main.go b/components/playground/main.go index 1515a46e64..04f0ef9610 100644 --- a/components/playground/main.go +++ b/components/playground/main.go @@ -245,18 +245,18 @@ Examples: // using a self build binary) and version number is not set, we assume // it is a developer and use the latest release version by default. // The platform string used to resolve the full version number is set - // to "linux-amd64" as this is the platform that every released version + // to "linux/amd64" as this is the platform that every released version // is available. // For platforms lacks of support for some versions, e.g., darwin-amd64, // specifically set a valid version for it, or use custom binpath for // all components used. // If none of the binpath arguments is set, use the platform of the // playground binary itself. - if options.TiDB.BinPath != "" || options.TiKV.BinPath != "" || + if (options.TiDB.BinPath != "" || options.TiKV.BinPath != "" || options.PD.BinPath != "" || options.TiFlash.BinPath != "" || options.TiCDC.BinPath != "" || options.Pump.BinPath != "" || - options.Drainer.BinPath != "" && options.Version == "" { - version, err = env.V1Repository().ResolveComponentVersionWithPlatform(spec.ComponentTiDB, options.Version, "linux-amd64") + options.Drainer.BinPath != "") && options.Version == "" { + version, err = env.V1Repository().ResolveComponentVersionWithPlatform(spec.ComponentTiDB, options.Version, "linux/amd64") } else { version, err = env.V1Repository().ResolveComponentVersion(spec.ComponentTiDB, options.Version) } diff --git a/pkg/exec/run.go b/pkg/exec/run.go index 773caffcef..da04db63d6 100644 --- a/pkg/exec/run.go +++ b/pkg/exec/run.go @@ -176,24 +176,9 @@ type PrepareCommandParams struct { // PrepareCommand will download necessary component and returns a *exec.Cmd func PrepareCommand(p *PrepareCommandParams) (*exec.Cmd, error) { env := p.Env - - selectVer, err := env.DownloadComponentIfMissing(p.Component, p.Version) - if err != nil { - return nil, err - } - - // playground && cluster version must greater than v1.0.0 - if (p.Component == "playground" || p.Component == "cluster") && semver.Compare(selectVer.String(), "v1.0.0") < 0 { - return nil, errors.Errorf("incompatible component version, please use `tiup update %s` to upgrade to the latest version", p.Component) - } - profile := env.Profile() - installPath, err := profile.ComponentInstalledPath(p.Component, selectVer) - if err != nil { - return nil, err - } - binPath := p.BinPath + if binPath != "" { tmp, err := filepath.Abs(binPath) if err != nil { @@ -201,11 +186,22 @@ func PrepareCommand(p *PrepareCommandParams) (*exec.Cmd, error) { } binPath = tmp } else { + selectVer, err := env.DownloadComponentIfMissing(p.Component, p.Version) + if err != nil { + return nil, err + } + + // playground && cluster version must greater than v1.0.0 + if (p.Component == "playground" || p.Component == "cluster") && semver.Compare(selectVer.String(), "v1.0.0") < 0 { + return nil, errors.Errorf("incompatible component version, please use `tiup update %s` to upgrade to the latest version", p.Component) + } + binPath, err = env.BinaryPath(p.Component, selectVer) if err != nil { return nil, err } } + installPath := filepath.Dir(binPath) if err := os.MkdirAll(p.InstanceDir, 0755); err != nil { return nil, err