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.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +10 -0
- data/bin/machinery +1 -1
- data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
- data/lib/autoyast.rb +2 -2
- data/lib/build_task.rb +10 -7
- data/lib/cli.rb +1005 -801
- data/lib/compare_task.rb +11 -7
- data/lib/comparison.rb +2 -2
- data/lib/config_base.rb +1 -1
- data/lib/config_task.rb +1 -1
- data/lib/containerize_task.rb +3 -3
- data/lib/containerized_app.rb +1 -1
- data/lib/copy_task.rb +1 -1
- data/lib/current_user.rb +1 -1
- data/lib/deploy_task.rb +6 -4
- data/lib/diff_widget.rb +67 -63
- data/lib/docker_system.rb +12 -8
- data/lib/dpkg_database.rb +1 -1
- data/lib/element_filter.rb +7 -4
- data/lib/exceptions.rb +23 -5
- data/lib/export_task.rb +1 -1
- data/lib/exporter.rb +1 -1
- data/lib/file_diff.rb +1 -1
- data/lib/file_scope.rb +1 -1
- data/lib/file_validator.rb +7 -4
- data/lib/filter.rb +97 -93
- data/lib/filter_option_parser.rb +2 -2
- data/lib/hint.rb +64 -59
- data/lib/html.rb +1 -1
- data/lib/inspect_task.rb +12 -12
- data/lib/inspector.rb +3 -3
- data/lib/json_validation_error_cleaner.rb +1 -1
- data/lib/json_validator.rb +4 -4
- data/lib/kiwi_config.rb +8 -4
- data/lib/list_task.rb +10 -9
- data/lib/local_system.rb +11 -5
- data/lib/logged_cheetah.rb +1 -1
- data/lib/man_task.rb +10 -6
- data/lib/managed_files_database.rb +1 -1
- data/lib/manifest.rb +5 -5
- data/lib/migration.rb +16 -10
- data/lib/mountpoints.rb +1 -1
- data/lib/move_task.rb +1 -1
- data/lib/remote_system.rb +7 -7
- data/lib/remove_task.rb +1 -1
- data/lib/renderer.rb +177 -172
- data/lib/rpm.rb +4 -4
- data/lib/rpm_database.rb +1 -1
- data/lib/scope.rb +2 -2
- data/lib/scope_file_access_archive.rb +1 -1
- data/lib/scope_file_access_flat.rb +1 -1
- data/lib/scope_file_store.rb +1 -1
- data/lib/serve_html_task.rb +6 -2
- data/lib/server.rb +19 -12
- data/lib/show_task.rb +10 -6
- data/lib/static_html.rb +1 -1
- data/lib/system.rb +10 -10
- data/lib/system_description.rb +14 -13
- data/lib/system_description_memory_store.rb +1 -1
- data/lib/system_description_store.rb +9 -9
- data/lib/tarball.rb +8 -2
- data/lib/upgrade_format_task.rb +11 -6
- data/lib/validate_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/workload_mapper.rb +2 -2
- data/lib/workload_mapper_dsl.rb +1 -1
- data/lib/zypper.rb +40 -17
- data/machinery-helper/machinery_helper.go +35 -16
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/site/sitemap.xml +24 -24
- data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
- data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
- data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
- data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
- data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
- data/plugins/environment/environment_inspector.rb +25 -23
- data/plugins/environment/environment_model.rb +5 -3
- data/plugins/groups/groups_inspector.rb +30 -28
- data/plugins/groups/groups_model.rb +18 -17
- data/plugins/groups/groups_renderer.rb +29 -25
- data/plugins/os/os_inspector.rb +120 -118
- data/plugins/os/os_model.rb +139 -134
- data/plugins/os/os_renderer.rb +13 -9
- data/plugins/packages/packages_inspector.rb +99 -86
- data/plugins/packages/packages_model.rb +35 -34
- data/plugins/packages/packages_renderer.rb +47 -39
- data/plugins/patterns/patterns_inspector.rb +70 -68
- data/plugins/patterns/patterns_model.rb +19 -18
- data/plugins/patterns/patterns_renderer.rb +36 -32
- data/plugins/repositories/repositories_inspector.rb +162 -156
- data/plugins/repositories/repositories_model.rb +50 -49
- data/plugins/repositories/repositories_renderer.rb +48 -44
- data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
- data/plugins/services/services_inspector.rb +187 -176
- data/plugins/services/services_model.rb +37 -36
- data/plugins/services/services_renderer.rb +28 -24
- data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
- data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
- data/plugins/users/users_inspector.rb +67 -65
- data/plugins/users/users_model.rb +37 -36
- data/plugins/users/users_renderer.rb +31 -27
- data/schema/migrations/migrate1to2.rb +1 -1
- data/schema/migrations/migrate2to3.rb +1 -1
- data/schema/migrations/migrate3to4.rb +1 -1
- data/schema/migrations/migrate4to5.rb +1 -1
- data/schema/migrations/migrate5to6.rb +1 -1
- data/schema/migrations/migrate6to7.rb +1 -1
- data/schema/migrations/migrate7to8.rb +1 -1
- data/schema/migrations/migrate8to9.rb +1 -1
- data/schema/migrations/migrate9to10.rb +1 -1
- 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
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
+
list do
|
31
|
+
file_status = description["changed_managed_files"].extracted
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
55
|
+
def display_name
|
56
|
+
"Changed Managed Files"
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
19
|
-
|
18
|
+
module Machinery
|
19
|
+
class EnvironmentInspector < Machinery::Inspector
|
20
|
+
has_priority 5
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def initialize(system, description)
|
23
|
+
@system = system
|
24
|
+
@description = description
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def inspect(_filter = nil, _options = {})
|
28
|
+
environment = EnvironmentScope.new
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
environment.locale = get_locale
|
31
|
+
environment.system_type = @system.type
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
@description.environment = environment
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
+
private
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
46
|
+
all_locales = output.split
|
47
|
+
locale = all_locales.find { |l| l.downcase.match(/en_us.utf.?8/) }
|
47
48
|
|
48
|
-
|
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
|
-
|
19
|
-
|
18
|
+
module Machinery
|
19
|
+
class EnvironmentScope < Machinery::Object
|
20
|
+
include Machinery::Scope
|
20
21
|
|
21
|
-
|
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
|
-
|
19
|
-
|
18
|
+
module Machinery
|
19
|
+
class GroupsInspector < Machinery::Inspector
|
20
|
+
has_priority 60
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def initialize(system, description)
|
23
|
+
@system = system
|
24
|
+
@description = description
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def inspect(_filter, _options = {})
|
28
|
+
group_content = @system.read_file("/etc/group")
|
28
29
|
|
29
|
-
|
30
|
+
groups = group_content ? parse_groups(group_content) : []
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
@description.groups = GroupsScope.new(groups.sort_by(&:name))
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def summary
|
36
|
+
"Found #{Machinery.pluralize(@description.groups.size, "%d group")}."
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
+
private
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
+
gid = Machinery.is_int?(gid) ? gid.to_i : nil
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
attrs = {
|
50
|
+
name: name,
|
51
|
+
password: password,
|
52
|
+
gid: gid,
|
53
|
+
users: users.split(",")
|
54
|
+
}
|
54
55
|
|
55
|
-
|
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
|
20
|
-
|
21
|
-
|
22
|
-
class GroupsScope < Machinery::Array
|
23
|
-
include Machinery::Scope
|
22
|
+
class GroupsScope < Machinery::Array
|
23
|
+
include Machinery::Scope
|
24
24
|
|
25
|
-
|
25
|
+
has_elements class: Group
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
18
|
+
module Machinery
|
19
|
+
class Ui
|
20
|
+
class GroupsRenderer < Machinery::Ui::Renderer
|
21
|
+
def content(description)
|
22
|
+
return unless description.groups
|
21
23
|
|
22
|
-
|
24
|
+
na_note("group ID") if description.groups.any? { |a| a[:gid].nil? }
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
32
|
+
item "#{group.name} (#{details})"
|
33
|
+
end
|
34
|
+
end
|
31
35
|
end
|
32
|
-
end
|
33
|
-
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
def display_name
|
38
|
+
"Groups"
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
data/plugins/os/os_inspector.rb
CHANGED
@@ -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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
44
|
-
|
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
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
44
|
+
def inspect(_filter, _options = {})
|
45
|
+
@system.check_requirement("cat", "--version") if @system.is_a?(Machinery::RemoteSystem)
|
62
46
|
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
68
|
-
unless os
|
69
|
-
os = get_os_from_suse_release
|
55
|
+
@description.os = os
|
70
56
|
end
|
71
57
|
|
72
|
-
|
73
|
-
|
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
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
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
|
-
#
|
94
|
-
|
95
|
-
|
68
|
+
# Fall back to SuSE-release file
|
69
|
+
unless os
|
70
|
+
os = get_os_from_suse_release
|
96
71
|
end
|
97
72
|
|
98
|
-
#
|
99
|
-
|
100
|
-
|
73
|
+
# Fall back to redhat-release file
|
74
|
+
unless os
|
75
|
+
os = get_os_from_redhat_release
|
101
76
|
end
|
102
77
|
|
103
|
-
|
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
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
130
|
-
|
131
|
-
result["name"] = strip_arch_from_name(suse_release.split("\n").first)
|
122
|
+
os
|
123
|
+
end
|
132
124
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
142
|
+
if result["version"] && !result["patchlevel"].nil?
|
143
|
+
result["version"] = "#{result["version"]} SP#{result["patchlevel"]}"
|
144
|
+
end
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
os = if result["codename"] == "Tumbleweed"
|
147
|
+
Os.for "openSUSE Tumbleweed"
|
148
|
+
else
|
149
|
+
Os.for result["name"]
|
150
|
+
end
|
150
151
|
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
os.version = result["version"]
|
153
|
+
os
|
154
|
+
end
|
154
155
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
161
|
-
|
161
|
+
result = Hash.new
|
162
|
+
result["name"], result["version"] = redhat_release.split("\n").first.split(" release ")
|
162
163
|
|
163
|
-
|
164
|
-
|
165
|
-
|
164
|
+
os = Os.for(result["name"])
|
165
|
+
os.version = result["version"]
|
166
|
+
os
|
167
|
+
end
|
166
168
|
end
|
167
169
|
end
|