summaryrefslogtreecommitdiff
path: root/stdlib/os/debian/debian.go
blob: 95af85d25049a1b591d6edb42a8553cee6f7f2c9 (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
package debian

import (
	_ "embed"

	gonf "git.adyxax.org/adyxax/gonf/v2/pkg"
	"git.adyxax.org/adyxax/gonf/v2/stdlib/os/linux"
	"git.adyxax.org/adyxax/gonf/v2/stdlib/os/systemd"
)

//go:embed apt-norecommends
var aptNoRecommends []byte

//go:embed sources.list
var sourcesList []byte

func Promise() {
	// ----- gonf --------------------------------------------------------------
	aptUpdate := gonf.Command("apt-get", "update", "-qq")
	gonf.SetPackagesConfiguration(packagesInstall, aptUpdate)
	gonf.SetUsersConfiguration(linux.Useradd)
	// ----- systemd -----------------------------------------------------------
	systemd.Promise()
	// ----- apt ---------------------------------------------------------------
	rootDir := gonf.ModeUserGroup(0755, "root", "root")
	rootRO := gonf.ModeUserGroup(0444, "root", "root")
	gonf.Default("debian-release", "stable")
	gonf.AppendVariable("debian-extra-sources", "# Extra sources")
	gonf.File("/etc/apt/sources.list").
		Permissions(rootRO).
		Template(sourcesList).
		Promise().
		IfRepaired(aptUpdate)
	gonf.File("/etc/apt/apt.conf.d/99_norecommends").
		DirectoriesPermissions(rootDir).
		Permissions(rootRO).
		Contents(aptNoRecommends).
		Promise()
}