patchman/client/zypper/updatePackage.go

22 lines
427 B
Go
Raw Normal View History

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