summaryrefslogtreecommitdiff
path: root/apt.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-21 19:48:09 -0600
committerJeff Carr <[email protected]>2024-11-21 19:48:09 -0600
commit22d49578c99e7c77ca7f6bd4691e3d88a7cfc7f5 (patch)
treebf72bc245dccbd82beca9e77130e9b0f5bfa1db0 /apt.go
parentf5144e4b8ae85d86e7d8172b2aa9d6b3da3e8835 (diff)
Diffstat (limited to 'apt.go')
-rw-r--r--apt.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/apt.go b/apt.go
deleted file mode 100644
index 5fa6385..0000000
--- a/apt.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "go.wit.com/lib/protobuf/zoopb"
- "go.wit.com/log"
-)
-
-// init the installed package list
-func initPackages() {
- // Get the list of installed packages for the detected distro
- newP, err := getPackageList(me.distro)
- if err != nil {
- fmt.Println("Error:", err)
- return
- }
-
- // Print the installed packages and their versions
- for pkg, version := range newP {
- new1 := new(zoopb.Package)
- new1.Name = pkg
- new1.Version = version
- if me.machine.Packages.Append(new1) {
- // log.Info("added", new1.Name, "ok")
- } else {
- log.Info("added", new1.Name, "failed")
- }
- }
-
- log.Info(me.hostname, "has distro", me.distro, "with", me.machine.Packages.Len(), "packages installed.")
-}
-
-func addNew(name string, version string) bool {
- new1 := new(zoopb.Package)
- new1.Name = name
- new1.Version = version
- return me.machine.Packages.Append(new1)
-}
-
-func updatePackages() string {
- // Get the list of installed packages for the detected distro
- newP, err := getPackageList(me.distro)
- if err != nil {
- fmt.Println("Error:", err)
- return fmt.Sprintln("getPackageList()", err)
- }
-
- var newCounter, changeCounter int
- // Print the installed packages and their versions
- for pkg, version := range newP {
- found := me.machine.Packages.FindByName(pkg)
- if found == nil {
- log.Info("adding new", pkg, version)
- addNew(pkg, version)
- newCounter += 1
- } else {
- found.Version = version
- if me.machine.Packages.Update(found) {
- changeCounter += 1
- }
- }
- }
-
- footer := fmt.Sprintf("%s has distro %s with %d packages installed", me.hostname, me.distro, me.machine.Packages.Len())
- if changeCounter != 0 {
- footer += fmt.Sprintf(" (%d changed)", changeCounter)
- }
- if newCounter != 0 {
- footer += fmt.Sprintf(" (%d new)", newCounter)
- }
- return footer
-}