mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-30 17:42:06 -04:00
system updater: make all distros use terminal
This commit is contained in:
@@ -15,11 +15,10 @@ var aptUpgradableLine = regexp.MustCompile(`^([^/]+)/\S+\s+(\S+)\s+\S+\s+\[upgra
|
||||
|
||||
type aptBackend struct{}
|
||||
|
||||
func (aptBackend) ID() string { return "apt" }
|
||||
func (aptBackend) DisplayName() string { return "APT" }
|
||||
func (aptBackend) Repo() RepoKind { return RepoSystem }
|
||||
func (aptBackend) NeedsAuth() bool { return true }
|
||||
func (aptBackend) RunsInTerminal() bool { return false }
|
||||
func (aptBackend) ID() string { return "apt" }
|
||||
func (aptBackend) DisplayName() string { return "APT" }
|
||||
func (aptBackend) Repo() RepoKind { return RepoSystem }
|
||||
func (aptBackend) NeedsAuth() bool { return true }
|
||||
func (aptBackend) IsAvailable(_ context.Context) bool {
|
||||
return commandExists("apt") || commandExists("apt-get")
|
||||
}
|
||||
@@ -34,19 +33,16 @@ func (aptBackend) CheckUpdates(ctx context.Context) ([]Package, error) {
|
||||
return parseAptUpgradable(string(out)), nil
|
||||
}
|
||||
|
||||
func (aptBackend) Upgrade(ctx context.Context, opts UpgradeOptions, onLine func(string)) error {
|
||||
func (aptBackend) UpgradeCommand(opts UpgradeOptions) (string, error) {
|
||||
bin := "apt-get"
|
||||
if !commandExists(bin) {
|
||||
bin = "apt"
|
||||
}
|
||||
env := "DEBIAN_FRONTEND=noninteractive LC_ALL=C "
|
||||
if opts.DryRun {
|
||||
return Run(ctx, []string{bin, "upgrade", "--dry-run"}, RunOptions{
|
||||
Env: []string{"DEBIAN_FRONTEND=noninteractive", "LC_ALL=C"},
|
||||
OnLine: onLine,
|
||||
})
|
||||
return env + bin + " upgrade --dry-run", nil
|
||||
}
|
||||
argv := []string{"pkexec", "env", "DEBIAN_FRONTEND=noninteractive", "LC_ALL=C", bin, "upgrade", "-y"}
|
||||
return Run(ctx, argv, RunOptions{OnLine: onLine})
|
||||
return "sudo " + env + bin + " upgrade -y", nil
|
||||
}
|
||||
|
||||
func parseAptUpgradable(text string) []Package {
|
||||
|
||||
Reference in New Issue
Block a user