parent
82c559e657
commit
34d84f5117
34
apt.go
34
apt.go
|
@ -37,37 +37,3 @@ func addNew(name string, version string) bool {
|
||||||
new1.Version = version
|
new1.Version = version
|
||||||
return me.packages.Append(new1)
|
return me.packages.Append(new1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePackagesOld() {
|
|
||||||
// Get the list of installed packages for the detected distro
|
|
||||||
newP, err := getPackageList(me.distro)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var newCounter, changeCounter int
|
|
||||||
// Print the installed packages and their versions
|
|
||||||
for pkg, version := range newP {
|
|
||||||
found := me.packages.FindByName(pkg)
|
|
||||||
if found == nil {
|
|
||||||
log.Info("adding new", pkg, version)
|
|
||||||
addNew(pkg, version)
|
|
||||||
newCounter += 1
|
|
||||||
} else {
|
|
||||||
found.Version = version
|
|
||||||
if me.packages.Update(found) {
|
|
||||||
changeCounter += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
footer := fmt.Sprintf("%s has distro %s with %d packages installed", me.hostname, me.distro, me.packages.Len())
|
|
||||||
if changeCounter != 0 {
|
|
||||||
footer += fmt.Sprintf(" (%d changed)", changeCounter)
|
|
||||||
}
|
|
||||||
if newCounter != 0 {
|
|
||||||
footer += fmt.Sprintf(" (%d new)", newCounter)
|
|
||||||
}
|
|
||||||
log.Info(footer)
|
|
||||||
}
|
|
||||||
|
|
25
machine.go
25
machine.go
|
@ -38,8 +38,11 @@ func updateMachine(u *zoopb.Machine) string {
|
||||||
if u.Packages == nil {
|
if u.Packages == nil {
|
||||||
u.Packages = new(zoopb.Packages)
|
u.Packages = new(zoopb.Packages)
|
||||||
}
|
}
|
||||||
|
if zood := m.FindPackageByName("zood"); zood != nil {
|
||||||
|
log.Log(ZOOD, m.Hostname, "has zood version", zood.Version)
|
||||||
|
}
|
||||||
|
|
||||||
updatePackages(m.Packages, u.Packages)
|
updatePackages(m, u.Packages)
|
||||||
return "upgrade"
|
return "upgrade"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +50,26 @@ func updateMachine(u *zoopb.Machine) string {
|
||||||
// changed versions
|
// changed versions
|
||||||
// were newly installed
|
// were newly installed
|
||||||
// were uninstalled
|
// were uninstalled
|
||||||
func updatePackages(p *zoopb.Packages, u *zoopb.Packages) bool {
|
func updatePackages(m *zoopb.Machine, newp *zoopb.Packages) bool {
|
||||||
var changed bool = false
|
var changed bool = false
|
||||||
|
|
||||||
|
loop := newp.SortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
p := loop.Package()
|
||||||
|
if p.Name == "zood" {
|
||||||
|
if pold := m.FindPackageByName("zood"); pold == nil {
|
||||||
|
changed = true
|
||||||
|
log.Log(ZOOD, m.Hostname, "updatePackages() new package", p.Name , "version", p.Version)
|
||||||
|
m.Packages.Append(p)
|
||||||
|
} else {
|
||||||
|
if p.Version == pold.Version {
|
||||||
|
log.Log(ZOOD, m.Hostname, "updatePackages() unchanged", p.Version)
|
||||||
|
} else {
|
||||||
|
changed = true
|
||||||
|
log.Log(ZOOD, m.Hostname, "updatePackages() package", p.Name , "version changed", pold.Version, "to", p.Version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue