summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt.go4
-rw-r--r--doUpgrade.go61
2 files changed, 24 insertions, 41 deletions
diff --git a/apt.go b/apt.go
index 7cd3fc0..ff6a6c4 100644
--- a/apt.go
+++ b/apt.go
@@ -50,5 +50,7 @@ func aptUpdate() {
badExit(err)
}
- aptInstall("wit-tools")
+ if found := me.machine.FindInstalledByName("wit-tools"); found == nil {
+ aptInstall("wit-tools")
+ }
}
diff --git a/doUpgrade.go b/doUpgrade.go
index 6fa6bdf..8dece7c 100644
--- a/doUpgrade.go
+++ b/doUpgrade.go
@@ -49,52 +49,33 @@ func doUpgrade() error {
aptUpdate()
}
- var installed []string
-
- installable := zoopb.NewPackages()
-
fmt.Println("Installed Packages:")
- loop := me.machine.Wit.SortByName()
- for loop.Scan() {
- p := loop.Next()
- if p.Name == "" {
- log.Infof("odd /var/lib/apt/ list parse error. p.Name was blank (should be the package name) p=%v\n", p)
- continue
- }
- installable.Append(p)
- if !me.machine.IsInstalled(p.Name) {
- continue
- }
-
- found := me.machine.FindInstalledByName(p.Name)
-
- if found.Version == p.Version {
- log.Info("name version already installed", p.Name, found.Version)
- if !argv.Force {
- continue
- }
- } else {
- log.Info("name ver diff", p.Name, found.Version, p.Version)
- }
-
- if argv.DryRun {
- log.Info("should install package", p.Name)
- continue
- }
+ me.machine.PrintTable(me.machine.Wit)
- installed = append(installed, p.Name)
- }
- installable.PrintTable()
- me.sh.GoodExit("")
if argv.Force {
// force remove the packages. can be used if binaries change but versions didn't
- for _, pkgname := range installed {
- aptRemove(pkgname)
+ for p := range me.machine.Wit.IterByName() {
+ if me.machine.IsInstalled(p.Name) {
+ aptRemove(p.Name)
+ }
}
}
- for _, pkgname := range installed {
- aptInstall(pkgname)
+
+ for p := range me.machine.Wit.IterByName() {
+ if me.machine.WillUpgrade(p) {
+ if argv.DryRun {
+ log.Info("Would install here without --dry-run")
+ continue
+ }
+ if argv.Force {
+ aptInstall(p.Name)
+ continue
+ }
+ if _, err := aptInstall(p.Name); err != nil {
+ me.sh.BadExit("damn it", err)
+ }
+ }
}
- okExit("installed")
+ me.sh.GoodExit("installed")
return nil
}