blob: b04ce619b0b560c1f7ee2978b889738eac7ea152 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// 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/debian"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
func doPackageList(all bool) {
installed := zoopb.NewPackages()
for p := range me.machine.Wit.IterByPackage() {
if all {
installed.Append(p)
} else {
found := me.machine.FindInstalledByName(p.Package)
if found == nil {
continue
}
p.Installed = true
installed.Append(p)
}
}
me.machine.PrintTable(installed)
}
func doUpgrade() error {
me.machine = debian.InitMachine()
if argv.All {
doPackageList(true)
return nil
}
// if !argv.DryRun {
// }
if areSuperuser() {
checkSuperuser()
debian.AptUpdate()
// try to re-init due to new apt lists
me.machine = debian.InitMachine()
}
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.IterByPackage() {
if me.machine.IsInstalled(p.Package) {
debian.AptRemove(p.Package)
}
}
}
for p := range me.machine.Wit.IterByPackage() {
if me.machine.WillUpgrade(p) {
if !areSuperuser() {
log.Info("Would install here but you are not root")
continue
}
if argv.DryRun {
log.Info("Would install here without --dry-run")
continue
}
if argv.Force {
debian.AptInstall(p.Package)
continue
}
if _, err := debian.AptInstall(p.Package); err != nil {
me.argv.BadExit("damn it", err)
}
}
}
me.argv.GoodExit("installed")
return nil
}
|