feat: migrate to system cache with changing core logic

This commit is contained in:
2025-04-15 21:41:21 +03:00
parent 5ca34a572a
commit efa4f59403
62 changed files with 4002 additions and 1889 deletions

View File

@ -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
}