Use uname machine field to get CPU variant if fails at /proc/cpuinfo

When images/containers in ARM arch were built/executed on x86 host,
getCPUVariant will fail as it tries to look for /proc/cpuinfo, whose
content is from the host. Adding a new method as fallback to check uname
machine when it happens.

Signed-off-by: Tony Fang <nenghui.fang@gmail.com>
This commit is contained in:
Tony Fang
2022-11-07 17:02:24 +00:00
parent 8f7cfbda29
commit 8d5c045435
5 changed files with 238 additions and 115 deletions

View File

@@ -21,13 +21,6 @@ import (
"strings"
)
// isLinuxOS returns true if the operating system is Linux.
//
// The OS value should be normalized before calling this function.
func isLinuxOS(os string) bool {
return os == "linux"
}
// These function are generated from https://golang.org/src/go/build/syslist.go.
//
// We use switch statements because they are slightly faster than map lookups