patchman/client/apt/updatePackage.go

23 lines
484 B
Go

package apt
import (
"log"
"os/exec"
"strings"
)
func UpdatePackage(name string) ([]string, error) {
var cmd *exec.Cmd
if name == "all" {
cmd = exec.Command("/usr/bin/apt", "dist-upgrade", "-y")
} else {
cmd = exec.Command("/usr/bin/apt", "install", name)
}
cmd.Env = append(cmd.Environ(), "APT_FRONTEND=noninteractive")
out, err := cmd.Output()
if err != nil {
log.Printf("Could not upgrade apt packages %s", err)
}
return strings.Split(string(out), "\n"), err
}