Skip to content

Commit

Permalink
fix binpath not work (#1545)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Sep 2, 2021
1 parent 699add6 commit 551e758
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions components/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
28 changes: 12 additions & 16 deletions pkg/exec/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,32 @@ 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 {
return nil, errors.Trace(err)
}
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
Expand Down

0 comments on commit 551e758

Please sign in to comment.