Class: Yast::OSReleaseClass

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

Constant Summary collapse

OS_RELEASE_PATH =
"/etc/os-release".freeze

Instance Method Summary collapse

Constructor Details

#initializeOSReleaseClass

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

#id(directory = "/") ⇒ String

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

Returns:

  • (String)

    the OS identifier (sles, opensuse, etc.)



86
87
88
# File 'library/general/src/modules/OSRelease.rb', line 86

def id(directory = "/")
  Misc.CustomSysconfigRead("ID", "", File.join(directory, OS_RELEASE_PATH))
end

#os_release_exists?(directory = "/") ⇒ Boolean

Returns whether os-release file exists in the given directory

Parameters:

  • (optional) (String)

    directory, defaults to “/”

Returns:

  • (Boolean)

    whether exists



94
95
96
97
98
# File 'library/general/src/modules/OSRelease.rb', line 94

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

#ReleaseInformation(directory = "/") ⇒ String

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

#ReleaseName(directory = "/") ⇒ String

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

#ReleaseVersion(directory = "/") ⇒ String

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