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 (
// APT represents the APT package manager
type APT struct {
rootCmd string
CommonPackageManager
}
func NewAPT() *APT {
return &APT{
CommonPackageManager: CommonPackageManager{
noConfirmArg: "-y",
},
}
}
func (*APT) Exists() bool {
@ -44,10 +52,6 @@ func (*APT) Format() string {
return "deb"
}
func (a *APT) SetRootCmd(s string) {
a.rootCmd = s
}
func (a *APT) Sync(opts *Opts) error {
opts = ensureOpts(opts)
cmd := a.getCmd(opts, "apt", "update")
@ -149,20 +153,3 @@ func (a *APT) IsInstalled(pkg string) (bool, error) {
}
return true, nil
}
func (a *APT) 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, "-y")
}
return cmd
}