lang: funcs: Add ArchLinux family detection

Signed-off-by: Christian Rebischke <chris@nullday.de>
This commit is contained in:
Christian Rebischke
2019-04-24 22:49:55 +02:00
parent 63ef11c708
commit acb2a5d2b0

View File

@@ -34,6 +34,10 @@ func init() {
T: types.NewType("func() bool"),
V: IsRedHat,
})
simple.ModuleRegister(moduleName, "is_archlinux", &types.FuncValue{
T: types.NewType("func() bool"),
V: IsArchLinux,
})
}
// IsDebian detects if the os family is debian.
@@ -61,3 +65,16 @@ func IsRedHat(input []types.Value) (types.Value, error) {
V: exists,
}, nil
}
// IsArchLinux detects if the os family is archlinux.
// TODO: Detect OS changes.
func IsArchLinux(input []types.Value) (types.Value, error) {
exists := true
_, err := os.Stat("/etc/arch-release")
if os.IsNotExist(err) {
exists = false
}
return &types.BoolValue{
V: exists,
}, nil
}