nix-amer/internal/pkg/apt.go

41 lines
734 B
Go
Raw Normal View History

package pkg
import (
"os/exec"
)
type aptGet struct{}
func (d aptGet) Name() string { return "apt-get" }
func (d aptGet) Fetch() error {
err := exec.Command(d.Name(), "update").Run()
return err
}
func (d aptGet) 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 aptGet) Install(_pkg string) error {
err := exec.Command(d.Name(), "install", _pkg).Run()
return err
}
func (d aptGet) Remove(_pkg string) error {
err := exec.Command(d.Name(), "remove", _pkg).Run()
exec.Command(d.Name(), "autoremove").Run()
return err
}