Skip to content

Commit fb5d35d

Browse files
authored
Add support to set the target binary in the package config (#38)
1 parent 72763eb commit fb5d35d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmd/get.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ type hdConfig struct {
228228
Name string
229229
Filename string
230230
Binary string
231+
TargetBinary string
231232
URL string `yaml:"url"`
232233
Tar string
233234
Replacements map[string]string

cmd/install.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,24 @@ func (o *installOption) runE(cmd *cobra.Command, args []string) (err error) {
6161
}
6262
}
6363

64+
targetBinary := o.name
65+
if o.Package != nil && o.Package.TargetBinary != "" {
66+
// this is the desired binary file
67+
targetBinary = o.Package.TargetBinary
68+
}
69+
6470
var source string
6571
var target string
6672
if o.Tar {
6773
if err = o.extractFiles(o.Output, o.name); err == nil {
6874
source = fmt.Sprintf("%s/%s", filepath.Dir(o.Output), o.name)
69-
target = fmt.Sprintf("/usr/local/bin/%s", o.name)
75+
target = fmt.Sprintf("/usr/local/bin/%s", targetBinary)
7076
} else {
7177
err = fmt.Errorf("cannot extract %s from tar file, error: %v", o.Output, err)
7278
}
7379
} else {
7480
source = o.downloadOption.Output
75-
target = fmt.Sprintf("/usr/local/bin/%s", o.name)
81+
target = fmt.Sprintf("/usr/local/bin/%s", targetBinary)
7682
}
7783

7884
if err == nil {

0 commit comments

Comments
 (0)