Skip to content

Commit

Permalink
Add OSRelease.id to get the 'ID' field
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Dec 21, 2016
1 parent 7b04f84 commit 23c1ea6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/general/src/modules/OSRelease.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def ReleaseVersion(directory = "/")
Misc.CustomSysconfigRead("VERSION_ID", "", File.join(directory, OS_RELEASE_PATH))
end

# Get information about OS ID
# Is limited for the currently running product
# @return [String] the OS identifier (sles, opensuse, etc.)
def id(directory = "/")
Misc.CustomSysconfigRead("ID", "", File.join(directory, OS_RELEASE_PATH))
end

# Returns whether os-release file exists in the given directory
#
# @param [String] (optional) directory, defaults to "/"
Expand Down
10 changes: 10 additions & 0 deletions library/general/test/os_release_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@
expect(Yast::OSRelease.ReleaseVersion(DATA_DIR)).to eq("13.1")
end
end

describe "#id" do
it "returns an OS identifier" do
stub_const("Yast::OSReleaseClass::OS_RELEASE_PATH", "os-release_SLES_12_Beta5")
expect(Yast::OSRelease.id(DATA_DIR)).to eq("sles")

stub_const("Yast::OSReleaseClass::OS_RELEASE_PATH", "os-release_openSUSE_13.1_GM")
expect(Yast::OSRelease.id(DATA_DIR)).to eq("opensuse")
end
end
end

0 comments on commit 23c1ea6

Please sign in to comment.