Skip to content

Commit

Permalink
Merge pull request #828 from chef/gentoo
Browse files Browse the repository at this point in the history
Switch to kernel version to identify Gentoo versions
  • Loading branch information
thommay committed May 31, 2016
2 parents eb75927 + c744ed7 commit dd350dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/ohai/plugins/linux/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")
Expand Down
7 changes: 6 additions & 1 deletion spec/unit/plugins/linux/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,16 @@
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
Expand Down

0 comments on commit dd350dd

Please sign in to comment.