From f4ce449e7ba5de977de8e8d100bf26dabafb97be Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 3 Oct 2025 04:21:37 -0500 Subject: rename file --- argv.go | 7 ++++- doAptUpgrade.go | 79 --------------------------------------------------------- upgrade.go | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 80 deletions(-) delete mode 100644 doAptUpgrade.go create mode 100644 upgrade.go diff --git a/argv.go b/argv.go index 165d5c1..06251d9 100644 --- a/argv.go +++ b/argv.go @@ -29,7 +29,7 @@ type args struct { Test *EmptyCmd `arg:"subcommand:test" help:"test build everything first"` Clone *EmptyCmd `arg:"subcommand:repomap-clone" help:"go-clone from a gowebd repomap"` Rdate *EmptyCmd `arg:"subcommand:rdate" help:"standard rdate"` - Upgrade *DefaultCmd `arg:"subcommand:upgrade" help:"apt upgrade packages installed from mirrors.wit.com"` + Upgrade *UpgradeCmd `arg:"subcommand:upgrade" help:"apt upgrade packages installed from mirrors.wit.com"` RepoMap string `arg:"--repomap" help:"location of the repomap"` Release bool `arg:"--release" help:"use go-deb --release"` DryRun bool `arg:"--dry-run" help:"only show what would be packaged"` @@ -48,6 +48,11 @@ type DebianCmd struct { SkipInstall bool `arg:"--skip-install" help:"rebuild everything"` } +type UpgradeCmd struct { + DryRun bool `arg:"--dry-run" help:"don't really do anything"` + Force bool `arg:"--force" help:"force un-install and re-install each package"` +} + type DefaultCmd struct { DryRun bool `arg:"--dry-run" help:"only show what would be packaged"` Verbose bool `arg:"--verbose" help:"be loud about it"` diff --git a/doAptUpgrade.go b/doAptUpgrade.go deleted file mode 100644 index ae0a248..0000000 --- a/doAptUpgrade.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2017-2025 WIT.COM Inc. All rights reserved. -// Use of this source code is governed by the GPL 3.0 - -package main - -import ( - "fmt" - - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -func doAptUpgrade() { - if argv.DryRun { - log.Info("--dry-run", []string{"apt", "update"}) - } else { - result := shell.Run([]string{"apt", "update"}) - if result.Error != nil { - log.Info("apt update error:", result.Error) - badExit(result.Error) - } - } - - fmt.Println("Installed Packages:") - loop := me.machine.Wit.SortByName() - for loop.Scan() { - p := loop.Next() - // log.Info("apt install", p.Name) - if p.Name == "" { - log.Info("something wrong. p.Name was blank", p) - continue - } - if me.machine.IsInstalled(p.Name) { - cmd := []string{"apt", "install", p.Name} - if argv.DryRun { - log.Info("--dry-run", cmd) - } else { - log.Info("Running:", cmd) - shell.RunRealtime([]string{"apt", "install", p.Name}) - } - } - } - okExit("installed") -} - -func doAptList() { - log.DaemonMode(true) - defer log.DaemonMode(false) - fmt.Println("Installed Packages:") - loop := me.machine.Wit.SortByName() - for loop.Scan() { - p := loop.Next() - var end string - var version string - if me.forge.Config.IsPrivate(p.Name) { - end += "(private) " - } - if actualp := me.machine.FindByVersion(p.Name, p.Version); actualp != nil { - // end += "(version match) " - } else { - end += "(version mismatch) " + actualp.Version + " " + version + " " - } - if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil { - if p.Version != actualp.Version { - end += "(installed " + actualp.Version + " vs " + p.Version + ") " - } else { - end += "(installed ok) " - } - version = actualp.Version - } - if me.forge.Config.IsReadOnly(p.Name) { - // end += " (readonly) " - } else { - end += "(writable) " - } - log.Printf("%-30s %-8s %s\n", p.Name, p.Version, end) // p.PkgName) - } - okExit("") -} diff --git a/upgrade.go b/upgrade.go new file mode 100644 index 0000000..ae0a248 --- /dev/null +++ b/upgrade.go @@ -0,0 +1,79 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +func doAptUpgrade() { + if argv.DryRun { + log.Info("--dry-run", []string{"apt", "update"}) + } else { + result := shell.Run([]string{"apt", "update"}) + if result.Error != nil { + log.Info("apt update error:", result.Error) + badExit(result.Error) + } + } + + fmt.Println("Installed Packages:") + loop := me.machine.Wit.SortByName() + for loop.Scan() { + p := loop.Next() + // log.Info("apt install", p.Name) + if p.Name == "" { + log.Info("something wrong. p.Name was blank", p) + continue + } + if me.machine.IsInstalled(p.Name) { + cmd := []string{"apt", "install", p.Name} + if argv.DryRun { + log.Info("--dry-run", cmd) + } else { + log.Info("Running:", cmd) + shell.RunRealtime([]string{"apt", "install", p.Name}) + } + } + } + okExit("installed") +} + +func doAptList() { + log.DaemonMode(true) + defer log.DaemonMode(false) + fmt.Println("Installed Packages:") + loop := me.machine.Wit.SortByName() + for loop.Scan() { + p := loop.Next() + var end string + var version string + if me.forge.Config.IsPrivate(p.Name) { + end += "(private) " + } + if actualp := me.machine.FindByVersion(p.Name, p.Version); actualp != nil { + // end += "(version match) " + } else { + end += "(version mismatch) " + actualp.Version + " " + version + " " + } + if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil { + if p.Version != actualp.Version { + end += "(installed " + actualp.Version + " vs " + p.Version + ") " + } else { + end += "(installed ok) " + } + version = actualp.Version + } + if me.forge.Config.IsReadOnly(p.Name) { + // end += " (readonly) " + } else { + end += "(writable) " + } + log.Printf("%-30s %-8s %s\n", p.Name, p.Version, end) // p.PkgName) + } + okExit("") +} -- cgit v1.2.3