Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix binpath not work #1545

Merged
merged 3 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.Split(binPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use filepath.Dir() for this usage.


if err := os.MkdirAll(p.InstanceDir, 0755); err != nil {
return nil, err
Expand Down