// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "github.com/go-cmd/cmd" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) func aptInstall(pkgname string) (*cmd.Status, error) { cmd := []string{"apt-get", "install", "-y", pkgname} log.Info("Running:", cmd) return shell.RunRealtimeError(cmd) } 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 nil, nil } cmd := []string{"apt-get", "remove", "-y", pkgname} log.Info("Running:", cmd) return shell.RunRealtimeError(cmd) } func aptRemoveOrExit(pkgname string) { if _, err := aptRemove(pkgname); err != nil { badExit(err) } } func aptUpdate() { cmd := []string{"apt", "update"} if _, err := shell.RunRealtimeError(cmd); err != nil { badExit(err) } aptInstall("wit-tools") }