Files
lpm/workflow/installer.go
zeekay 7d7127a687 deps: update to latest luxfi packages
- Update node v1.16.15 → v1.19.8
- Update crypto v1.17.0 → v1.17.4
- Update database v1.2.0 → v1.2.1
- Update geth v1.16.34 → v1.16.35
- Update ids v1.1.0 → v1.1.1
- Update Go 1.25 → 1.25.1
- Update copyright year to 2025
2025-09-30 00:05:18 +00:00

55 lines
1.2 KiB
Go

// Copyright (C) 2019-2025, Lux Partners Limited. All rights reserved.
// See the file LICENSE for licensing terms.
package workflow
import (
"os"
"os/exec"
"github.com/spf13/afero"
"github.com/luxfi/lpm/url"
)
type Installer interface {
Download(url string, path string) error
Decompress(source string, dest string) error
// Install installs the VM. installScriptPath is a path relative to
// workingDir.
Install(workingDir string, args ...string) error
}
var _ Installer = &VMInstaller{}
type VMInstallerConfig struct {
Fs afero.Fs
URLClient url.Client
}
func NewVMInstaller(config VMInstallerConfig) *VMInstaller {
return &VMInstaller{
fs: config.Fs,
Client: config.URLClient,
}
}
type VMInstaller struct {
fs afero.Fs
url.Client
}
func (t VMInstaller) Decompress(source string, dest string) error {
cmd := exec.Command("tar", "xf", source, "-C", dest, "--strip-components", "1")
return cmd.Run()
}
func (t VMInstaller) Install(workingDir string, args ...string) error {
cmd := exec.Command(args[0], args[1:]...) // #nosec G204 installation scripts are assumed to be trusted if a user is tracking a plugin repository
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = workingDir
return cmd.Run()
}