summaryrefslogtreecommitdiff
path: root/stdlib/os
diff options
context:
space:
mode:
authorJulien Dessaux2024-03-25 10:52:45 +0100
committerJulien Dessaux2024-03-25 10:52:45 +0100
commitd20734c275470d35303974767ca16c3c254dd092 (patch)
tree423ba7ee90e81327b68f0f69a8a9fa548e91a336 /stdlib/os
parentfix(promises): fixed IfRepaired promises chaining (diff)
downloadgonf-d20734c275470d35303974767ca16c3c254dd092.tar.gz
gonf-d20734c275470d35303974767ca16c3c254dd092.tar.bz2
gonf-d20734c275470d35303974767ca16c3c254dd092.zip
chore(packages): removed useless packages list hook function and debian stdlib refactoring
Diffstat (limited to 'stdlib/os')
-rw-r--r--stdlib/os/debian/apt.go29
-rw-r--r--stdlib/os/debian/debian.go38
2 files changed, 38 insertions, 29 deletions
diff --git a/stdlib/os/debian/apt.go b/stdlib/os/debian/apt.go
index 5b0b54f..3386f20 100644
--- a/stdlib/os/debian/apt.go
+++ b/stdlib/os/debian/apt.go
@@ -3,14 +3,12 @@ package debian
import (
"bufio"
"bytes"
- _ "embed"
"log/slog"
"os"
"os/exec"
"strings"
gonf "git.adyxax.org/adyxax/gonf/v2/pkg"
- "git.adyxax.org/adyxax/gonf/v2/stdlib/os/systemd"
)
var packages map[string]string
@@ -19,33 +17,6 @@ func init() {
packages_list()
}
-//go:embed apt-norecommends
-var apt_norecommends []byte
-
-//go:embed sources.list
-var sources_list []byte
-
-func Promise() {
- rootDir := gonf.ModeUserGroup(0755, "root", "root")
- rootRO := gonf.ModeUserGroup(0444, "root", "root")
- gonf.Default("debian-release", "stable")
- gonf.AppendVariable("debian-extra-sources", "# Extra sources")
- apt_update := gonf.Command("apt-get", "update", "-qq")
- gonf.File("/etc/apt/sources.list").
- Permissions(rootRO).
- Template(sources_list).
- Promise().
- IfRepaired(apt_update)
- gonf.File("/etc/apt/apt.conf.d/99_norecommends").
- DirectoriesPermissions(rootDir).
- Permissions(rootRO).
- Template(apt_norecommends).
- Promise()
- gonf.SetPackagesConfiguration(packages_install, packages_list, apt_update)
- gonf.Service("opensmtpd").State("enabled", "started").Promise()
- systemd.Promise()
-}
-
func packages_install(names []string) (gonf.Status, []string) {
gonf.FilterSlice(&names, func(n string) bool {
_, ok := packages[n]
diff --git a/stdlib/os/debian/debian.go b/stdlib/os/debian/debian.go
new file mode 100644
index 0000000..9954088
--- /dev/null
+++ b/stdlib/os/debian/debian.go
@@ -0,0 +1,38 @@
+package debian
+
+import (
+ _ "embed"
+ "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 apt_norecommends []byte
+
+//go:embed sources.list
+var sources_list []byte
+
+func Promise() {
+ // ----- gonf --------------------------------------------------------------
+ apt_update := gonf.Command("apt-get", "update", "-qq")
+ gonf.SetPackagesConfiguration(packages_install, apt_update)
+ 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(sources_list).
+ Promise().
+ IfRepaired(apt_update)
+ gonf.File("/etc/apt/apt.conf.d/99_norecommends").
+ DirectoriesPermissions(rootDir).
+ Permissions(rootRO).
+ Contents(apt_norecommends).
+ Promise()
+}