diff options
author | Thom May <thom@may.lt> | 2016-05-31 08:08:16 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2016-05-31 08:08:16 +0100 |
commit | dd350ddd38d9976892a7754d142b2b6e707a9f56 (patch) | |
tree | 57a5d8d17d931c358c08110216d44f221bde2d28 | |
parent | eb75927881b10f1c60a26add31f6afe9f773330f (diff) | |
parent | c744ed7e855dcd18b0b46e8d64d2b3d0d830c1c1 (diff) | |
download | ohai-dd350ddd38d9976892a7754d142b2b6e707a9f56.tar.gz |
Merge pull request #828 from chef/gentoo
Switch to kernel version to identify Gentoo versions
-rw-r--r-- | lib/ohai/plugins/linux/platform.rb | 5 | ||||
-rw-r--r-- | spec/unit/plugins/linux/platform_spec.rb | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index d70c2874..21cc4030 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -118,7 +118,10 @@ Ohai.plugin(:Platform) do 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 5dccc929..3501610e 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -217,11 +217,16 @@ describe Ohai::System, "Linux plugin platform" do end it "should set platform and platform_family to gentoo" do - expect(File).to receive(:read).with("/etc/gentoo-release").and_return("Gentoo Base System release 1.20.1.1") @plugin.run 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 |