// 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/protobuf/zoopb" "go.wit.com/log" ) func doPackageList(all bool) { installed := zoopb.NewPackages() for p := range me.machine.Wit.IterByName() { if all { installed.Append(p) } else { found := me.machine.FindInstalledByName(p.Name) if found == nil { continue } p.Installed = true installed.Append(p) } } me.machine.PrintTable(installed) } func doUpgrade() error { me.machine, _ = zoopb.InitMachine() if argv.Upgrade.List != nil { if argv.Upgrade.All { doPackageList(true) } else { doPackageList(false) } return nil } if !argv.DryRun { checkSuperuser() aptUpdate() } fmt.Println("Installed Packages:") if argv.All { me.machine.PrintTable(me.machine.Wit) } else { me.machine.PrintInstalledTable() } if argv.Force { // 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) } } } 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) } } } me.sh.GoodExit("installed") return nil }