File: apt_wrapper.go

package info (click to toggle)
debos 1.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 636 kB
  • sloc: sh: 105; makefile: 17
file content (50 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download
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
/* Abstracts the apt command. */
package wrapper

import (
	"github.com/go-debos/debos"
)

type AptCommand struct {
	Wrapper
}

func NewAptCommand(context debos.Context, label string) AptCommand {
	command := "apt-get"

	apt := AptCommand{
		Wrapper: NewCommandWrapper(context, command, label),
	}

	apt.AddEnv("DEBIAN_FRONTEND=noninteractive")

	/* Don't show progress update percentages */
	apt.AppendGlobalArguments("-o=quiet::NoUpdate=1")
	apt.AppendGlobalArguments("-o=Dpkg::Progress-Fancy=0")

	return apt
}

func (apt AptCommand) Clean() error {
	return apt.Run("clean")
}

func (apt AptCommand) Install(packages []string, recommends bool, unauthenticated bool) error {
	arguments := []string{"install", "--yes"}

	if !recommends {
		arguments = append(arguments, "--no-install-recommends")
	}

	if unauthenticated {
		arguments = append(arguments, "--allow-unauthenticated")
	}

	arguments = append(arguments, packages...)

	return apt.Run(arguments...)
}

func (apt AptCommand) Update() error {
	return apt.Run("update")
}