machinery-tool 1.17.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +17 -1
  4. data/bin/machinery +1 -1
  5. data/export_helpers/merge_users_and_groups.pl.erb +1 -1
  6. data/html/comparison.html.haml +14 -9
  7. data/html/index.html.haml +5 -2
  8. data/html/landing_page.html.haml +4 -1
  9. data/html/partials/changed_managed_files.html.haml +2 -0
  10. data/html/partials/compare/alert.html.haml +1 -1
  11. data/html/partials/compare/unmanaged_file_list.html.haml +12 -0
  12. data/html/partials/config_files.html.haml +2 -0
  13. data/html/partials/landing_page/alert.html.haml +1 -1
  14. data/html/partials/unmanaged_files.html.haml +14 -0
  15. data/inspect_helpers/changed_files.sh +1 -1
  16. data/inspect_helpers/dpkg_unmanaged_files.sh +1 -1
  17. data/inspect_helpers/yum_repositories.py +1 -1
  18. data/lib/analyze_config_file_diffs_task.rb +1 -1
  19. data/lib/array.rb +1 -1
  20. data/lib/autoyast.rb +34 -34
  21. data/lib/build_task.rb +1 -1
  22. data/lib/cli.rb +21 -6
  23. data/lib/compare_task.rb +1 -1
  24. data/lib/comparison.rb +1 -1
  25. data/lib/config.rb +1 -1
  26. data/lib/config_base.rb +1 -1
  27. data/lib/config_task.rb +1 -1
  28. data/lib/constants.rb +2 -2
  29. data/lib/containerize_task.rb +1 -1
  30. data/lib/containerized_app.rb +1 -1
  31. data/lib/copy_task.rb +1 -1
  32. data/lib/current_user.rb +1 -1
  33. data/lib/deploy_task.rb +1 -1
  34. data/lib/docker_system.rb +4 -5
  35. data/lib/dpkg_database.rb +2 -2
  36. data/lib/element_filter.rb +1 -1
  37. data/lib/exceptions.rb +2 -2
  38. data/lib/export_task.rb +1 -1
  39. data/lib/exporter.rb +1 -1
  40. data/lib/file_diff.rb +1 -1
  41. data/lib/file_scope.rb +1 -1
  42. data/lib/file_validator.rb +1 -1
  43. data/lib/filter.rb +1 -1
  44. data/lib/filter_option_parser.rb +1 -1
  45. data/lib/helper.rb +1 -1
  46. data/lib/hint.rb +1 -1
  47. data/lib/html.rb +1 -1
  48. data/lib/inspect_task.rb +1 -1
  49. data/lib/inspector.rb +1 -1
  50. data/lib/json_schema_monkey_patch.rb +35 -0
  51. data/lib/json_validation_error_cleaner.rb +1 -1
  52. data/lib/json_validator.rb +1 -1
  53. data/lib/kiwi_config.rb +69 -67
  54. data/lib/list_task.rb +1 -1
  55. data/lib/local_system.rb +1 -1
  56. data/lib/logged_cheetah.rb +1 -1
  57. data/lib/machinery.rb +6 -2
  58. data/lib/machinery_helper.rb +28 -8
  59. data/lib/machinery_logger.rb +1 -1
  60. data/lib/man_task.rb +50 -5
  61. data/lib/managed_files_database.rb +24 -17
  62. data/lib/manifest.rb +3 -2
  63. data/lib/migration.rb +1 -1
  64. data/lib/mountpoints.rb +1 -1
  65. data/lib/move_task.rb +1 -1
  66. data/lib/object.rb +1 -1
  67. data/lib/remote_system.rb +2 -2
  68. data/lib/remove_task.rb +1 -1
  69. data/lib/renderer.rb +1 -1
  70. data/lib/renderer_helper.rb +1 -1
  71. data/lib/rpm.rb +1 -1
  72. data/lib/rpm_database.rb +1 -1
  73. data/lib/scope.rb +1 -1
  74. data/lib/scope_file_store.rb +1 -1
  75. data/lib/serve_html_task.rb +1 -1
  76. data/lib/server.rb +32 -2
  77. data/lib/show_task.rb +1 -1
  78. data/lib/system.rb +1 -1
  79. data/lib/system_description.rb +2 -2
  80. data/lib/system_description_memory_store.rb +1 -1
  81. data/lib/system_description_store.rb +1 -1
  82. data/lib/system_file.rb +1 -1
  83. data/lib/tarball.rb +1 -1
  84. data/lib/tee_io.rb +39 -0
  85. data/lib/try.rb +1 -1
  86. data/lib/ui.rb +1 -1
  87. data/lib/upgrade_format_task.rb +1 -1
  88. data/lib/validate_task.rb +1 -1
  89. data/lib/version.rb +2 -2
  90. data/lib/workload_mapper.rb +1 -1
  91. data/lib/workload_mapper_dsl.rb +1 -1
  92. data/lib/zypper.rb +3 -3
  93. data/machinery-helper/Rakefile +2 -8
  94. data/machinery-helper/file_utils.go +28 -0
  95. data/machinery-helper/file_utils_test.go +21 -0
  96. data/machinery-helper/machinery_helper.go +121 -8
  97. data/machinery-helper/machinery_helper_test.go +102 -0
  98. data/machinery-helper/mountpoints_test.go +33 -33
  99. data/machinery-helper/version.go +1 -1
  100. data/man/generated/machinery.1.gz +0 -0
  101. data/manual/custom_theme/base.html +42 -0
  102. data/manual/docs/CNAME +1 -0
  103. data/manual/docs/README.md +128 -0
  104. data/manual/docs/css/bootstrap.min.css +7 -0
  105. data/manual/docs/css/custom.css +788 -0
  106. data/manual/docs/css/fixed-positioning.css +45 -0
  107. data/manual/docs/custom.css +804 -0
  108. data/manual/docs/docs.md +7 -0
  109. data/manual/docs/favicon.png +0 -0
  110. data/manual/docs/hand3.png +0 -0
  111. data/manual/docs/img/arrow.png +0 -0
  112. data/manual/docs/img/background/1.png +0 -0
  113. data/manual/docs/img/background/2.png +0 -0
  114. data/manual/docs/img/background/3.png +0 -0
  115. data/manual/docs/img/background/4.png +0 -0
  116. data/manual/docs/img/background/5.png +0 -0
  117. data/manual/docs/img/background/6.png +0 -0
  118. data/manual/docs/img/background/7.png +0 -0
  119. data/manual/docs/img/bk-cloud.png +0 -0
  120. data/manual/docs/img/bk-sec-15.png +0 -0
  121. data/manual/docs/img/book.png +0 -0
  122. data/manual/docs/img/configuration-discovery.png +0 -0
  123. data/manual/docs/img/dot-line-left.png +0 -0
  124. data/manual/docs/img/dot-line-right.png +0 -0
  125. data/manual/docs/img/gear.png +0 -0
  126. data/manual/docs/img/gear2.png +0 -0
  127. data/manual/docs/img/gear3.png +0 -0
  128. data/manual/docs/img/hand.png +0 -0
  129. data/manual/docs/img/hand2.png +0 -0
  130. data/manual/docs/img/hand3.png +0 -0
  131. data/manual/docs/img/home2.png +0 -0
  132. data/manual/docs/img/moustache.png +0 -0
  133. data/manual/docs/img/navig.png +0 -0
  134. data/manual/docs/img/philo.png +0 -0
  135. data/manual/docs/img/service-migration.png +0 -0
  136. data/manual/docs/img/system-validation.png +0 -0
  137. data/manual/docs/img/ticket2.png +0 -0
  138. data/manual/docs/img/usecase-default.png +0 -0
  139. data/manual/docs/img/usecase1.png +0 -0
  140. data/manual/docs/img/usecase2.png +0 -0
  141. data/manual/docs/img/usecase3.png +0 -0
  142. data/manual/docs/img/usecase4.png +0 -0
  143. data/manual/docs/img/wheels.png +0 -0
  144. data/manual/docs/index.html +402 -0
  145. data/manual/docs/js/bootstrap.min.js +6 -0
  146. data/manual/docs/js/custom.js +148 -0
  147. data/manual/docs/js/jquery.js +4 -0
  148. data/manual/docs/js/jquery.nicescroll.min.js +116 -0
  149. data/manual/docs/js/jquery.pageslide.min.js +11 -0
  150. data/manual/docs/js/parallaxImg.js +146 -0
  151. data/manual/docs/js/skrollr.min.js +2 -0
  152. data/manual/docs/machinery-analyze.1.md +37 -0
  153. data/manual/docs/machinery-build.1.md +62 -0
  154. data/manual/docs/machinery-compare.1.md +63 -0
  155. data/manual/docs/machinery-config.1.md +45 -0
  156. data/manual/docs/machinery-copy.1.md +31 -0
  157. data/manual/docs/machinery-deploy.1.md +71 -0
  158. data/manual/docs/machinery-export-autoyast.1.md +58 -0
  159. data/manual/docs/machinery-export-kiwi.1.md +38 -0
  160. data/manual/docs/machinery-inspect-docker.1.md +108 -0
  161. data/manual/docs/machinery-inspect.1.md +145 -0
  162. data/manual/docs/machinery-list.1.md +51 -0
  163. data/manual/docs/machinery-man.1.md +16 -0
  164. data/manual/docs/machinery-move.1.md +29 -0
  165. data/manual/docs/machinery-remove.1.md +44 -0
  166. data/manual/docs/machinery-serve.1.md +45 -0
  167. data/manual/docs/machinery-show.1.md +63 -0
  168. data/manual/docs/machinery-upgrade-format.1.md +47 -0
  169. data/manual/docs/machinery-validate.1.md +34 -0
  170. data/manual/docs/machinery.ymp +114 -0
  171. data/manual/docs/machinery_main_general.1.md +139 -0
  172. data/manual/docs/machinery_main_scopes.1.md +98 -0
  173. data/manual/docs/machinery_main_usecases.1.md +49 -0
  174. data/manual/docs/machinery_security_implications.1.md +89 -0
  175. data/manual/docs/subcommand-template.1.md +46 -0
  176. data/manual/docs/wheels.png +0 -0
  177. data/manual/mkdocs.yml +30 -0
  178. data/manual/site/CNAME +1 -0
  179. data/manual/site/base.html +42 -0
  180. data/manual/site/css/bootstrap.min.css +7 -0
  181. data/manual/site/css/custom.css +788 -0
  182. data/manual/site/css/fixed-positioning.css +45 -0
  183. data/manual/site/custom.css +804 -0
  184. data/manual/site/docs/index.html +144 -0
  185. data/manual/site/favicon.png +0 -0
  186. data/manual/site/hand3.png +0 -0
  187. data/manual/site/img/arrow.png +0 -0
  188. data/manual/site/img/background/1.png +0 -0
  189. data/manual/site/img/background/2.png +0 -0
  190. data/manual/site/img/background/3.png +0 -0
  191. data/manual/site/img/background/4.png +0 -0
  192. data/manual/site/img/background/5.png +0 -0
  193. data/manual/site/img/background/6.png +0 -0
  194. data/manual/site/img/background/7.png +0 -0
  195. data/manual/site/img/bk-cloud.png +0 -0
  196. data/manual/site/img/bk-sec-15.png +0 -0
  197. data/manual/site/img/book.png +0 -0
  198. data/manual/site/img/configuration-discovery.png +0 -0
  199. data/manual/site/img/dot-line-left.png +0 -0
  200. data/manual/site/img/dot-line-right.png +0 -0
  201. data/manual/site/img/gear.png +0 -0
  202. data/manual/site/img/gear2.png +0 -0
  203. data/manual/site/img/gear3.png +0 -0
  204. data/manual/site/img/hand.png +0 -0
  205. data/manual/site/img/hand2.png +0 -0
  206. data/manual/site/img/hand3.png +0 -0
  207. data/manual/site/img/home2.png +0 -0
  208. data/manual/site/img/moustache.png +0 -0
  209. data/manual/site/img/navig.png +0 -0
  210. data/manual/site/img/philo.png +0 -0
  211. data/manual/site/img/service-migration.png +0 -0
  212. data/manual/site/img/system-validation.png +0 -0
  213. data/manual/site/img/ticket2.png +0 -0
  214. data/manual/site/img/usecase-default.png +0 -0
  215. data/manual/site/img/usecase1.png +0 -0
  216. data/manual/site/img/usecase2.png +0 -0
  217. data/manual/site/img/usecase3.png +0 -0
  218. data/manual/site/img/usecase4.png +0 -0
  219. data/manual/site/img/wheels.png +0 -0
  220. data/manual/site/index.html +402 -0
  221. data/manual/site/js/bootstrap.min.js +6 -0
  222. data/manual/site/js/custom.js +148 -0
  223. data/manual/site/js/jquery.js +4 -0
  224. data/manual/site/js/jquery.nicescroll.min.js +116 -0
  225. data/manual/site/js/jquery.pageslide.min.js +11 -0
  226. data/manual/site/js/parallaxImg.js +146 -0
  227. data/manual/site/js/skrollr.min.js +2 -0
  228. data/manual/site/machinery-analyze.1/index.html +167 -0
  229. data/manual/site/machinery-build.1/index.html +198 -0
  230. data/manual/site/machinery-compare.1/index.html +200 -0
  231. data/manual/site/machinery-config.1/index.html +175 -0
  232. data/manual/site/machinery-copy.1/index.html +164 -0
  233. data/manual/site/machinery-deploy.1/index.html +200 -0
  234. data/manual/site/machinery-export-autoyast.1/index.html +188 -0
  235. data/manual/site/machinery-export-kiwi.1/index.html +169 -0
  236. data/manual/site/machinery-inspect-docker.1/index.html +242 -0
  237. data/manual/site/machinery-inspect.1/index.html +283 -0
  238. data/manual/site/machinery-list.1/index.html +180 -0
  239. data/manual/site/machinery-man.1/index.html +148 -0
  240. data/manual/site/machinery-move.1/index.html +162 -0
  241. data/manual/site/machinery-remove.1/index.html +175 -0
  242. data/manual/site/machinery-serve.1/index.html +174 -0
  243. data/manual/site/machinery-show.1/index.html +199 -0
  244. data/manual/site/machinery-upgrade-format.1/index.html +173 -0
  245. data/manual/site/machinery-validate.1/index.html +161 -0
  246. data/manual/site/machinery.ymp +114 -0
  247. data/manual/site/machinery_main_general.1/index.html +260 -0
  248. data/manual/site/machinery_main_scopes.1/index.html +242 -0
  249. data/manual/site/machinery_main_usecases.1/index.html +182 -0
  250. data/manual/site/machinery_security_implications.1/index.html +223 -0
  251. data/manual/site/mkdocs/js/lunr-0.5.7.min.js +7 -0
  252. data/manual/site/mkdocs/js/mustache.min.js +1 -0
  253. data/manual/site/mkdocs/js/require.js +36 -0
  254. data/manual/site/mkdocs/js/search-results-template.mustache +4 -0
  255. data/manual/site/mkdocs/js/search.js +88 -0
  256. data/manual/site/mkdocs/js/text.js +390 -0
  257. data/manual/site/mkdocs/search_index.json +824 -0
  258. data/manual/site/sitemap.xml +152 -0
  259. data/manual/site/wheels.png +0 -0
  260. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +1 -1
  261. data/plugins/changed_managed_files/changed_managed_files_model.rb +1 -1
  262. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +1 -1
  263. data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v7.json +160 -0
  264. data/plugins/config_files/config_files_inspector.rb +1 -1
  265. data/plugins/config_files/config_files_model.rb +1 -1
  266. data/plugins/config_files/config_files_renderer.rb +1 -1
  267. data/plugins/config_files/schema/system-description-config-files.schema-v7.json +160 -0
  268. data/plugins/environment/environment_inspector.rb +1 -1
  269. data/plugins/environment/environment_model.rb +1 -1
  270. data/plugins/environment/schema/system-description-environment.schema-v7.json +17 -0
  271. data/plugins/groups/groups_inspector.rb +1 -1
  272. data/plugins/groups/groups_model.rb +1 -1
  273. data/plugins/groups/groups_renderer.rb +1 -1
  274. data/plugins/groups/schema/system-description-groups.schema-v7.json +49 -0
  275. data/plugins/os/os_inspector.rb +1 -1
  276. data/plugins/os/os_model.rb +1 -1
  277. data/plugins/os/os_renderer.rb +1 -1
  278. data/plugins/os/schema/system-description-os.schema-v7.json +21 -0
  279. data/plugins/packages/packages_inspector.rb +1 -1
  280. data/plugins/packages/packages_model.rb +1 -1
  281. data/plugins/packages/packages_renderer.rb +1 -1
  282. data/plugins/packages/schema/system-description-packages.schema-v7.json +115 -0
  283. data/plugins/patterns/patterns_inspector.rb +6 -6
  284. data/plugins/patterns/patterns_model.rb +1 -1
  285. data/plugins/patterns/patterns_renderer.rb +1 -1
  286. data/plugins/patterns/schema/system-description-patterns.schema-v7.json +58 -0
  287. data/plugins/repositories/repositories_inspector.rb +16 -16
  288. data/plugins/repositories/repositories_model.rb +1 -1
  289. data/plugins/repositories/repositories_renderer.rb +1 -1
  290. data/plugins/repositories/schema/system-description-repositories.schema-v7.json +165 -0
  291. data/plugins/services/schema/system-description-services.schema-v7.json +93 -0
  292. data/plugins/services/services_inspector.rb +1 -1
  293. data/plugins/services/services_model.rb +1 -1
  294. data/plugins/services/services_renderer.rb +1 -1
  295. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v6.json +19 -61
  296. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v7.json +124 -0
  297. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +21 -436
  298. data/plugins/unmanaged_files/unmanaged_files_model.rb +2 -2
  299. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +2 -2
  300. data/plugins/users/schema/system-description-users.schema-v7.json +86 -0
  301. data/plugins/users/users_inspector.rb +1 -1
  302. data/plugins/users/users_model.rb +1 -1
  303. data/plugins/users/users_renderer.rb +1 -1
  304. data/schema/migrations/migrate1to2.rb +1 -1
  305. data/schema/migrations/migrate6to7.rb +38 -0
  306. data/schema/system-description-global.schema-v7.json +43 -0
  307. data/tools/go.rb +92 -0
  308. data/tools/helper_builder.rb +16 -49
  309. metadata +182 -6
  310. data/man/generated/machinery.1.html +0 -1399
data/lib/list_task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/local_system.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/machinery.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -32,11 +32,14 @@ require "haml"
32
32
  require "kramdown"
33
33
  require "find"
34
34
  require "pathname"
35
- require "nokogiri"
36
35
  require "socket"
37
36
  require "diffy"
38
37
  require "sinatra/base"
39
38
  require "mimemagic"
39
+ require "rexml/document"
40
+ require "builder"
41
+
42
+ require_relative "json_schema_monkey_patch"
40
43
 
41
44
  require_relative "try"
42
45
  require_relative "machinery_logger"
@@ -112,6 +115,7 @@ require_relative "docker_system"
112
115
  require_relative "managed_files_database"
113
116
  require_relative "rpm_database"
114
117
  require_relative "dpkg_database"
118
+ require_relative "tee_io"
115
119
 
116
120
  Dir[File.join(Machinery::ROOT, "plugins", "**", "*.rb")].each { |f| require(f) }
117
121
 
@@ -26,33 +26,47 @@
26
26
 
27
27
  class MachineryHelper
28
28
  attr_accessor :local_helpers_path
29
- attr_accessor :remote_helper_path
30
29
 
31
30
  def initialize(s)
32
31
  @system = s
33
- @arch = @system.arch
34
32
 
35
33
  @local_helpers_path = File.join(Machinery::ROOT, "machinery-helper")
36
- @remote_helper_path = File.join(Machinery::HELPER_REMOTE_PATH, "machinery-helper")
37
34
  end
38
35
 
39
36
  def local_helper_path
40
- File.join(local_helpers_path, "machinery-helper")
37
+ File.join(local_helpers_path, "machinery-helper-#{@system.arch}")
38
+ end
39
+
40
+ def remote_helper_path
41
+ @remote_helper_path ||= @system.run_command(
42
+ # Expand Machinery::HELPER_REMOTE_PATH on remote machine
43
+ "bash", "-c", "echo -n #{File.join(Machinery::HELPER_REMOTE_PATH, "machinery-helper")}",
44
+ stdout: :capture
45
+ )
41
46
  end
42
47
 
43
48
  # Returns true, if there is a helper binary matching the architecture of the
44
49
  # inspected system. Return false, if not.
45
50
  def can_help?
46
- File.exist?(local_helper_path) && LocalSystem.matches_architecture?(@arch)
51
+ File.exist?(local_helper_path)
47
52
  end
48
53
 
49
54
  def inject_helper
50
- @system.inject_file(local_helper_path, Machinery::HELPER_REMOTE_PATH)
55
+ @system.inject_file(local_helper_path, remote_helper_path)
51
56
  end
52
57
 
53
- def run_helper(scope)
54
- json = @system.run_command(remote_helper_path, stdout: :capture, stderr: STDERR)
58
+ def run_helper(scope, *options)
59
+ error = TeeIO.new(STDERR, "sudo: a password is required\n")
60
+ json = @system.run_command(
61
+ remote_helper_path, *options, stdout: :capture, stderr: error, privileged: true
62
+ )
55
63
  scope.insert(0, *JSON.parse(json)["files"])
64
+ rescue Cheetah::ExecutionFailed => e
65
+ if error.string.include?("password is required")
66
+ raise Machinery::Errors::InsufficientPrivileges.new(@system.remote_user, @system.host)
67
+ else
68
+ raise e
69
+ end
56
70
  end
57
71
 
58
72
  def remove_helper
@@ -66,4 +80,10 @@ class MachineryHelper
66
80
 
67
81
  version == File.read(File.join(Machinery::ROOT, ".git_revision"))
68
82
  end
83
+
84
+ def run_helper_subcommand(subcommand, *args)
85
+ options = args.last.is_a?(Hash) ? args.pop : {}
86
+ options[:privileged] = true
87
+ @system.run_command(remote_helper_path, subcommand, *args, options)
88
+ end
69
89
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/man_task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -16,12 +16,57 @@
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
18
  class ManTask
19
- def man
19
+ def self.compile_documentation
20
+ docs = Inspector.all_scopes.map do |scope|
21
+ scope_doc = "* #{scope}\n\n"
22
+ scope_doc += YAML.load_file(
23
+ File.join(Machinery::ROOT, "plugins/#{scope}/#{scope}.yml")
24
+ )[:description]
25
+ scope_doc + "\n"
26
+ end.join
27
+ File.write("manual/docs/machinery_main_scopes.1.md", docs)
28
+ Dir.chdir(File.join(Machinery::ROOT, "manual")) do
29
+ Cheetah.run("mkdocs", "build")
30
+ end
31
+ end
32
+
33
+ def man(options)
34
+ if options[:html]
35
+ man_html(options)
36
+ else
37
+ man_system
38
+ end
39
+ end
40
+
41
+ def man_system
20
42
  LocalSystem.validate_existence_of_package("man")
21
- system("man", man_path)
43
+ system("man", File.join(Machinery::ROOT, "man/generated/machinery.1.gz"))
22
44
  end
23
45
 
24
- def man_path
25
- File.join(Machinery::ROOT, "man/generated/machinery.1.gz")
46
+ def man_html(options)
47
+ unless File.exist?(File.join(Machinery::ROOT, "manual/site"))
48
+ Machinery::Ui.warn(
49
+ "The documentation was not generated yet. Please make sure that `mkdocs` is installed on " \
50
+ "your system and run `rake man_pages:compile_documentation` from the machinery directory."
51
+ )
52
+ return
53
+ end
54
+
55
+ LocalSystem.validate_existence_of_command("xdg-open", "xdg-utils")
56
+
57
+ url = "http://#{options[:ip]}:#{options[:port]}/site/docs/index.html"
58
+
59
+ Machinery::Ui.use_pager = false
60
+ Machinery::Ui.puts <<EOF
61
+ Trying to start a web server for serving the documentation on #{url}.
62
+
63
+ The server can be closed with Ctrl+C.
64
+ EOF
65
+
66
+ server = Html.run_server(SystemDescriptionStore.new, port: options[:port], ip: options[:ip]) do
67
+ LoggedCheetah.run("xdg-open", url)
68
+ end
69
+
70
+ server.join # Wait until the user cancelled the blocking webserver
26
71
  end
27
72
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -46,25 +46,30 @@ class ManagedFilesDatabase
46
46
  return @changed_files if @changed_files
47
47
  check_requirements
48
48
 
49
- result = managed_files_list(&block).each_line.map do |line|
49
+ result = managed_files_list(&block).lines.inject({}) do |hash, line|
50
50
  line.chomp!
51
- next unless line =~ /^[^ ]+[ ]+. \/.*$/
51
+ next(hash) unless line =~ /^[^ ]+[ ]+. \/.*$/
52
52
 
53
53
  file, changes, type = parse_changes_line(line)
54
54
 
55
- package_name, package_version = package_for_file_path(file)
55
+ unless hash[file]
56
+ package_name, package_version = package_for_file_path(file)
57
+
58
+ hash[file] = ChangedFile.new(
59
+ type,
60
+ name: file,
61
+ package_name: package_name,
62
+ package_version: package_version,
63
+ status: "changed",
64
+ changes: []
65
+ )
66
+ end
56
67
 
57
- ChangedFile.new(
58
- type,
59
- name: file,
60
- package_name: package_name,
61
- package_version: package_version,
62
- status: "changed",
63
- changes: changes
64
- )
65
- end.compact.uniq
68
+ hash[file].changes |= changes
69
+ hash
70
+ end.values
66
71
 
67
- paths = result.reject { |f| f.changes == ["deleted"] }.map(&:name)
72
+ paths = result.reject { |f| f.changes.include?("deleted") }.map(&:name)
68
73
  path_data = get_path_data(paths)
69
74
  result.each do |pkg|
70
75
  next unless path_data[pkg.name]
@@ -90,11 +95,13 @@ class ManagedFilesDatabase
90
95
  path = fields.join(" ")
91
96
 
92
97
  changes = []
93
- if @rpm_changes == "missing"
94
- changes << "deleted"
95
- elsif @rpm_changes == "........." && path.end_with?(" (replaced)")
98
+ if (@rpm_changes == "........." || @rpm_changes == "missing") && path.end_with?(" (replaced)")
96
99
  changes << "replaced"
97
100
  path.slice!(/ \(replaced\)$/)
101
+ end
102
+
103
+ if @rpm_changes == "missing"
104
+ changes << "deleted"
98
105
  else
99
106
  changes << "size" if expected_tag?("S", 0)
100
107
  changes << "mode" if expected_tag?("M", 1)
data/lib/manifest.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -95,6 +95,7 @@ class Manifest
95
95
  end
96
96
 
97
97
  def compatible_json?
98
- @hash && @hash["meta"] && @hash["meta"]["format_version"]
98
+ @hash && @hash["meta"] && @hash["meta"]["format_version"] &&
99
+ @hash["meta"]["format_version"] <= SystemDescription::CURRENT_FORMAT_VERSION
99
100
  end
100
101
  end
data/lib/migration.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/mountpoints.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/move_task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/object.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/remote_system.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -178,7 +178,7 @@ class RemoteSystem < System
178
178
 
179
179
  # Removes a file from the system
180
180
  def remove_file(file)
181
- run_command("rm", file, privileged: true)
181
+ run_command("rm", file)
182
182
  rescue Cheetah::ExecutionFailed => e
183
183
  raise Machinery::Errors::RemoveFileFailed.new(
184
184
  "Could not remove file '#{file}' on host '#{host}'.\nError: #{e}"
data/lib/remove_task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/renderer.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/rpm.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/rpm_database.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/scope.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/server.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (c) 2013-2015 SUSE LLC
2
+ # Copyright (c) 2013-2016 SUSE LLC
3
3
  #
4
4
  # This program is free software; you can redistribute it and/or
5
5
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -16,6 +16,28 @@
16
16
  # To contact SUSE about this file by physical or electronic mail,
17
17
  # you may find current contact information at www.suse.com
18
18
 
19
+ # Rack::TryStatic was taken from the rack-contrib repository (https://github.com/rack/rack-contrib)
20
+ module Rack
21
+ class TryStatic
22
+ def initialize(app, options)
23
+ @app = app
24
+ @try = ["", *options[:try]]
25
+ @static = ::Rack::Static.new(->(_) { [404, {}, []] }, options)
26
+ end
27
+
28
+ def call(env)
29
+ orig_path = env["PATH_INFO"]
30
+ found = nil
31
+ @try.each do |path|
32
+ resp = @static.call(env.merge!("PATH_INFO" => orig_path + path))
33
+ break if !(403..405).cover?(resp[0]) && found = resp
34
+ end
35
+ found || @app.call(env.merge!("PATH_INFO" => orig_path))
36
+ end
37
+ end
38
+ end
39
+
40
+
19
41
  class Server < Sinatra::Base
20
42
  module Helpers
21
43
  def render_partial(partial, locals = {})
@@ -126,7 +148,8 @@ class Server < Sinatra::Base
126
148
  id: change[0][opts[:key]],
127
149
  change: "(" + changes.join(", ") + ")",
128
150
  diffable: change[0].is_a?(UnmanagedFile) && change[0].is_a?(UnmanagedFile) &&
129
- change[0].file? && change[1].file?
151
+ change[0].file? && change[1].file? &&
152
+ @diff[scope].try(:common).try(:attributes).try(:[], "extracted")
130
153
  )
131
154
  end
132
155
  changed
@@ -200,6 +223,13 @@ class Server < Sinatra::Base
200
223
 
201
224
  helpers Helpers
202
225
 
226
+ # Serve the 'manual/site' directory under /site using Rack::TryStatic
227
+ use Rack::TryStatic,
228
+ root: File.join(Machinery::ROOT, "manual"),
229
+ urls: %w[/site],
230
+ try: ["index.html"]
231
+
232
+
203
233
  get "/descriptions/:id/files/:scope/*" do
204
234
  description = SystemDescription.load(params[:id], settings.system_description_store)
205
235
  filename = File.join("/", params["splat"].first)
data/lib/show_task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
data/lib/system.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 SUSE LLC
1
+ # Copyright (c) 2013-2016 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as