// 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 doUpgrade() error { var cmd []string if !argv.DryRun { checkSuperuser() cmd = []string{"apt", "update"} exitOnError(cmd) cmd = []string{"apt", "install", "wit-tools"} exitOnError(cmd) } me.machine, _ = zoopb.InitMachine() // doAptUpgrade() 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.Infof("odd /var/lib/apt/ list parse error. p.Name was blank (should be the package name) p=%v\n", p) continue } 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 } if argv.Force { cmd := []string{"apt", "remove", "-y", p.Name} log.Info("Running:", cmd) exitOnError(cmd) cmd = []string{"apt", "install", "-y", p.Name} log.Info("Running:", cmd) exitOnError(cmd) } else { cmd := []string{"apt", "install", "-y", p.Name} log.Info("Running:", cmd) exitOnError(cmd) } } okExit("installed") return nil }