summaryrefslogtreecommitdiff
path: root/stdlib/os/debian/apt.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-02-28 00:53:57 +0100
committerJulien Dessaux2024-03-07 01:01:47 +0100
commit24c4bde14aa3a4fd39ea7fa0478bcdd8f74e6bec (patch)
treeb25879feed05de4a97d3fb6b2378fb5f34d7a7ba /stdlib/os/debian/apt.go
parentfeat(stdlib): bootstrapped stdlib with debian and systemd promises (diff)
downloadgonf-24c4bde14aa3a4fd39ea7fa0478bcdd8f74e6bec.tar.gz
gonf-24c4bde14aa3a4fd39ea7fa0478bcdd8f74e6bec.tar.bz2
gonf-24c4bde14aa3a4fd39ea7fa0478bcdd8f74e6bec.zip
feat(packages): finished implementing packages install promises
Diffstat (limited to 'stdlib/os/debian/apt.go')
-rw-r--r--stdlib/os/debian/apt.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/stdlib/os/debian/apt.go b/stdlib/os/debian/apt.go
index 63ce497..2eb58fa 100644
--- a/stdlib/os/debian/apt.go
+++ b/stdlib/os/debian/apt.go
@@ -7,6 +7,7 @@ import (
"log/slog"
"os"
"os/exec"
+ "strings"
"git.adyxax.org/adyxax/gonf/v2/gonf"
"git.adyxax.org/adyxax/gonf/v2/stdlib/os/systemd"
@@ -32,21 +33,19 @@ func Promise() {
systemd.Promise()
}
-func packages_install(names []string) gonf.Status {
- allKept := true
- for _, n := range names {
- if _, ok := packages[n]; !ok {
- allKept = false
- }
- }
- if allKept {
- return gonf.KEPT
+func packages_install(names []string) (gonf.Status, []string) {
+ gonf.FilterSlice(&names, func(n string) bool {
+ _, ok := packages[n]
+ return !ok
+ })
+ if len(names) == 0 {
+ return gonf.KEPT, nil
}
args := append([]string{"install", "-y", "--no-install-recommends"}, names...)
cmd := gonf.CommandWithEnv([]string{"DEBIAN_FRONTEND=noninteractive", "LC_ALL=C"}, "apt-get", args...)
cmd.Resolve()
packages_list()
- return cmd.Status
+ return cmd.Status, names
}
func packages_list() {