Class: Yast::SUSEReleaseClass

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

Constant Summary

RELEASE_FILE_PATH =
"/etc/SuSE-release"

Instance Method Summary (collapse)

Constructor Details

- (SUSEReleaseClass) initialize

Returns a new instance of SUSEReleaseClass



45
46
47
48
49
# File '../../src/modules/SUSERelease.rb', line 45

def initialize
  textdomain "update"

  Yast.import "FileUtils"
end

Instance Method Details

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

Returns product name as found in SuSE-release file. Compatible with OSRelease.ReleaseInformation. Returns SUSEReleaseFileMissingError if SuSE-release file is missing. Returns IOError is SuSE-release could not be open.

Parameters:

  • system (String)

    base-directory, default is “/”

Returns:

  • (String)

    product name



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File '../../src/modules/SUSERelease.rb', line 58

def ReleaseInformation(base_dir="/")
  release_file = File.join(base_dir, RELEASE_FILE_PATH)

  if !FileUtils.Exists(release_file)
    log.info "Release file #{release_file} not found"
    raise(
      SUSEReleaseFileMissingError,
      _("Release file %{file} not found") % { :file => release_file }
    )
  end

  file_contents = SCR.Read(path(".target.string"), release_file)
  if file_contents.nil?
    log.error "Cannot read file #{release_file}"
    raise(
      IOError,
      _("Cannot read release file %{file}") % { :file => release_file }
    )
  end

  product_name = file_contents.split(/\n/)[0]
  shorten(product_name)
end

- (Object) shorten(long_name)

Removes all unneeded stuff such as architecture or product nickname



83
84
85
# File '../../src/modules/SUSERelease.rb', line 83

def shorten(long_name)
  long_name.gsub(/[ ]*\(.*/, "")
end