feat: migrate to system cache with changing core logic
This commit is contained in:
@ -28,7 +28,15 @@ import (
|
||||
|
||||
// APK represents the APK package manager
|
||||
type APK struct {
|
||||
rootCmd string
|
||||
CommonPackageManager
|
||||
}
|
||||
|
||||
func NewAPK() *APK {
|
||||
return &APK{
|
||||
CommonPackageManager: CommonPackageManager{
|
||||
noConfirmArg: "-i",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (*APK) Exists() bool {
|
||||
@ -44,10 +52,6 @@ func (*APK) Format() string {
|
||||
return "apk"
|
||||
}
|
||||
|
||||
func (a *APK) SetRootCmd(s string) {
|
||||
a.rootCmd = s
|
||||
}
|
||||
|
||||
func (a *APK) Sync(opts *Opts) error {
|
||||
opts = ensureOpts(opts)
|
||||
cmd := a.getCmd(opts, "apk", "update")
|
||||
@ -163,20 +167,3 @@ func (a *APK) IsInstalled(pkg string) (bool, error) {
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (a *APK) getCmd(opts *Opts, mgrCmd string, args ...string) *exec.Cmd {
|
||||
var cmd *exec.Cmd
|
||||
if opts.AsRoot {
|
||||
cmd = exec.Command(getRootCmd(a.rootCmd), mgrCmd)
|
||||
cmd.Args = append(cmd.Args, opts.Args...)
|
||||
cmd.Args = append(cmd.Args, args...)
|
||||
} else {
|
||||
cmd = exec.Command(mgrCmd, args...)
|
||||
}
|
||||
|
||||
if !opts.NoConfirm {
|
||||
cmd.Args = append(cmd.Args, "-i")
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
Reference in New Issue
Block a user