From f0ba0435f0801d606f296a076d5c4aedda6376d1 Mon Sep 17 00:00:00 2001 From: erdii Date: Mon, 9 Aug 2021 18:40:00 +0200 Subject: [PATCH] add archlinux support Signed-off-by: erdii --- os/linux/archlinux.go | 30 ++++++++++++++++++++++++++++++ resolver.go | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 os/linux/archlinux.go diff --git a/os/linux/archlinux.go b/os/linux/archlinux.go new file mode 100644 index 00000000..d811b83c --- /dev/null +++ b/os/linux/archlinux.go @@ -0,0 +1,30 @@ +package linux + +import ( + "strings" + + "github.com/k0sproject/rig" + "github.com/k0sproject/rig/os" + "github.com/k0sproject/rig/os/registry" +) + +// Archlinux provides OS support for Archlinux systems +type Archlinux struct { + os.Linux +} + +func init() { + registry.RegisterOSModule( + func(os rig.OSVersion) bool { + return os.IDLike == "arch" + }, + func() interface{} { + return Archlinux{} + }, + ) +} + +// InstallPackage installs packages via pacman +func (c Archlinux) InstallPackage(h os.Host, s ...string) error { + return h.Execf("sudo pacman -S --noconfirm --noprogressbar %s", strings.Join(s, " ")) +} diff --git a/resolver.go b/resolver.go index b9754608..2e3c4c0f 100644 --- a/resolver.go +++ b/resolver.go @@ -116,6 +116,9 @@ func parseOSReleaseFile(s string, os *OSVersion) error { os.ID = unquote(fields[1]) case "ID_LIKE": os.IDLike = unquote(fields[1]) + if os.IDLike == "arch" { + os.Version = "0.0.0" + } case "VERSION_ID": os.Version = unquote(fields[1]) case "PRETTY_NAME":