Merge pull request #6443 from MikeMcQuaid/linux-os-version
os/linux: add, use OS::Linux.os_version
This commit is contained in:
commit
4db823cb78
@ -5,18 +5,6 @@ require "os/linux/glibc"
|
|||||||
|
|
||||||
class SystemConfig
|
class SystemConfig
|
||||||
class << self
|
class << self
|
||||||
def host_os_version
|
|
||||||
if which("lsb_release")
|
|
||||||
description = `lsb_release -d`.chomp.sub("Description:\t", "")
|
|
||||||
codename = `lsb_release -c`.chomp.sub("Codename:\t", "")
|
|
||||||
"#{description} (#{codename})"
|
|
||||||
elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable?
|
|
||||||
redhat_release.read.chomp
|
|
||||||
else
|
|
||||||
"N/A"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def host_glibc_version
|
def host_glibc_version
|
||||||
version = OS::Linux::Glibc.system_version
|
version = OS::Linux::Glibc.system_version
|
||||||
return "N/A" if version.null?
|
return "N/A" if version.null?
|
||||||
@ -42,7 +30,7 @@ class SystemConfig
|
|||||||
def dump_verbose_config(out = $stdout)
|
def dump_verbose_config(out = $stdout)
|
||||||
dump_generic_verbose_config(out)
|
dump_generic_verbose_config(out)
|
||||||
out.puts "Kernel: #{`uname -mors`.chomp}"
|
out.puts "Kernel: #{`uname -mors`.chomp}"
|
||||||
out.puts "OS: #{host_os_version}"
|
out.puts "OS: #{OS::Linux.os_version}"
|
||||||
out.puts "Host glibc: #{host_glibc_version}"
|
out.puts "Host glibc: #{host_glibc_version}"
|
||||||
out.puts "/usr/bin/gcc: #{host_gcc_version}"
|
out.puts "/usr/bin/gcc: #{host_gcc_version}"
|
||||||
["glibc", "gcc", "xorg"].each do |f|
|
["glibc", "gcc", "xorg"].each do |f|
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module OS
|
module OS
|
||||||
|
module Linux
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def os_version
|
||||||
|
if which("lsb_release")
|
||||||
|
description = Utils.popen_read("lsb_release -d")
|
||||||
|
.chomp
|
||||||
|
.sub("Description:\t", "")
|
||||||
|
codename = Utils.popen_read("lsb_release -c")
|
||||||
|
.chomp
|
||||||
|
.sub("Codename:\t", "")
|
||||||
|
"#{description} (#{codename})"
|
||||||
|
elsif (redhat_release = Pathname.new("/etc/redhat-release")).readable?
|
||||||
|
redhat_release.read.chomp
|
||||||
|
else
|
||||||
|
"Unknown"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Define OS::Mac on Linux for formula API compatibility.
|
# Define OS::Mac on Linux for formula API compatibility.
|
||||||
module Mac
|
module Mac
|
||||||
module_function
|
module_function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user