From 1efc8cb934eed7a8b42ed3a5791ac7030c8ad029 Mon Sep 17 00:00:00 2001 From: Mark Stenglein Date: Sun, 26 May 2019 19:24:47 -0400 Subject: [PATCH] CMD: LINUX: Arch Linux detection without lsb-release The existing distribution detection does not work on Arch Linux without the `lsb-release` package installed. This patch adds detection using `/etc/os-release` in the same way that f9a1881 uses for Fedora and CentOS detection. I changed the if statement that Bryn Sinclair used to a case statement to avoid extra if-else-if statements. I also needed to add a trim statement to remove the `"` characters that are present in Arch Linux's `/etc/os-release` file. --- cmd/linux.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index 5ff360efc..781c34298 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -77,10 +77,16 @@ func GetLinuxDistroInfo() *DistroInfo { re := regexp.MustCompile(`^NAME=(.*)\n`) // extract the distro name osName := string(re.FindSubmatch(osRelease)[1]) - // Check distro name against list of RedHat distros - if osName == "Fedora" || osName == "CentOS" { - //if it matches set result.Distribution to RedHat + // strip quotations + osName = strings.Trim(osName, "\"") + // Check distro name against list of distros + switch osName { + case "Fedora": result.Distribution = RedHat + case "CentOS": + result.Distribution = RedHat + case "Arch Linux": + result.Distribution = Arch } } return result