43 lines
874 B
Go
43 lines
874 B
Go
package zoopb
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
// init the installed package list
|
|
func (me *Machine) initPackages() {
|
|
// Get the list of installed packages for the detected distro
|
|
newP, err := getPackageList(me.Distro)
|
|
if err != nil {
|
|
fmt.Println("Error:", err)
|
|
return
|
|
}
|
|
|
|
if me.Packages == nil {
|
|
me.Packages = new(Packages)
|
|
}
|
|
|
|
// Print the installed packages and their versions
|
|
for pkg, version := range newP {
|
|
new1 := new(Package)
|
|
new1.Name = pkg
|
|
new1.Version = version
|
|
if me.Packages.Append(new1) {
|
|
// log.Info("added", new1.Name, "ok")
|
|
} else {
|
|
log.Info("added", new1.Name, "failed")
|
|
}
|
|
}
|
|
|
|
log.Info(me.Hostname, "is", me.Distro, "with", me.Packages.Len(), "packages")
|
|
}
|
|
|
|
func (me *Machine) addNew(name string, version string) bool {
|
|
new1 := new(Package)
|
|
new1.Name = name
|
|
new1.Version = version
|
|
return me.Packages.Append(new1)
|
|
}
|