machinery-tool 1.22.1 → 1.22.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +10 -0
  4. data/bin/machinery +1 -1
  5. data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
  6. data/lib/autoyast.rb +2 -2
  7. data/lib/build_task.rb +10 -7
  8. data/lib/cli.rb +1005 -801
  9. data/lib/compare_task.rb +11 -7
  10. data/lib/comparison.rb +2 -2
  11. data/lib/config_base.rb +1 -1
  12. data/lib/config_task.rb +1 -1
  13. data/lib/containerize_task.rb +3 -3
  14. data/lib/containerized_app.rb +1 -1
  15. data/lib/copy_task.rb +1 -1
  16. data/lib/current_user.rb +1 -1
  17. data/lib/deploy_task.rb +6 -4
  18. data/lib/diff_widget.rb +67 -63
  19. data/lib/docker_system.rb +12 -8
  20. data/lib/dpkg_database.rb +1 -1
  21. data/lib/element_filter.rb +7 -4
  22. data/lib/exceptions.rb +23 -5
  23. data/lib/export_task.rb +1 -1
  24. data/lib/exporter.rb +1 -1
  25. data/lib/file_diff.rb +1 -1
  26. data/lib/file_scope.rb +1 -1
  27. data/lib/file_validator.rb +7 -4
  28. data/lib/filter.rb +97 -93
  29. data/lib/filter_option_parser.rb +2 -2
  30. data/lib/hint.rb +64 -59
  31. data/lib/html.rb +1 -1
  32. data/lib/inspect_task.rb +12 -12
  33. data/lib/inspector.rb +3 -3
  34. data/lib/json_validation_error_cleaner.rb +1 -1
  35. data/lib/json_validator.rb +4 -4
  36. data/lib/kiwi_config.rb +8 -4
  37. data/lib/list_task.rb +10 -9
  38. data/lib/local_system.rb +11 -5
  39. data/lib/logged_cheetah.rb +1 -1
  40. data/lib/man_task.rb +10 -6
  41. data/lib/managed_files_database.rb +1 -1
  42. data/lib/manifest.rb +5 -5
  43. data/lib/migration.rb +16 -10
  44. data/lib/mountpoints.rb +1 -1
  45. data/lib/move_task.rb +1 -1
  46. data/lib/remote_system.rb +7 -7
  47. data/lib/remove_task.rb +1 -1
  48. data/lib/renderer.rb +177 -172
  49. data/lib/rpm.rb +4 -4
  50. data/lib/rpm_database.rb +1 -1
  51. data/lib/scope.rb +2 -2
  52. data/lib/scope_file_access_archive.rb +1 -1
  53. data/lib/scope_file_access_flat.rb +1 -1
  54. data/lib/scope_file_store.rb +1 -1
  55. data/lib/serve_html_task.rb +6 -2
  56. data/lib/server.rb +19 -12
  57. data/lib/show_task.rb +10 -6
  58. data/lib/static_html.rb +1 -1
  59. data/lib/system.rb +10 -10
  60. data/lib/system_description.rb +14 -13
  61. data/lib/system_description_memory_store.rb +1 -1
  62. data/lib/system_description_store.rb +9 -9
  63. data/lib/tarball.rb +8 -2
  64. data/lib/upgrade_format_task.rb +11 -6
  65. data/lib/validate_task.rb +2 -2
  66. data/lib/version.rb +1 -1
  67. data/lib/workload_mapper.rb +2 -2
  68. data/lib/workload_mapper_dsl.rb +1 -1
  69. data/lib/zypper.rb +40 -17
  70. data/machinery-helper/machinery_helper.go +35 -16
  71. data/machinery-helper/version.go +1 -1
  72. data/man/generated/machinery.1.gz +0 -0
  73. data/manual/site/sitemap.xml +24 -24
  74. data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
  75. data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
  76. data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
  77. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
  78. data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
  79. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
  80. data/plugins/environment/environment_inspector.rb +25 -23
  81. data/plugins/environment/environment_model.rb +5 -3
  82. data/plugins/groups/groups_inspector.rb +30 -28
  83. data/plugins/groups/groups_model.rb +18 -17
  84. data/plugins/groups/groups_renderer.rb +29 -25
  85. data/plugins/os/os_inspector.rb +120 -118
  86. data/plugins/os/os_model.rb +139 -134
  87. data/plugins/os/os_renderer.rb +13 -9
  88. data/plugins/packages/packages_inspector.rb +99 -86
  89. data/plugins/packages/packages_model.rb +35 -34
  90. data/plugins/packages/packages_renderer.rb +47 -39
  91. data/plugins/patterns/patterns_inspector.rb +70 -68
  92. data/plugins/patterns/patterns_model.rb +19 -18
  93. data/plugins/patterns/patterns_renderer.rb +36 -32
  94. data/plugins/repositories/repositories_inspector.rb +162 -156
  95. data/plugins/repositories/repositories_model.rb +50 -49
  96. data/plugins/repositories/repositories_renderer.rb +48 -44
  97. data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
  98. data/plugins/services/services_inspector.rb +187 -176
  99. data/plugins/services/services_model.rb +37 -36
  100. data/plugins/services/services_renderer.rb +28 -24
  101. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
  102. data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
  103. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
  104. data/plugins/users/users_inspector.rb +67 -65
  105. data/plugins/users/users_model.rb +37 -36
  106. data/plugins/users/users_renderer.rb +31 -27
  107. data/schema/migrations/migrate1to2.rb +1 -1
  108. data/schema/migrations/migrate2to3.rb +1 -1
  109. data/schema/migrations/migrate3to4.rb +1 -1
  110. data/schema/migrations/migrate4to5.rb +1 -1
  111. data/schema/migrations/migrate5to6.rb +1 -1
  112. data/schema/migrations/migrate6to7.rb +1 -1
  113. data/schema/migrations/migrate7to8.rb +1 -1
  114. data/schema/migrations/migrate8to9.rb +1 -1
  115. data/schema/migrations/migrate9to10.rb +1 -1
  116. metadata +2 -2
@@ -15,58 +15,62 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class ChangedManagedFilesRenderer < Renderer
19
- def content(description)
20
- return unless description["changed_managed_files"]
18
+ module Machinery
19
+ class Ui
20
+ class ChangedManagedFilesRenderer < Machinery::Ui::Renderer
21
+ def content(description)
22
+ return unless description["changed_managed_files"]
21
23
 
22
- if description["changed_managed_files"]
23
- files, errors = description["changed_managed_files"].partition do |file|
24
- file.status != "error"
25
- end
26
- end
24
+ if description["changed_managed_files"]
25
+ files, errors = description["changed_managed_files"].partition do |file|
26
+ file.status != "error"
27
+ end
28
+ end
27
29
 
28
- list do
29
- file_status = description["changed_managed_files"].extracted
30
+ list do
31
+ file_status = description["changed_managed_files"].extracted
30
32
 
31
- if files.empty?
32
- puts "There are no changed managed files."
33
- elsif !file_status.nil?
34
- puts "Files extracted: #{file_status ? "yes" : "no"}"
35
- end
33
+ if files.empty?
34
+ puts "There are no changed managed files."
35
+ elsif !file_status.nil?
36
+ puts "Files extracted: #{file_status ? "yes" : "no"}"
37
+ end
36
38
 
37
- if files && !files.empty?
38
- files.each do |p|
39
- item "#{p.name} (#{p.changes.join(", ")})"
39
+ if files && !files.empty?
40
+ files.each do |p|
41
+ item "#{p.name} (#{p.changes.join(", ")})"
42
+ end
43
+ end
40
44
  end
41
- end
42
- end
43
45
 
44
- if errors && !errors.empty?
45
- list("Errors") do
46
- errors.each do |p|
47
- item "#{p.name}: #{p.error_message}"
46
+ if errors && !errors.empty?
47
+ list("Errors") do
48
+ errors.each do |p|
49
+ item "#{p.name}: #{p.error_message}"
50
+ end
51
+ end
48
52
  end
49
53
  end
50
- end
51
- end
52
54
 
53
- def display_name
54
- "Changed Managed Files"
55
- end
55
+ def display_name
56
+ "Changed Managed Files"
57
+ end
56
58
 
57
- def compare_content_changed(changed_elements)
58
- list do
59
- changed_elements.each do |one, two|
60
- changes = []
61
- relevant_attributes = (one.attributes.keys & two.attributes.keys)
59
+ def compare_content_changed(changed_elements)
60
+ list do
61
+ changed_elements.each do |one, two|
62
+ changes = []
63
+ relevant_attributes = (one.attributes.keys & two.attributes.keys)
62
64
 
63
- relevant_attributes.each do |attribute|
64
- if one[attribute] != two[attribute]
65
- changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
65
+ relevant_attributes.each do |attribute|
66
+ if one[attribute] != two[attribute]
67
+ changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
68
+ end
69
+ end
70
+
71
+ item "#{one.name} (#{changes.join(", ")})"
66
72
  end
67
73
  end
68
-
69
- item "#{one.name} (#{changes.join(", ")})"
70
74
  end
71
75
  end
72
76
  end
@@ -15,36 +15,38 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class EnvironmentInspector < Inspector
19
- has_priority 5
18
+ module Machinery
19
+ class EnvironmentInspector < Machinery::Inspector
20
+ has_priority 5
20
21
 
21
- def initialize(system, description)
22
- @system = system
23
- @description = description
24
- end
22
+ def initialize(system, description)
23
+ @system = system
24
+ @description = description
25
+ end
25
26
 
26
- def inspect(_filter = nil, _options = {})
27
- environment = EnvironmentScope.new
27
+ def inspect(_filter = nil, _options = {})
28
+ environment = EnvironmentScope.new
28
29
 
29
- environment.locale = get_locale
30
- environment.system_type = @system.type
30
+ environment.locale = get_locale
31
+ environment.system_type = @system.type
31
32
 
32
- @description.environment = environment
33
- end
33
+ @description.environment = environment
34
+ end
34
35
 
35
- private
36
+ private
36
37
 
37
- def get_locale
38
- output = nil
39
- begin
40
- output = Machinery.scrub(@system.run_command("locale", "-a", stdout: :capture))
41
- rescue
42
- return "C"
43
- end
38
+ def get_locale
39
+ output = nil
40
+ begin
41
+ output = Machinery.scrub(@system.run_command("locale", "-a", stdout: :capture))
42
+ rescue
43
+ return "C"
44
+ end
44
45
 
45
- all_locales = output.split
46
- locale = all_locales.find { |l| l.downcase.match(/en_us.utf.?8/) }
46
+ all_locales = output.split
47
+ locale = all_locales.find { |l| l.downcase.match(/en_us.utf.?8/) }
47
48
 
48
- locale || "C"
49
+ locale || "C"
50
+ end
49
51
  end
50
52
  end
@@ -15,8 +15,10 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class EnvironmentScope < Machinery::Object
19
- include Machinery::Scope
18
+ module Machinery
19
+ class EnvironmentScope < Machinery::Object
20
+ include Machinery::Scope
20
21
 
21
- hidden_scope
22
+ hidden_scope
23
+ end
22
24
  end
@@ -15,44 +15,46 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class GroupsInspector < Inspector
19
- has_priority 60
18
+ module Machinery
19
+ class GroupsInspector < Machinery::Inspector
20
+ has_priority 60
20
21
 
21
- def initialize(system, description)
22
- @system = system
23
- @description = description
24
- end
22
+ def initialize(system, description)
23
+ @system = system
24
+ @description = description
25
+ end
25
26
 
26
- def inspect(_filter, _options = {})
27
- group_content = @system.read_file("/etc/group")
27
+ def inspect(_filter, _options = {})
28
+ group_content = @system.read_file("/etc/group")
28
29
 
29
- groups = group_content ? parse_groups(group_content) : []
30
+ groups = group_content ? parse_groups(group_content) : []
30
31
 
31
- @description.groups = GroupsScope.new(groups.sort_by(&:name))
32
- end
32
+ @description.groups = GroupsScope.new(groups.sort_by(&:name))
33
+ end
33
34
 
34
- def summary
35
- "Found #{Machinery.pluralize(@description.groups.size, "%d group")}."
36
- end
35
+ def summary
36
+ "Found #{Machinery.pluralize(@description.groups.size, "%d group")}."
37
+ end
37
38
 
38
- private
39
+ private
39
40
 
40
- def parse_groups(content)
41
- content.lines.map do |line|
42
- # prevent split from ignoring the last entry if it is empty and there is no newline
43
- line += "\n" if line.end_with?(":")
44
- name, password, gid, users = line.split(":").map(&:chomp)
41
+ def parse_groups(content)
42
+ content.lines.map do |line|
43
+ # prevent split from ignoring the last entry if it is empty and there is no newline
44
+ line += "\n" if line.end_with?(":")
45
+ name, password, gid, users = line.split(":").map(&:chomp)
45
46
 
46
- gid = Machinery::is_int?(gid) ? gid.to_i : nil
47
+ gid = Machinery.is_int?(gid) ? gid.to_i : nil
47
48
 
48
- attrs = {
49
- name: name,
50
- password: password,
51
- gid: gid,
52
- users: users.split(",")
53
- }
49
+ attrs = {
50
+ name: name,
51
+ password: password,
52
+ gid: gid,
53
+ users: users.split(",")
54
+ }
54
55
 
55
- Group.new(attrs)
56
+ Group.new(attrs)
57
+ end
56
58
  end
57
59
  end
58
60
  end
@@ -15,26 +15,27 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
+ module Machinery
19
+ class Group < Machinery::Object
20
+ end
18
21
 
19
- class Group < Machinery::Object
20
- end
21
-
22
- class GroupsScope < Machinery::Array
23
- include Machinery::Scope
22
+ class GroupsScope < Machinery::Array
23
+ include Machinery::Scope
24
24
 
25
- has_elements class: Group
25
+ has_elements class: Group
26
26
 
27
- def compare_with(other)
28
- only_self = self - other
29
- only_other = other - self
30
- common = self & other
31
- changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :name)
27
+ def compare_with(other)
28
+ only_self = self - other
29
+ only_other = other - self
30
+ common = self & other
31
+ changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :name)
32
32
 
33
- [
34
- only_self,
35
- only_other,
36
- changed,
37
- common
38
- ].map { |e| (e && !e.empty?) ? e : nil }
33
+ [
34
+ only_self,
35
+ only_other,
36
+ changed,
37
+ common
38
+ ].map { |e| e && !e.empty? ? e : nil }
39
+ end
39
40
  end
40
41
  end
@@ -15,40 +15,44 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class GroupsRenderer < Renderer
19
- def content(description)
20
- return unless description.groups
18
+ module Machinery
19
+ class Ui
20
+ class GroupsRenderer < Machinery::Ui::Renderer
21
+ def content(description)
22
+ return unless description.groups
21
23
 
22
- na_note("group ID") if description.groups.any? { |a| a[:gid].nil? }
24
+ na_note("group ID") if description.groups.any? { |a| a[:gid].nil? }
23
25
 
24
- list do
25
- description.groups.each do |group|
26
- gid = group.gid || "N/A"
27
- details ="gid: #{gid}"
28
- details += ", users: #{group.users.join(",")}" unless group.users.empty?
26
+ list do
27
+ description.groups.each do |group|
28
+ gid = group.gid || "N/A"
29
+ details = "gid: #{gid}"
30
+ details += ", users: #{group.users.join(",")}" unless group.users.empty?
29
31
 
30
- item "#{group.name} (#{details})"
32
+ item "#{group.name} (#{details})"
33
+ end
34
+ end
31
35
  end
32
- end
33
- end
34
36
 
35
- def display_name
36
- "Groups"
37
- end
37
+ def display_name
38
+ "Groups"
39
+ end
38
40
 
39
- def compare_content_changed(changed_elements)
40
- list do
41
- changed_elements.each do |one, two|
42
- changes = []
43
- relevant_attributes = one.attributes.keys
41
+ def compare_content_changed(changed_elements)
42
+ list do
43
+ changed_elements.each do |one, two|
44
+ changes = []
45
+ relevant_attributes = one.attributes.keys
44
46
 
45
- relevant_attributes.each do |attribute|
46
- if one[attribute] != two[attribute]
47
- changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
47
+ relevant_attributes.each do |attribute|
48
+ if one[attribute] != two[attribute]
49
+ changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
50
+ end
51
+ end
52
+
53
+ item "#{one.name} (#{changes.join(", ")})"
48
54
  end
49
55
  end
50
-
51
- item "#{one.name} (#{changes.join(", ")})"
52
56
  end
53
57
  end
54
58
  end
@@ -16,152 +16,154 @@
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
18
  # Inspect name, version, and other attributes of the operating system
19
- class OsInspector < Inspector
20
- has_priority 10
21
-
22
- def strip_arch_from_name(name)
23
- # architecture information in the name might be misleading
24
- # information with regards to the real architecture name.
25
- # in addition the architecture information is not consistently
26
- # added for all distributions. Thus we strip this part
27
- name.gsub(/\((i.86|x86_64|s390|ia64|ppc|arm).*\)/, "").strip
28
- end
29
-
30
- # checks for additional version information like Beta or RC
31
- def get_additional_version
32
- issue = @system.read_file("/etc/issue")
33
- special_version = issue.scan(/Beta\d+|RC\d|GMC\d*/).first if issue
34
-
35
- special_version ? " #{special_version.gsub(/[0-9]{1,2}/," \\0")}" : ""
36
- end
37
-
38
- def initialize(system, description)
39
- @system = system
40
- @description = description
41
- end
19
+ module Machinery
20
+ class OsInspector < Machinery::Inspector
21
+ has_priority 10
22
+
23
+ def strip_arch_from_name(name)
24
+ # architecture information in the name might be misleading
25
+ # information with regards to the real architecture name.
26
+ # in addition the architecture information is not consistently
27
+ # added for all distributions. Thus we strip this part
28
+ name.gsub(/\((i.86|x86_64|s390|ia64|ppc|arm).*\)/, "").strip
29
+ end
42
30
 
43
- def inspect(_filter, _options = {})
44
- @system.check_requirement("cat", "--version") if @system.is_a?(RemoteSystem)
31
+ # checks for additional version information like Beta or RC
32
+ def get_additional_version
33
+ issue = @system.read_file("/etc/issue")
34
+ special_version = issue.scan(/Beta\d+|RC\d|GMC\d*/).first if issue
45
35
 
46
- os = get_os
47
- if os
48
- os.architecture = @system.arch
49
- os.version += get_additional_version if os.version
50
- else
51
- raise Machinery::Errors::UnknownOs
36
+ special_version ? " #{special_version.gsub(/[0-9]{1,2}/, " \\0")}" : ""
52
37
  end
53
38
 
54
- @description.os = os
55
- end
56
-
57
- def summary
58
- "Found operating system '#{@description.os.name}' version '#{@description.os.version}'."
59
- end
39
+ def initialize(system, description)
40
+ @system = system
41
+ @description = description
42
+ end
60
43
 
61
- private
44
+ def inspect(_filter, _options = {})
45
+ @system.check_requirement("cat", "--version") if @system.is_a?(Machinery::RemoteSystem)
62
46
 
63
- def get_os
64
- # Use os-release file by default
65
- os = get_os_from_os_release
47
+ os = get_os
48
+ if os
49
+ os.architecture = @system.arch
50
+ os.version += get_additional_version if os.version
51
+ else
52
+ raise Machinery::Errors::UnknownOs
53
+ end
66
54
 
67
- # Fall back to SuSE-release file
68
- unless os
69
- os = get_os_from_suse_release
55
+ @description.os = os
70
56
  end
71
57
 
72
- # Fall back to redhat-release file
73
- unless os
74
- os = get_os_from_redhat_release
58
+ def summary
59
+ "Found operating system '#{@description.os.name}' version '#{@description.os.version}'."
75
60
  end
76
61
 
77
- os
78
- end
79
-
80
- # check for freedesktop standard: /etc/os-release
81
- def get_os_from_os_release
82
- os_release = @system.read_file("/etc/os-release")
83
- return unless os_release
62
+ private
84
63
 
85
- result = Hash.new
86
- key_value_pairs = Hash[os_release.split("\n").reject(&:empty?).map { |l| l.split("=") }]
87
- key_value_pairs.each_pair do |k,v|
88
- result[k.downcase] = v.strip.gsub(/^"|"$/,"")
89
- end
90
- if result["pretty_name"]
91
- result["pretty_name"] = strip_arch_from_name(result["pretty_name"])
64
+ def get_os
65
+ # Use os-release file by default
66
+ os = get_os_from_os_release
92
67
 
93
- # remove always changing Tumbleweed version from pretty name
94
- if result["pretty_name"] =~ /^openSUSE.*Tumbleweed/
95
- result["pretty_name"] = "openSUSE Tumbleweed"
68
+ # Fall back to SuSE-release file
69
+ unless os
70
+ os = get_os_from_suse_release
96
71
  end
97
72
 
98
- # remove Leap version from pretty name
99
- if result["pretty_name"] =~ /^openSUSE.*Leap/
100
- result["pretty_name"] = "openSUSE Leap"
73
+ # Fall back to redhat-release file
74
+ unless os
75
+ os = get_os_from_redhat_release
101
76
  end
102
77
 
103
- # converts SLES11 SP4 result to SP3 style
104
- # the results are different because SP4 has an os-release
105
- if result["pretty_name"] =~ /^SUSE Linux Enterprise Server 11 (SP\d)$/
106
- result["pretty_name"] = "SUSE Linux Enterprise Server 11"
107
- result["version"] = "11 #{$1}"
108
- end
109
- end
110
- # return pretty_name as name as it contains the actual full length
111
- # name instead of an abbreviation
112
- os = Os.for(result["pretty_name"] || result["name"])
113
- os.version = result["version"]
114
-
115
- # since Tumbleweed does no longer store the version number in the
116
- # "version" property, we've to read from the "version_id" property
117
- if os.version == "Tumbleweed" || os.name == "openSUSE Tumbleweed"
118
- os.version = result["version_id"]
78
+ os
119
79
  end
120
80
 
121
- os
122
- end
81
+ # check for freedesktop standard: /etc/os-release
82
+ def get_os_from_os_release
83
+ os_release = @system.read_file("/etc/os-release")
84
+ return unless os_release
123
85
 
124
- # checks for old suse standard: /etc/SuSE-release
125
- def get_os_from_suse_release
126
- suse_release = @system.read_file("/etc/SuSE-release")
127
- return unless suse_release
86
+ result = Hash.new
87
+ key_value_pairs = Hash[os_release.split("\n").reject(&:empty?).map { |l| l.split("=") }]
88
+ key_value_pairs.each_pair do |k, v|
89
+ result[k.downcase] = v.strip.gsub(/^"|"$/, "")
90
+ end
91
+ if result["pretty_name"]
92
+ result["pretty_name"] = strip_arch_from_name(result["pretty_name"])
93
+
94
+ # remove always changing Tumbleweed version from pretty name
95
+ if result["pretty_name"] =~ /^openSUSE.*Tumbleweed/
96
+ result["pretty_name"] = "openSUSE Tumbleweed"
97
+ end
98
+
99
+ # remove Leap version from pretty name
100
+ if result["pretty_name"] =~ /^openSUSE.*Leap/
101
+ result["pretty_name"] = "openSUSE Leap"
102
+ end
103
+
104
+ # converts SLES11 SP4 result to SP3 style
105
+ # the results are different because SP4 has an os-release
106
+ if result["pretty_name"] =~ /^SUSE Linux Enterprise Server 11 (SP\d)$/
107
+ result["pretty_name"] = "SUSE Linux Enterprise Server 11"
108
+ result["version"] = "11 #{$1}"
109
+ end
110
+ end
111
+ # return pretty_name as name as it contains the actual full length
112
+ # name instead of an abbreviation
113
+ os = Os.for(result["pretty_name"] || result["name"])
114
+ os.version = result["version"]
115
+
116
+ # since Tumbleweed does no longer store the version number in the
117
+ # "version" property, we've to read from the "version_id" property
118
+ if os.version == "Tumbleweed" || os.name == "openSUSE Tumbleweed"
119
+ os.version = result["version_id"]
120
+ end
128
121
 
129
- result = Hash.new
130
- # name is always the first line in /etc/SuSE-release
131
- result["name"] = strip_arch_from_name(suse_release.split("\n").first)
122
+ os
123
+ end
132
124
 
133
- result["patchlevel"] = nil
134
- suse_release.split("\n").slice(1, suse_release.length).each do |line|
135
- unless line.start_with?("#")
136
- key, value = line.split("=")
137
- result[key.strip.downcase] = value.strip
125
+ # checks for old suse standard: /etc/SuSE-release
126
+ def get_os_from_suse_release
127
+ suse_release = @system.read_file("/etc/SuSE-release")
128
+ return unless suse_release
129
+
130
+ result = Hash.new
131
+ # name is always the first line in /etc/SuSE-release
132
+ result["name"] = strip_arch_from_name(suse_release.split("\n").first)
133
+
134
+ result["patchlevel"] = nil
135
+ suse_release.split("\n").slice(1, suse_release.length).each do |line|
136
+ unless line.start_with?("#")
137
+ key, value = line.split("=")
138
+ result[key.strip.downcase] = value.strip
139
+ end
138
140
  end
139
- end
140
141
 
141
- if result["version"] && !result["patchlevel"].nil?
142
- result["version"] = "#{result["version"]} SP#{result["patchlevel"]}"
143
- end
142
+ if result["version"] && !result["patchlevel"].nil?
143
+ result["version"] = "#{result["version"]} SP#{result["patchlevel"]}"
144
+ end
144
145
 
145
- if result["codename"] == "Tumbleweed"
146
- os = Os.for ("openSUSE Tumbleweed")
147
- else
148
- os = Os.for(result["name"])
149
- end
146
+ os = if result["codename"] == "Tumbleweed"
147
+ Os.for "openSUSE Tumbleweed"
148
+ else
149
+ Os.for result["name"]
150
+ end
150
151
 
151
- os.version = result["version"]
152
- os
153
- end
152
+ os.version = result["version"]
153
+ os
154
+ end
154
155
 
155
- # checks for redhat standard: /etc/redhat-release
156
- def get_os_from_redhat_release
157
- redhat_release = @system.read_file("/etc/redhat-release")
158
- return unless redhat_release
156
+ # checks for redhat standard: /etc/redhat-release
157
+ def get_os_from_redhat_release
158
+ redhat_release = @system.read_file("/etc/redhat-release")
159
+ return unless redhat_release
159
160
 
160
- result = Hash.new
161
- result["name"], result["version"] = redhat_release.split("\n").first.split(" release ")
161
+ result = Hash.new
162
+ result["name"], result["version"] = redhat_release.split("\n").first.split(" release ")
162
163
 
163
- os = Os.for(result["name"])
164
- os.version = result["version"]
165
- os
164
+ os = Os.for(result["name"])
165
+ os.version = result["version"]
166
+ os
167
+ end
166
168
  end
167
169
  end