lang: funcs: Add ArchLinux family detection
Signed-off-by: Christian Rebischke <chris@nullday.de>
This commit is contained in:
@@ -34,6 +34,10 @@ func init() {
|
|||||||
T: types.NewType("func() bool"),
|
T: types.NewType("func() bool"),
|
||||||
V: IsRedHat,
|
V: IsRedHat,
|
||||||
})
|
})
|
||||||
|
simple.ModuleRegister(moduleName, "is_archlinux", &types.FuncValue{
|
||||||
|
T: types.NewType("func() bool"),
|
||||||
|
V: IsArchLinux,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDebian detects if the os family is debian.
|
// IsDebian detects if the os family is debian.
|
||||||
@@ -61,3 +65,16 @@ func IsRedHat(input []types.Value) (types.Value, error) {
|
|||||||
V: exists,
|
V: exists,
|
||||||
}, nil
|
}, 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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user