diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 08:40:15 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 08:40:15 -0500 |
| commit | 137fbac44c6bdfd746bd561377b3a28988f15172 (patch) | |
| tree | 7b224df39bb82ab3b338151f725b40326b393463 /apt.go | |
| parent | 8514f8fb6b6b74323186bd738e8d592332df3042 (diff) | |
smarter apt force install
Diffstat (limited to 'apt.go')
| -rw-r--r-- | apt.go | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -4,27 +4,43 @@ package main import ( + "github.com/go-cmd/cmd" + "go.wit.com/lib/gui/shell" "go.wit.com/log" ) -func aptInstall(pkgname string) { +func aptInstall(pkgname string) (*cmd.Status, error) { cmd := []string{"apt-get", "install", "-y", pkgname} log.Info("Running:", cmd) - exitOnError(cmd) + return shell.RunRealtimeError(cmd) } -func aptRemove(pkgname string) { +func aptInstallOrExit(pkgname string) { + if _, err := aptInstall(pkgname); err != nil { + badExit(err) + } +} + +func aptRemove(pkgname string) (*cmd.Status, error) { if pkgname == "mirrors.wit.com" { - return + return nil, nil } cmd := []string{"apt-get", "remove", "-y", pkgname} log.Info("Running:", cmd) - exitOnError(cmd) + return shell.RunRealtimeError(cmd) +} + +func aptRemoveOrExit(pkgname string) { + if _, err := aptRemove(pkgname); err != nil { + badExit(err) + } } func aptUpdate() { cmd := []string{"apt", "update"} - exitOnError(cmd) + if _, err := shell.RunRealtimeError(cmd); err != nil { + badExit(err) + } aptInstall("wit-tools") } |
