Class: Yast::OSReleaseClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../library/general/src/modules/OSRelease.rb

Constant Summary

OS_RELEASE_PATH =
"/etc/os-release"

Instance Method Summary (collapse)

Constructor Details

- (OSReleaseClass) initialize

Returns a new instance of OSReleaseClass



43
44
45
# File '../../library/general/src/modules/OSRelease.rb', line 43

def initialize
  textdomain "base"
end

Instance Method Details

- (Boolean) os_release_exists?(directory = "/")

Returns whether os-release file exists in the given directory

Parameters:

  • (optional) (String)

    directory, defaults to “/”

Returns:

  • (Boolean)

    whether exists



87
88
89
90
91
# File '../../library/general/src/modules/OSRelease.rb', line 87

def os_release_exists?(directory = "/")
  FileUtils.Exists(
    File.join(directory, OS_RELEASE_PATH)
  )
end

- (String) ReleaseInformation(directory = "/")

Get information about the OS release Throws exception Yast::OSReleaseFileMissingError if release file is missing.

Parameters:

  • directory (String) (defaults to: "/")

    containing the installed system (/ in installed system)

Returns:

  • (String)

    the release information



55
56
57
58
59
60
61
62
63
64
65
66
67
# File '../../library/general/src/modules/OSRelease.rb', line 55

def ReleaseInformation(directory = "/")
  release_file = File.join(directory, OS_RELEASE_PATH)

  if !os_release_exists?(directory)
    log.info "Release file #{release_file} not found"
    raise(
      OSReleaseFileMissingError,
      _("Release file %{file} not found") % { file: release_file }
    )
  end

  MakeNiceName(Misc.CustomSysconfigRead("PRETTY_NAME", "", release_file))
end

- (String) ReleaseName(directory = "/")

Get information about the OS name Is limited for the currently running product

Returns:

  • (String)

    the release information



72
73
74
# File '../../library/general/src/modules/OSRelease.rb', line 72

def ReleaseName(directory = "/")
  Misc.CustomSysconfigRead("NAME", "SUSE Linux", File.join(directory, OS_RELEASE_PATH))
end

- (String) ReleaseVersion(directory = "/")

Get information about the OS version Is limited for the currently running product

Returns:

  • (String)

    the release information



79
80
81
# File '../../library/general/src/modules/OSRelease.rb', line 79

def ReleaseVersion(directory = "/")
  Misc.CustomSysconfigRead("VERSION_ID", "", File.join(directory, OS_RELEASE_PATH))
end