From 85761945ce11bd2417b1889b210f3d582f1ec211 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 7 Oct 2025 08:00:05 -0500 Subject: early work on a debian library --- apt.go | 8 ++------ doRdate.go | 9 ++++++--- doUpgrade.go | 9 +++++---- tableRepos.go | 28 ++++++++++++++-------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apt.go b/apt.go index ff6a6c4..77339a9 100644 --- a/apt.go +++ b/apt.go @@ -3,12 +3,7 @@ package main -import ( - "github.com/go-cmd/cmd" - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - +/* func aptInstall(pkgname string) (*cmd.Status, error) { cmd := []string{"apt-get", "install", "-y", pkgname} log.Info("Running:", cmd) @@ -54,3 +49,4 @@ func aptUpdate() { aptInstall("wit-tools") } } +*/ diff --git a/doRdate.go b/doRdate.go index a757e2c..7896f1c 100644 --- a/doRdate.go +++ b/doRdate.go @@ -3,17 +3,20 @@ package main -import "go.wit.com/lib/fhelp" +import ( + "go.wit.com/lib/debian" + "go.wit.com/lib/fhelp" +) func doRdate() { checkSuperuser() if _, err := fhelp.CheckCmd("rdate"); err != nil { - aptInstallOrExit("rdate") + debian.AptInstallOrExit("rdate") } if _, err := fhelp.CheckCmd("hwclock"); err != nil { - aptInstallOrExit("util-linux-extra") + debian.AptInstallOrExit("util-linux-extra") } exitOnError([]string{"rdate", "rdate.grid.wit.com"}) diff --git a/doUpgrade.go b/doUpgrade.go index edf0f81..d359af8 100644 --- a/doUpgrade.go +++ b/doUpgrade.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "go.wit.com/lib/debian" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) @@ -41,7 +42,7 @@ func doUpgrade() error { if !argv.DryRun { checkSuperuser() - aptUpdate() + debian.AptUpdate() } fmt.Println("Installed Packages:") @@ -55,7 +56,7 @@ func doUpgrade() error { // force remove the packages. can be used if binaries change but versions didn't for p := range me.machine.Wit.IterByName() { if me.machine.IsInstalled(p.Name) { - aptRemove(p.Name) + debian.AptRemove(p.Name) } } } @@ -67,10 +68,10 @@ func doUpgrade() error { continue } if argv.Force { - aptInstall(p.Name) + debian.AptInstall(p.Name) continue } - if _, err := aptInstall(p.Name); err != nil { + if _, err := debian.AptInstall(p.Name); err != nil { me.sh.BadExit("damn it", err) } } diff --git a/tableRepos.go b/tableRepos.go index 2e3fde2..c15dbd6 100644 --- a/tableRepos.go +++ b/tableRepos.go @@ -5,18 +5,22 @@ package main import ( "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/lib/protobuf/zoopb" + "go.wit.com/log" ) func isPackageOnMirrors(repo *gitpb.Repo) bool { - manufactured := repo.GetCurrentVersion() - ver := trimNonNumericFromStart(manufactured) + var found *zoopb.Package name := me.forge.Config.DebName(repo.Namespace) - if actualp := me.machine.FindByVersion(name, ver); actualp != nil { - // end += " (version match) " + actualp.Version + " " + ver + " " - // repo.State = "on mirrors" - return true + for pkg := range me.machine.Wit.IterAll() { + if name == pkg.Name { + found = pkg + } + } + if found.PkgName == "" { + log.Info("found", found) } - return false + return true } func printPackagingTable(pb *gitpb.Repos) { @@ -56,14 +60,10 @@ func printPackagingTable(pb *gitpb.Repos) { */ col = tablePB.AddStringFunc("I", func(r *gitpb.Repo) string { - name := me.forge.Config.DebName(r.GetNamespace()) - if me.machine.IsInstalled(name) { + debname := me.forge.Config.DebName(r.GetNamespace()) + if me.machine.IsInstalled(debname) { return "X" } - // debname := me.forge.Config.DebName(r.GetNamespace()) - // if actualp := me.machine.FindInstalledByName(debname); actualp != nil { - // return "X" - // } return "" }) col.Width = 1 @@ -87,7 +87,7 @@ func printPackagingTable(pb *gitpb.Repos) { col = tablePB.AddState() col.Width = 32 - col = tablePB.AddStringFunc("deb name", func(r *gitpb.Repo) string { + col = tablePB.AddStringFunc("filename for .deb", func(r *gitpb.Repo) string { name := me.forge.Config.DebName(r.Namespace) for pkg := range me.machine.Wit.IterAll() { if name == pkg.Name { -- cgit v1.2.3