nix-amer/internal/pkg/apt.go

41 lines
716 B
Go

package pkg
import (
"os/exec"
)
type Apt struct{}
func (d Apt) Name() string { return "apt-get" }
func (d Apt) Fetch() error {
err := exec.Command(d.Name(), "update").Run()
return err
}
func (d Apt) Upgrade() error {
err := exec.Command(d.Name(), "upgrade").Run()
if err != nil {
return err
}
err = exec.Command(d.Name(), "dist-upgrade").Run()
if err != nil {
return err
}
exec.Command(d.Name(), "autoremove").Run()
return nil
}
func (d Apt) Install(_pkg string) error {
err := exec.Command(d.Name(), "install", _pkg).Run()
return err
}
func (d Apt) Remove(_pkg string) error {
err := exec.Command(d.Name(), "remove", _pkg).Run()
exec.Command(d.Name(), "autoremove").Run()
return err
}