From e01bbc43507e93c1f67d69f24ebb6040de359634 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 27 May 2016 16:52:19 -0700 Subject: [PATCH] Switch to kernel version to identify Gentoo versions We're looking at the gentoo release file to identify the version currently which is 2.2. It's been 2.2 for years since that's just the Gentoo Base System version which never changes. We should do what we do on Arch and use the kernel version string. This is a copy / paste of that code. Signed-off-by: Tim Smith --- lib/ohai/plugins/linux/platform.rb | 5 ++++- spec/unit/plugins/linux/platform_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index d70c28747..21cc40305 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -118,7 +118,10 @@ def os_release_file_is_cisco? platform_version get_redhatish_version(contents) elsif File.exist?("/etc/gentoo-release") platform "gentoo" - platform_version File.read("/etc/gentoo-release").scan(/(\d+|\.+)/).join + # the gentoo release version is the base version used to bootstrap + # a node and doesn't have a lot of meaning in a rolling release distro + # kernel release will be used - ex. 3.18.7-gentoo + platform_version `uname -r`.strip elsif File.exist?("/etc/SuSE-release") suse_release = File.read("/etc/SuSE-release") suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".") diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 5dccc929d..9fca3096b 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -222,6 +222,12 @@ expect(@plugin[:platform]).to eq("gentoo") expect(@plugin[:platform_family]).to eq("gentoo") end + + it "should set platform_version to kernel release" do + expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.7-gentoo") + @plugin.run + expect(@plugin[:platform_version]).to eq("3.18.7-gentoo") + end end describe "on alpine" do