Skip to content

Commit

Permalink
Merge pull request #1324 from yyt030/master
Browse files Browse the repository at this point in the history
add neokylin host info on linux
  • Loading branch information
shirou committed Jul 14, 2022
2 parents 96fd417 + 15354cb commit 8c479f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion host/host_linux.go
Expand Up @@ -216,6 +216,12 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
version = contents[0]
}
}
} else if common.PathExists(common.HostEtc("neokylin-release")) {
contents, err := common.ReadLines(common.HostEtc("neokylin-release"))
if err == nil {
version = getRedhatishVersion(contents)
platform = getRedhatishPlatform(contents)
}
} else if common.PathExists(common.HostEtc("redhat-release")) {
contents, err := common.ReadLines(common.HostEtc("redhat-release"))
if err == nil {
Expand Down Expand Up @@ -296,6 +302,8 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
family = "coreos"
case "solus":
family = "solus"
case "neokylin":
family = "neokylin"
}

return platform, family, version, nil
Expand All @@ -322,7 +330,7 @@ func getRedhatishVersion(contents []string) string {
if strings.Contains(c, "rawhide") {
return "rawhide"
}
if matches := regexp.MustCompile(`release (\d[\d.]*)`).FindStringSubmatch(c); matches != nil {
if matches := regexp.MustCompile(`release (\w[\d.]*)`).FindStringSubmatch(c); matches != nil {
return matches[1]
}
return ""
Expand Down

0 comments on commit 8c479f5

Please sign in to comment.