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.


41
42
43
# File 'library/general/src/modules/OSRelease.rb', line 41

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.)


91
92
93
# File 'library/general/src/modules/OSRelease.rb', line 91

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


99
100
101
102
103
# File 'library/general/src/modules/OSRelease.rb', line 99

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


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

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,
      format(_("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


70
71
72
# File 'library/general/src/modules/OSRelease.rb', line 70

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

#ReleaseVersion(directory = "/") ⇒ String

Get information about the OS version (technical). E.g. 15.2 Is limited for the currently running product

Returns:

  • (String)

    the release information


77
78
79
# File 'library/general/src/modules/OSRelease.rb', line 77

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

#ReleaseVersionHumanReadable(directory = "/") ⇒ String

Get information about the OS version (human readable). E.g. 15-SP2 Is limited for the currently running product

Returns:

  • (String)

    the release information


84
85
86
# File 'library/general/src/modules/OSRelease.rb', line 84

def ReleaseVersionHumanReadable(directory = "/")
  Misc.CustomSysconfigRead("VERSION", "", File.join(directory, OS_RELEASE_PATH))
end