[lxc-devel] [lxd/master] shared/version: Support detecting ChromeOS versions

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 18 10:30:52 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180918/6fa770c5/attachment.bin>
-------------- next part --------------
From addbc5c878a586ccf222ca1ec965cd0896655ac1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 18 Sep 2018 12:17:55 +0200
Subject: [PATCH] shared/version: Support detecting ChromeOS versions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/version/platform_linux.go | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/shared/version/platform_linux.go b/shared/version/platform_linux.go
index 1be9b34225..c6c3a87b57 100644
--- a/shared/version/platform_linux.go
+++ b/shared/version/platform_linux.go
@@ -3,6 +3,7 @@
 package version
 
 import (
+	"io/ioutil"
 	"strings"
 
 	"github.com/lxc/lxd/shared"
@@ -12,13 +13,15 @@ import (
 func getPlatformVersionStrings() []string {
 	versions := []string{}
 
-	// add kernel version
+	// Add kernel version
 	uname, err := shared.Uname()
-	if err == nil {
-		versions = append(versions, strings.Split(uname.Release, "-")[0])
+	if err != nil {
+		return versions
 	}
 
-	// add distribution info
+	versions = append(versions, strings.Split(uname.Release, "-")[0])
+
+	// Add distribution info
 	lsbRelease, err := osarch.GetLSBRelease()
 	if err == nil {
 		for _, key := range []string{"NAME", "VERSION_ID"} {
@@ -28,5 +31,15 @@ func getPlatformVersionStrings() []string {
 			}
 		}
 	}
+
+	// Add chromebook info
+	if len(versions) == 1 && shared.PathExists("/run/cros_milestone") {
+		content, err := ioutil.ReadFile("/run/cros_milestone")
+		if err == nil {
+			versions = append(versions, "Chrome OS")
+			versions = append(versions, strings.TrimSpace(string(content)))
+		}
+	}
+
 	return versions
 }


More information about the lxc-devel mailing list