diff --git a/.toolbox.yaml b/.toolbox.yaml index 169025c..fa02d03 100644 --- a/.toolbox.yaml +++ b/.toolbox.yaml @@ -1,4 +1,8 @@ tools: + age: + additional: + - age-keygen + github: FiloSottile/age gh: github: cli/cli check: version diff --git a/pkg/fetcher/fetch.go b/pkg/fetcher/fetch.go index 4c64ada..39cba51 100644 --- a/pkg/fetcher/fetch.go +++ b/pkg/fetcher/fetch.go @@ -410,8 +410,20 @@ func (f *fetcher) fetchTool(tool *types.Tool, toolName string, url string, tmpDi if !extracted { downloadedName = fileName } + if err = f.moveToTarget(tool, toolName, targetDir, dir, downloadedName, false); err != nil { + return err + } + + for _, add := range tool.Additional { + if toolName != add { + if err = f.moveToTarget(tool, add, targetDir, dir, add, true); err != nil { + return err + } + } + } + + return nil - return f.moveToTarget(tool, toolName, targetDir, dir, downloadedName) } func (f *fetcher) validate(targetPath string, check string) error { @@ -446,6 +458,7 @@ func (f *fetcher) moveToTarget( targetDir string, dir string, downloadedName string, + isAdditional bool, ) error { targetFilePath, err := filepath.Abs(filepath.Join(targetDir, trueToolName)) if err != nil { @@ -463,7 +476,7 @@ func (f *fetcher) moveToTarget( if err != nil { return err } - if !ok { + if !ok && !isAdditional { return fmt.Errorf("could not find: %s", downloadedName) } return nil @@ -484,28 +497,29 @@ func (f *fetcher) copyTool( for _, file := range files { if file.IsDir() { dirs = append(dirs, file) - } - if fileMatches(file, fileName) { + } else { + if fileMatches(file, fileName) { - sourcePath := filepath.Join(dir, file.Name()) - targetPath := filepath.Join(targetDir, binaryName(targetName)) + sourcePath := filepath.Join(dir, file.Name()) + targetPath := filepath.Join(targetDir, binaryName(targetName)) - if err := copyFile(sourcePath, targetPath); err != nil { - return false, err - } - if err := f.validate(targetPath, tool.Check); err != nil { - return true, err - } + if err := copyFile(sourcePath, targetPath); err != nil { + return false, err + } + if err := f.validate(targetPath, tool.Check); err != nil { + return true, err + } - if f.upx { - if tool.SkipUpx { - log.Printf("⏭️️ Skipping upx compression") - } else { - f.upxCompress(targetPath) + if f.upx { + if tool.SkipUpx { + log.Printf("⏭️️ Skipping upx compression") + } else { + f.upxCompress(targetPath) + } } - } - return true, nil + return true, nil + } } } for _, d := range dirs {