machinery-tool 1.16.4 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +10 -0
  4. data/filters/default_filters.json +21 -20
  5. data/html/assets/machinery-base.js +4 -0
  6. data/html/index.html.haml +1 -1
  7. data/html/partials/changed_managed_files.html.haml +2 -2
  8. data/html/partials/compare/changed_managed_file_list.html.haml +2 -2
  9. data/html/partials/compare/changed_managed_files.html.haml +3 -3
  10. data/html/partials/compare/config_file_list.html.haml +2 -2
  11. data/html/partials/compare/config_files.html.haml +3 -3
  12. data/html/partials/compare/packages.html.haml +21 -4
  13. data/html/partials/compare/repositories.html.haml +10 -7
  14. data/html/partials/compare/repository_list_apt.html.haml +15 -0
  15. data/html/partials/compare/repository_list_yum.html.haml +35 -0
  16. data/html/partials/compare/{repository_list.html.haml → repository_list_zypp.html.haml} +0 -0
  17. data/html/partials/compare/service_list.html.haml +1 -1
  18. data/html/partials/compare/services.html.haml +3 -3
  19. data/html/partials/compare/unmanaged_file_list.html.haml +2 -2
  20. data/html/partials/compare/unmanaged_files.html.haml +1 -1
  21. data/html/partials/config_files.html.haml +39 -41
  22. data/html/partials/repositories.html.haml +1 -23
  23. data/html/partials/repositories_apt.html.haml +15 -0
  24. data/html/partials/repositories_yum.html.haml +30 -0
  25. data/html/partials/repositories_zypp.html.haml +24 -0
  26. data/html/partials/services.html.haml +2 -2
  27. data/html/partials/unmanaged_files.html.haml +2 -2
  28. data/inspect_helpers/dpkg_unmanaged_files.sh +47 -0
  29. data/inspect_helpers/yum_repositories.py +3 -5
  30. data/lib/analyze_config_file_diffs_task.rb +11 -1
  31. data/lib/array.rb +97 -35
  32. data/lib/autoyast.rb +13 -2
  33. data/lib/cli.rb +10 -2
  34. data/lib/config.rb +4 -4
  35. data/lib/dpkg_database.rb +68 -0
  36. data/lib/element_filter.rb +2 -0
  37. data/lib/file_diff.rb +2 -2
  38. data/lib/file_scope.rb +10 -49
  39. data/lib/file_validator.rb +10 -4
  40. data/lib/filter.rb +6 -6
  41. data/lib/filter_option_parser.rb +1 -1
  42. data/lib/kiwi_config.rb +13 -10
  43. data/lib/machinery.rb +2 -0
  44. data/lib/machinery_helper.rb +1 -1
  45. data/lib/managed_files_database.rb +200 -0
  46. data/lib/object.rb +5 -3
  47. data/lib/remote_system.rb +43 -10
  48. data/lib/renderer.rb +3 -4
  49. data/lib/rpm_database.rb +7 -183
  50. data/lib/scope_file_access_archive.rb +3 -3
  51. data/lib/scope_file_access_flat.rb +1 -1
  52. data/lib/server.rb +7 -2
  53. data/lib/system.rb +50 -22
  54. data/lib/system_description.rb +3 -3
  55. data/lib/version.rb +1 -1
  56. data/lib/workload_mapper.rb +2 -2
  57. data/machinery-helper/machinery_helper.go +252 -178
  58. data/machinery-helper/machinery_helper_test.go +121 -121
  59. data/machinery-helper/mountpoints.go +28 -28
  60. data/machinery-helper/tar.go +105 -104
  61. data/machinery-helper/version.go +1 -1
  62. data/man/generated/machinery.1.gz +0 -0
  63. data/man/generated/machinery.1.html +19 -8
  64. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +3 -3
  65. data/plugins/changed_managed_files/changed_managed_files_model.rb +3 -1
  66. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +2 -2
  67. data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v6.json +168 -0
  68. data/plugins/config_files/config_files_inspector.rb +4 -4
  69. data/plugins/config_files/config_files_model.rb +3 -1
  70. data/plugins/config_files/config_files_renderer.rb +2 -2
  71. data/plugins/config_files/schema/system-description-config-files.schema-v6.json +160 -0
  72. data/plugins/environment/schema/system-description-environment.schema-v6.json +17 -0
  73. data/plugins/groups/schema/system-description-groups.schema-v6.json +49 -0
  74. data/plugins/os/schema/system-description-os.schema-v6.json +21 -0
  75. data/plugins/packages/packages_inspector.rb +76 -6
  76. data/plugins/packages/packages_model.rb +31 -12
  77. data/plugins/packages/packages_renderer.rb +5 -2
  78. data/plugins/packages/schema/system-description-packages.schema-v6.json +115 -0
  79. data/plugins/patterns/patterns_inspector.rb +26 -2
  80. data/plugins/patterns/schema/system-description-patterns.schema-v6.json +58 -0
  81. data/plugins/repositories/repositories_inspector.rb +41 -14
  82. data/plugins/repositories/repositories_model.rb +55 -12
  83. data/plugins/repositories/repositories_renderer.rb +23 -7
  84. data/plugins/repositories/schema/system-description-repositories.schema-v6.json +165 -0
  85. data/plugins/services/schema/system-description-services.schema-v6.json +93 -0
  86. data/plugins/services/services_inspector.rb +88 -22
  87. data/plugins/services/services_model.rb +9 -15
  88. data/plugins/services/services_renderer.rb +2 -2
  89. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v6.json +162 -0
  90. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +80 -30
  91. data/plugins/unmanaged_files/unmanaged_files_model.rb +22 -18
  92. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +3 -3
  93. data/plugins/users/schema/system-description-users.schema-v6.json +86 -0
  94. data/schema/migrations/migrate5to6.rb +101 -0
  95. data/schema/system-description-global.schema-v6.json +43 -0
  96. metadata +24 -4
  97. data/html/assets/landing_page/landing_page.js +0 -10
@@ -27,9 +27,11 @@ class RepositoriesInspector < Inspector
27
27
  @description.repositories = inspect_zypp_repositories
28
28
  elsif system.has_command?("yum")
29
29
  @description.repositories = inspect_yum_repositories
30
+ elsif system.has_command?("apt")
31
+ @description.repositories = inspect_apt_repositories
30
32
  else
31
33
  raise Machinery::Errors::MissingRequirement.new(
32
- "Need either the binary 'zypper' or 'yum' to be available on the inspected system."
34
+ "Need either the binary 'zypper', 'yum' or 'apt' to be available on the inspected system."
33
35
  )
34
36
  end
35
37
  end
@@ -66,7 +68,7 @@ class RepositoriesInspector < Inspector
66
68
  result = parse_repositories_from_xml(xml, priorities, credentials)
67
69
  end
68
70
 
69
- RepositoriesScope.new(result)
71
+ RepositoriesScope.new(result, repository_system: "zypp")
70
72
  end
71
73
 
72
74
  def inspect_yum_repositories
@@ -74,14 +76,7 @@ class RepositoriesInspector < Inspector
74
76
  begin
75
77
  repositories = JSON.parse(system.run_command(
76
78
  "bash", "-c", "python", stdin: script, stdout: :capture
77
- ).split("\n").last).map { |element| Repository.new(element) }
78
- repositories.each do |repository|
79
- if repository.url.empty?
80
- raise Machinery::Errors::InspectionFailed.new(
81
- "Yum repository baseurl is missing. Metalinks are not supported at the moment."
82
- )
83
- end
84
- end
79
+ ).split("\n").last).map { |element| YumRepository.new(element) }
85
80
  rescue JSON::ParserError
86
81
  raise Machinery::Errors::InspectionFailed.new("Extraction of YUM repositories failed.")
87
82
  rescue Cheetah::ExecutionFailed => e
@@ -90,7 +85,40 @@ class RepositoriesInspector < Inspector
90
85
  )
91
86
  end
92
87
 
93
- RepositoriesScope.new(repositories)
88
+ RepositoriesScope.new(repositories, repository_system: "yum")
89
+ end
90
+
91
+ def inspect_apt_repositories
92
+ content = system.read_file("/etc/apt/sources.list")
93
+ begin
94
+ content += "\n" + system.run_command(
95
+ "bash", "-c", "cat /etc/apt/sources.list.d/*.list", stdout: :capture
96
+ )
97
+ rescue Cheetah::ExecutionFailed
98
+ end
99
+
100
+ RepositoriesScope.new(
101
+ parse_apt_repositories(content), repository_system: "apt"
102
+ )
103
+ end
104
+
105
+ def parse_apt_repositories(content)
106
+ repositories = []
107
+ content.each_line do |line|
108
+ if line =~ /^\s*(deb|deb-src)\s+(\S+)\s+(\S+)(\s+\S[^#]*\S)?(\s*|\s*#.*)$/
109
+ repositories << AptRepository.new(
110
+ type: $1,
111
+ url: $2,
112
+ distribution: $3,
113
+ components: $4 ? $4.strip.split(" ") : []
114
+ )
115
+ elsif line =~ /Types: deb/
116
+ Machinery::Ui.warn(
117
+ "Warning: An unsupported rfc822 style repository was found, which will be ignored."
118
+ )
119
+ end
120
+ end
121
+ repositories.uniq
94
122
  end
95
123
 
96
124
  def parse_priorities_from_details(details)
@@ -154,7 +182,7 @@ class RepositoriesInspector < Inspector
154
182
  password = credentials[cred_value][:password]
155
183
  end
156
184
 
157
- repository = Repository.new(
185
+ repository = ZyppRepository.new(
158
186
  alias: rep["alias"],
159
187
  name: rep["name"],
160
188
  type: rep["type"],
@@ -162,8 +190,7 @@ class RepositoriesInspector < Inspector
162
190
  enabled: rep["enabled"] == "1",
163
191
  autorefresh: rep["autorefresh"] == "1",
164
192
  gpgcheck: rep["gpgcheck"] == "1",
165
- priority: pri_value,
166
- package_manager: "zypp"
193
+ priority: pri_value
167
194
  )
168
195
  if username && password
169
196
  repository[:username] = username
@@ -22,22 +22,65 @@ class Repository < Machinery::Object
22
22
  end
23
23
  end
24
24
 
25
+ class ZyppRepository < Repository
26
+ class << self
27
+ def key
28
+ "alias"
29
+ end
30
+
31
+ def attributes
32
+ ["name", "url", "type", "enabled", "autorefresh", "gpgcheck", "priority", "gpgkey"]
33
+ end
34
+ end
35
+ end
36
+
37
+ class YumRepository < Repository
38
+ class << self
39
+ def key
40
+ "alias"
41
+ end
42
+
43
+ def attributes
44
+ ["name", "url", "type", "enabled", "gpgcheck", "priority", "mirrorlist", "gpgkey"]
45
+ end
46
+ end
47
+ end
48
+
49
+ class AptRepository < Repository
50
+ class << self
51
+ def key
52
+ "url"
53
+ end
54
+
55
+ def attributes
56
+ ["url", "type", "distribution", "components"]
57
+ end
58
+ end
59
+ end
60
+
25
61
  class RepositoriesScope < Machinery::Array
26
62
  include Machinery::Scope
27
63
 
28
- has_elements class: Repository
64
+ has_attributes :repository_system
65
+ has_elements class: ZyppRepository, if: { repository_system: "zypp" }
66
+ has_elements class: YumRepository, if: { repository_system: "yum" }
67
+ has_elements class: AptRepository, if: { repository_system: "apt" }
29
68
 
30
69
  def compare_with(other)
31
- only_self = self - other
32
- only_other = other - self
33
- common = self & other
34
- changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :alias)
35
-
36
- [
37
- only_self,
38
- only_other,
39
- changed,
40
- common
41
- ].map { |e| (e && !e.empty?) ? e : nil }
70
+ if self.repository_system != other.repository_system
71
+ [self, other, nil, nil]
72
+ else
73
+ only_self = self - other
74
+ only_other = other - self
75
+ changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :alias)
76
+ common = self & other
77
+
78
+ [
79
+ only_self,
80
+ only_other,
81
+ changed,
82
+ common
83
+ ].map { |e| (e && !e.empty?) ? e : nil }
84
+ end
42
85
  end
43
86
  end
@@ -25,13 +25,29 @@ class RepositoriesRenderer < Renderer
25
25
 
26
26
  list do
27
27
  description.repositories.each do |p|
28
- item "#{p.name}" do
29
- puts "URI: #{p.url}"
30
- puts "Alias: #{p.alias}"
31
- puts "Enabled: #{p.enabled ? "Yes" : "No"}"
32
- puts "Refresh: #{p.autorefresh ? "Yes" : "No"}" if p.autorefresh != nil
33
- puts "Priority: #{p.priority}" if p.priority != nil
34
- puts "Package Manager: #{p.package_manager}"
28
+ item_name = if p.name
29
+ p.name
30
+ else
31
+ "URI: #{p.url}"
32
+ end
33
+ item item_name do
34
+ if p.url.is_a?(Array)
35
+ list "URI", sublist: true do
36
+ p.url.each do |url|
37
+ item url
38
+ end
39
+ end
40
+ elsif p.name
41
+ puts "URI: #{p.url}"
42
+ end
43
+ puts "Mirrorlist: #{!p.mirrorlist.empty? ? p.mirrorlist : "N/A"}" if p.mirrorlist
44
+ puts "Alias: #{p.alias}" if p.alias
45
+ puts "Distribution: #{p.distribution}" if p.distribution
46
+ puts "Components: #{p.components.join(", ")}" if p.components
47
+ puts "Enabled: #{p.enabled ? "Yes" : "No"}" unless p.enabled.nil?
48
+ puts "Refresh: #{p.autorefresh ? "Yes" : "No"}" unless p.autorefresh.nil?
49
+ puts "Priority: #{p.priority}" unless p.priority.nil?
50
+ puts "Type: #{p.type || "N/A"}"
35
51
  end
36
52
  end
37
53
  end
@@ -0,0 +1,165 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "required": [
5
+ "_elements"
6
+ ],
7
+ "oneOf": [
8
+ {
9
+ "properties": {
10
+ "_attributes": {
11
+ "type": "object",
12
+ "required": [
13
+ "repository_system"
14
+ ],
15
+ "properties": {
16
+ "repository_system": {
17
+ "enum": ["zypp"]
18
+ }
19
+ }
20
+ },
21
+ "_elements": {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "object",
25
+ "required": ["alias", "name", "url", "type", "enabled", "gpgcheck", "autorefresh", "priority"],
26
+ "properties": {
27
+ "alias": {
28
+ "type": "string",
29
+ "minLength": 1
30
+ },
31
+ "name": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "type": {
36
+ "enum": ["yast2", "rpm-md", "plaindir", null]
37
+ },
38
+ "url": {
39
+ "type": "string",
40
+ "format": "uri",
41
+ "minLength": 1
42
+ },
43
+ "enabled": {
44
+ "type": "boolean"
45
+ },
46
+ "autorefresh": {
47
+ "type": "boolean"
48
+ },
49
+ "gpgcheck": {
50
+ "type": "boolean"
51
+ },
52
+ "priority": {
53
+ "type": "integer",
54
+ "minimum": 1
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "properties": {
63
+ "_attributes": {
64
+ "type": "object",
65
+ "required": [
66
+ "repository_system"
67
+ ],
68
+ "properties": {
69
+ "repository_system": {
70
+ "enum": ["yum"]
71
+ }
72
+ }
73
+ },
74
+ "_elements": {
75
+ "type": "array",
76
+ "items": {
77
+ "type": "object",
78
+ "required": ["alias", "name", "url", "type", "enabled", "gpgcheck", "gpgkey", "mirrorlist"],
79
+ "properties": {
80
+ "alias": {
81
+ "type": "string",
82
+ "minLength": 1
83
+ },
84
+ "mirrorlist": {
85
+ "type": "string"
86
+ },
87
+ "name": {
88
+ "type": "string",
89
+ "minLength": 1
90
+ },
91
+ "type": {
92
+ "enum": ["rpm-md", null]
93
+ },
94
+ "url": {
95
+ "type": "array",
96
+ "items": {
97
+ "type": "string",
98
+ "format": "url",
99
+ "minLength": 1
100
+ }
101
+ },
102
+ "enabled": {
103
+ "type": "boolean"
104
+ },
105
+ "gpgcheck": {
106
+ "type": "boolean"
107
+ },
108
+ "gpgkey": {
109
+ "type": "array",
110
+ "items": {
111
+ "type": "string",
112
+ "format": "url",
113
+ "minLength": 1
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ },
121
+ {
122
+ "properties": {
123
+ "_attributes": {
124
+ "type": "object",
125
+ "required": [
126
+ "repository_system"
127
+ ],
128
+ "properties": {
129
+ "repository_system": {
130
+ "enum": ["apt"]
131
+ }
132
+ }
133
+ },
134
+ "_elements": {
135
+ "type": "array",
136
+ "items": {
137
+ "type": "object",
138
+ "required": ["url", "type", "distribution", "components"],
139
+ "properties": {
140
+ "distribution": {
141
+ "type": "string",
142
+ "minLength": 1
143
+ },
144
+ "type": {
145
+ "enum": ["deb", "deb-src"]
146
+ },
147
+ "url": {
148
+ "type": "string",
149
+ "format": "uri",
150
+ "minLength": 1
151
+ },
152
+ "components": {
153
+ "type": "array",
154
+ "items": {
155
+ "type": "string",
156
+ "minLength": 1
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ ]
165
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+
4
+ "type": "object",
5
+ "required": [
6
+ "_elements"
7
+ ],
8
+ "oneOf": [
9
+ {
10
+ "properties": {
11
+ "_attributes": {
12
+ "type": "object",
13
+ "required": [
14
+ "init_system"
15
+ ],
16
+ "properties": {
17
+ "init_system": {
18
+ "not": {
19
+ "enum": [
20
+ "upstart"
21
+ ]
22
+ },
23
+ "type": "string",
24
+ "minLength": 1
25
+ }
26
+ }
27
+ },
28
+ "_elements": {
29
+ "type": "array",
30
+ "items": {
31
+ "type": "object",
32
+ "required": [
33
+ "name",
34
+ "state"
35
+ ],
36
+ "properties": {
37
+ "name": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "state": {
42
+ "type": "string",
43
+ "minLength": 1
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ },
50
+ {
51
+ "properties": {
52
+ "_attributes": {
53
+ "type": "object",
54
+ "required": [
55
+ "init_system"
56
+ ],
57
+ "properties": {
58
+ "init_system": {
59
+ "enum": [
60
+ "upstart"
61
+ ]
62
+ }
63
+ }
64
+ },
65
+ "_elements": {
66
+ "type": "array",
67
+ "items": {
68
+ "type": "object",
69
+ "required": [
70
+ "name",
71
+ "state",
72
+ "legacy_sysv"
73
+ ],
74
+ "properties": {
75
+ "name": {
76
+ "type": "string",
77
+ "minLength": 1
78
+ },
79
+ "state": {
80
+ "type": "string",
81
+ "minLength": 1
82
+ },
83
+ "legacy_sysv": {
84
+ "type": "boolean"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ]
92
+ }
93
+