From 4355ba2f83411e2ff3869334ce1342a2c45cdec3 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Sat, 30 Sep 2017 14:21:23 +0800 Subject: [PATCH] ctr: Add helpers to database to check Linux and ARM arch On ARM platforms, we have to prepare the variant for spec.platform. Currently, this action would only work on Linux/ARM system. We introduce these two helpers to check running system's OS and Arch. Change-Id: Iff14087699219413779dd6caf1bf9524db1cc19e Signed-off-by: Wei Chen --- platforms/database.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platforms/database.go b/platforms/database.go index bd66e2517..362b005a6 100644 --- a/platforms/database.go +++ b/platforms/database.go @@ -5,6 +5,13 @@ 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 from https://golang.org/src/go/build/syslist.go. // // We use switch statements because they are slightly faster than map lookups @@ -21,6 +28,17 @@ func isKnownOS(os string) bool { return false } +// isArmArch returns true if the architecture is ARM. +// +// The arch value should be normalized before being passed to this function. +func isArmArch(arch string) bool { + switch arch { + case "arm", "arm64": + return true + } + return false +} + // isKnownArch returns true if we know about the architecture. // // The arch value should be normalized before being passed to this function.