baltix 0.1.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/README.md +136 -10
  4. data/Rakefile +8 -3
  5. data/baltix.gemspec +47 -29
  6. data/bin/console +4 -3
  7. data/data/alt-licenses/README.md +26 -0
  8. data/data/alt-licenses/licenses.json +2991 -0
  9. data/data/alt-rpm/README.md +21 -0
  10. data/data/alt-rpm/architectures.json +613 -0
  11. data/data/spdx/README.md +22 -0
  12. data/data/spdx/licenses.json +9287 -0
  13. data/docs/action-flow.md +42 -0
  14. data/docs/actor-integration.md +71 -0
  15. data/docs/alt-architectures.md +27 -0
  16. data/docs/cleanup-actors.md +14 -0
  17. data/docs/dependency-actions.md +22 -0
  18. data/docs/installation-actors.md +35 -0
  19. data/docs/pkglist.md +56 -0
  20. data/docs/plans/revision-003.md +328 -0
  21. data/docs/plans/revision-004.md +416 -0
  22. data/docs/plans/revision-005.md +431 -0
  23. data/docs/plans/revision-006.md +439 -0
  24. data/docs/plans/revision-007.md +441 -0
  25. data/docs/plans/revision-008.md +445 -0
  26. data/docs/plans/revision-009.md +450 -0
  27. data/docs/plans/revision-010.md +486 -0
  28. data/docs/plans/revision-011.md +500 -0
  29. data/docs/plans/revision-012.md +501 -0
  30. data/docs/plans/revision-013.md +501 -0
  31. data/docs/plans/revision-014.md +501 -0
  32. data/docs/plans/revision-015.md +502 -0
  33. data/docs/plans/revision-016.md +503 -0
  34. data/docs/plans/revision-017.md +504 -0
  35. data/docs/plans/revision-018.md +505 -0
  36. data/docs/plans/revision-019.md +510 -0
  37. data/docs/plans/revision-020.md +524 -0
  38. data/docs/plans/revision-021.md +542 -0
  39. data/docs/plans/revision-022.md +542 -0
  40. data/docs/plans/revision-023.md +545 -0
  41. data/docs/plans/revision-024.md +567 -0
  42. data/docs/plans/revision-025.md +583 -0
  43. data/docs/plans/revision-026.md +241 -0
  44. data/docs/plans/revision-027.md +305 -0
  45. data/docs/plans/revision-028.md +298 -0
  46. data/docs/plans/revision-029.md +288 -0
  47. data/docs/rpm-action-macros.md +52 -0
  48. data/docs/rpm-parts.md +53 -0
  49. data/docs/ruby-dependencies.md +217 -0
  50. data/docs/ruby-policy-2.1.md +28 -0
  51. data/docs/ruby-versioning.md +61 -0
  52. data/docs/space-format.md +58 -0
  53. data/exe/baltix +1 -0
  54. data/lib/baltix/action_flow/files.rb +49 -0
  55. data/lib/baltix/action_flow/inputs.rb +60 -0
  56. data/lib/baltix/action_flow/journal.rb +60 -0
  57. data/lib/baltix/action_flow/options.rb +60 -0
  58. data/lib/baltix/action_flow.rb +65 -0
  59. data/lib/baltix/actor/build/collect.rb +72 -0
  60. data/lib/baltix/actor/build/compile.rb +25 -0
  61. data/lib/baltix/actor/build/extconf.rb +14 -0
  62. data/lib/baltix/actor/build/make.rb +18 -0
  63. data/lib/baltix/actor/build/postprocess.rb +14 -0
  64. data/lib/baltix/actor/build/rake.rb +18 -0
  65. data/lib/baltix/actor/build/ronn.rb +55 -0
  66. data/lib/baltix/actor/build.rb +87 -0
  67. data/lib/baltix/actor/clean/remove.rb +45 -0
  68. data/lib/baltix/actor/clean.rb +37 -0
  69. data/lib/baltix/actor/config.rb +12 -0
  70. data/lib/baltix/actor/copy.rb +22 -7
  71. data/lib/baltix/actor/distclean.rb +20 -0
  72. data/lib/baltix/actor/doc/collect.rb +39 -0
  73. data/lib/baltix/actor/doc/generate.rb +47 -0
  74. data/lib/baltix/actor/doc/inputs.rb +25 -0
  75. data/lib/baltix/actor/doc.rb +70 -0
  76. data/lib/baltix/actor/gen.rb +19 -0
  77. data/lib/baltix/actor/install/data.rb +18 -0
  78. data/lib/baltix/actor/install/documentation.rb +48 -0
  79. data/lib/baltix/actor/install/executable.rb +27 -0
  80. data/lib/baltix/actor/install/extension.rb +44 -0
  81. data/lib/baltix/actor/install/headers.rb +10 -0
  82. data/lib/baltix/actor/install/library.rb +13 -0
  83. data/lib/baltix/actor/install/metadata.rb +21 -0
  84. data/lib/baltix/actor/install/paths.rb +73 -0
  85. data/lib/baltix/actor/install/plugin.rb +25 -0
  86. data/lib/baltix/actor/install/record.rb +48 -0
  87. data/lib/baltix/actor/install/shebang.rb +29 -0
  88. data/lib/baltix/actor/install/transfer.rb +64 -0
  89. data/lib/baltix/actor/install/trees.rb +34 -0
  90. data/lib/baltix/actor/install.rb +71 -0
  91. data/lib/baltix/actor/link.rb +15 -6
  92. data/lib/baltix/actor/make.rb +14 -0
  93. data/lib/baltix/actor/predeps/write.rb +51 -0
  94. data/lib/baltix/actor/predeps.rb +41 -0
  95. data/lib/baltix/actor/provides.rb +12 -0
  96. data/lib/baltix/actor/requires.rb +12 -0
  97. data/lib/baltix/actor/show.rb +26 -0
  98. data/lib/baltix/actor/spec.rb +6 -3
  99. data/lib/baltix/actor/test/record.rb +8 -0
  100. data/lib/baltix/actor/test/run.rb +30 -0
  101. data/lib/baltix/actor/test/select.rb +16 -0
  102. data/lib/baltix/actor/test.rb +41 -0
  103. data/lib/baltix/actor/touch.rb +14 -5
  104. data/lib/baltix/actor.rb +43 -26
  105. data/lib/baltix/cli/dependency_options.rb +63 -0
  106. data/lib/baltix/cli/options/action.rb +32 -0
  107. data/lib/baltix/cli/options.rb +280 -0
  108. data/lib/baltix/cli/output_options.rb +56 -0
  109. data/lib/baltix/cli/rake_tasks.rb +59 -0
  110. data/lib/baltix/cli/source_options.rb +52 -0
  111. data/lib/baltix/cli.rb +130 -116
  112. data/lib/baltix/concerns/command.rb +52 -0
  113. data/lib/baltix/concerns/configuration.rb +39 -0
  114. data/lib/baltix/concerns/dependency_output.rb +21 -0
  115. data/lib/baltix/concerns/extension_metadata.rb +44 -0
  116. data/lib/baltix/concerns/file_destination.rb +14 -0
  117. data/lib/baltix/concerns/inspection.rb +27 -0
  118. data/lib/baltix/concerns/parts.rb +16 -0
  119. data/lib/baltix/concerns/target_paths.rb +57 -0
  120. data/lib/baltix/concerns.rb +11 -0
  121. data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
  122. data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
  123. data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
  124. data/lib/baltix/deps/executables.rb +30 -0
  125. data/lib/baltix/deps/packages.rb +32 -0
  126. data/lib/baltix/deps.rb +103 -194
  127. data/lib/baltix/dsl/dependency_groups.rb +77 -0
  128. data/lib/baltix/dsl/dependency_sources.rb +100 -0
  129. data/lib/baltix/dsl/filtering.rb +26 -0
  130. data/lib/baltix/dsl/loading.rb +72 -0
  131. data/lib/baltix/dsl/merging.rb +74 -0
  132. data/lib/baltix/dsl/rendering.rb +54 -0
  133. data/lib/baltix/dsl/requirements.rb +77 -0
  134. data/lib/baltix/dsl/temporary_files.rb +36 -0
  135. data/lib/baltix/dsl.rb +66 -273
  136. data/lib/baltix/executable_dependencies/features.rb +53 -0
  137. data/lib/baltix/executable_dependencies/library.rb +21 -0
  138. data/lib/baltix/executable_dependencies/library_features.rb +34 -0
  139. data/lib/baltix/executable_dependencies/syntax.rb +102 -0
  140. data/lib/baltix/executable_dependencies.rb +102 -0
  141. data/lib/baltix/extensions/bones.rb +173 -0
  142. data/lib/baltix/extensions/echoe.rb +143 -0
  143. data/lib/baltix/extensions/hoe/metadata.rb +89 -0
  144. data/lib/baltix/extensions/hoe/options.rb +84 -0
  145. data/lib/baltix/extensions/hoe/readme.rb +29 -0
  146. data/lib/baltix/extensions/hoe.rb +146 -0
  147. data/lib/baltix/extensions/jeweler.rb +95 -0
  148. data/lib/baltix/extensions/levitate.rb +74 -0
  149. data/lib/baltix/extensions/olddoc.rb +42 -0
  150. data/lib/baltix/extensions.rb +340 -419
  151. data/lib/baltix/i18n.rb +22 -19
  152. data/lib/baltix/license/catalog/capture.rb +58 -0
  153. data/lib/baltix/license/catalog.rb +75 -0
  154. data/lib/baltix/license.rb +76 -0
  155. data/lib/baltix/loader/capture.rb +91 -0
  156. data/lib/baltix/loader/cmake.rb +6 -3
  157. data/lib/baltix/loader/evaluation.rb +49 -0
  158. data/lib/baltix/loader/extconf.rb +27 -0
  159. data/lib/baltix/loader/feature_loading.rb +54 -0
  160. data/lib/baltix/loader/git-version-gen.rb +36 -21
  161. data/lib/baltix/loader/mast/properties.rb +58 -0
  162. data/lib/baltix/loader/mast.rb +97 -109
  163. data/lib/baltix/loader/object_capture.rb +27 -0
  164. data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
  165. data/lib/baltix/loader/pom.rb +36 -16
  166. data/lib/baltix/loader/rookbook.rb +19 -14
  167. data/lib/baltix/loader/yaml.rb +9 -5
  168. data/lib/baltix/loader.rb +85 -132
  169. data/lib/baltix/log.rb +26 -27
  170. data/lib/baltix/rake/metadata_adapter.rb +30 -0
  171. data/lib/baltix/rake/task_context.rb +59 -0
  172. data/lib/baltix/rake/task_libraries.rb +73 -0
  173. data/lib/baltix/rake.rb +62 -12
  174. data/lib/baltix/source/base/dependencies.rb +81 -0
  175. data/lib/baltix/source/base/file_queries.rb +67 -0
  176. data/lib/baltix/source/base/file_tree.rb +70 -0
  177. data/lib/baltix/source/base/metadata.rb +140 -0
  178. data/lib/baltix/source/base/options.rb +71 -0
  179. data/lib/baltix/source/base/roots.rb +53 -0
  180. data/lib/baltix/source/base.rb +95 -377
  181. data/lib/baltix/source/fake.rb +89 -5
  182. data/lib/baltix/source/gem/delegation.rb +32 -0
  183. data/lib/baltix/source/gem/dependencies.rb +69 -0
  184. data/lib/baltix/source/gem/discovery.rb +72 -0
  185. data/lib/baltix/source/gem/file_trees.rb +114 -0
  186. data/lib/baltix/source/gem/forwarding.rb +12 -0
  187. data/lib/baltix/source/gem/metadata.rb +104 -0
  188. data/lib/baltix/source/gem/specification.rb +65 -0
  189. data/lib/baltix/source/gem.rb +65 -312
  190. data/lib/baltix/source/gemfile.rb +55 -5
  191. data/lib/baltix/source/rakefile.rb +12 -5
  192. data/lib/baltix/source.rb +36 -24
  193. data/lib/baltix/space/configuration.rb +54 -0
  194. data/lib/baltix/space/data/collections.rb +33 -0
  195. data/lib/baltix/space/data/gem_metadata.rb +79 -0
  196. data/lib/baltix/space/data/models.rb +20 -0
  197. data/lib/baltix/space/data/values.rb +72 -0
  198. data/lib/baltix/space/data.rb +53 -0
  199. data/lib/baltix/space/dependencies.rb +53 -0
  200. data/lib/baltix/space/filters.rb +96 -0
  201. data/lib/baltix/space/initialization.rb +124 -0
  202. data/lib/baltix/space/metadata.rb +130 -0
  203. data/lib/baltix/space/source_order.rb +43 -0
  204. data/lib/baltix/space/source_selection.rb +136 -0
  205. data/lib/baltix/space/source_status.rb +114 -0
  206. data/lib/baltix/space/spec.rb +3 -0
  207. data/lib/baltix/space.rb +87 -367
  208. data/lib/baltix/spec/rpm/aliases.rb +79 -0
  209. data/lib/baltix/spec/rpm/arch.rb +119 -0
  210. data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
  211. data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
  212. data/lib/baltix/spec/rpm/build_queries.rb +61 -0
  213. data/lib/baltix/spec/rpm/changelog.rb +115 -0
  214. data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
  215. data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
  216. data/lib/baltix/spec/rpm/deps.rb +113 -0
  217. data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
  218. data/lib/baltix/spec/rpm/env.rb +76 -0
  219. data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
  220. data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
  221. data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
  222. data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
  223. data/lib/baltix/spec/rpm/layout.rb +14 -0
  224. data/lib/baltix/spec/rpm/manpages.rb +71 -0
  225. data/lib/baltix/spec/rpm/metadata.rb +78 -0
  226. data/lib/baltix/spec/rpm/name/equality.rb +68 -0
  227. data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
  228. data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
  229. data/lib/baltix/spec/rpm/name.rb +77 -108
  230. data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
  231. data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
  232. data/lib/baltix/spec/rpm/parser/context.rb +50 -0
  233. data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
  234. data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
  235. data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
  236. data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
  237. data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
  238. data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
  239. data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
  240. data/lib/baltix/spec/rpm/parser/values.rb +85 -0
  241. data/lib/baltix/spec/rpm/parser.rb +124 -269
  242. data/lib/baltix/spec/rpm/part_files.rb +64 -0
  243. data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
  244. data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
  245. data/lib/baltix/spec/rpm/part_switches.rb +65 -0
  246. data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
  247. data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
  248. data/lib/baltix/spec/rpm/pkglist.rb +116 -0
  249. data/lib/baltix/spec/rpm/preparation.rb +73 -0
  250. data/lib/baltix/spec/rpm/rendering.rb +66 -0
  251. data/lib/baltix/spec/rpm/repository_application.rb +33 -0
  252. data/lib/baltix/spec/rpm/revision.rb +58 -0
  253. data/lib/baltix/spec/rpm/root_source.rb +48 -0
  254. data/lib/baltix/spec/rpm/scripts.rb +85 -0
  255. data/lib/baltix/spec/rpm/secondaries.rb +82 -0
  256. data/lib/baltix/spec/rpm/secondary.rb +117 -64
  257. data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
  258. data/lib/baltix/spec/rpm/section_document.rb +84 -0
  259. data/lib/baltix/spec/rpm/section_guards.rb +116 -0
  260. data/lib/baltix/spec/rpm/source_selection.rb +82 -0
  261. data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
  262. data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
  263. data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
  264. data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
  265. data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
  266. data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
  267. data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
  268. data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
  269. data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
  270. data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
  271. data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
  272. data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
  273. data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
  274. data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
  275. data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
  276. data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
  277. data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
  278. data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
  279. data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
  280. data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
  281. data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
  282. data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
  283. data/lib/baltix/spec/rpm/spec_core.rb +75 -527
  284. data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
  285. data/lib/baltix/spec/rpm.rb +253 -644
  286. data/lib/baltix/spec.rb +16 -14
  287. data/lib/baltix/target/gem.rb +61 -0
  288. data/lib/baltix/target/site.rb +40 -0
  289. data/lib/baltix/target.rb +16 -0
  290. data/lib/baltix/version.rb +3 -1
  291. data/lib/baltix.rb +77 -5
  292. data/locale/en_US.UTF-8.yaml +4 -1
  293. data/locale/ru_RU.UTF-8.yaml +7 -1
  294. data/rpm/baltix.env +4 -0
  295. data/rpm/baltix.prov +8 -0
  296. data/rpm/baltix.prov.files +6 -0
  297. data/rpm/baltix.req +8 -0
  298. data/rpm/baltix.req.files +6 -0
  299. data/rpm/macros.baltix +24 -0
  300. data/utils/rubocop/compact_block_braces.rb +39 -0
  301. data/utils/rubocop/spacing.rb +96 -0
  302. data/utils/update_alt_architectures.rb +57 -0
  303. data/utils/update_alt_licenses.rb +19 -0
  304. data/utils/update_spdx_licenses.rb +21 -0
  305. metadata +526 -17
  306. data/.github/workflows/ci.yml +0 -44
  307. data/.gitignore +0 -10
  308. data/TODO +0 -84
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Reads only selected Source files, retaining explicit shared repository documents.
4
+ module Baltix::Actor::Doc::Inputs
5
+ class OutsideProjectError < StandardError; end
6
+
7
+ def self.apply context
8
+ source = context[:target].source
9
+ files =
10
+ source.docsrctree.flat_map do |directory, entries|
11
+ entries.map {|entry| File.join(directory, entry).delete_prefix('./') }
12
+ end
13
+
14
+ files.uniq!
15
+ files.each {|file| validate_input(context, file) }
16
+
17
+ files
18
+ end
19
+
20
+ def self.validate_input context, file
21
+ absolute = File.expand_path(file, context[:directory])
22
+
23
+ raise(OutsideProjectError, absolute) unless absolute.start_with?(File.join(context[:project_root], ''))
24
+ end
25
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tmpdir'
4
+ require 'baltix/concerns'
5
+
6
+ # Coordinates exact input selection, RI generation and collection for each source.
7
+ module Baltix::Actor::Doc
8
+ extend Baltix::Concerns::Parts
9
+
10
+ def self.context_kind
11
+ Baltix::Space
12
+ end
13
+
14
+ def self.apply_to space
15
+ space.prepare
16
+
17
+ return [] unless part_enabled?(space.options, :doc)
18
+
19
+ space.state.doc_results ||= []
20
+
21
+ space.targets.flat_map {|target| document_source(space, target) }
22
+ end
23
+
24
+ def self.document_source space, target
25
+ context = source_context(space, target)
26
+
27
+ context[:inputs] = Inputs.apply(context)
28
+
29
+ return [] if context[:inputs].empty?
30
+
31
+ Dir.mktmpdir('baltix-ri-') do |directory|
32
+ output = File.join(directory, 'ri')
33
+
34
+ Generate.apply(context, output)
35
+ Collect.apply(context, output)
36
+ end
37
+ ensure
38
+ record_result(space, context) if context
39
+ target.source.refresh_file_trees
40
+ end
41
+
42
+ def self.source_context space, target
43
+ source = target.source
44
+
45
+ { target: target, source: source.source_file, project_root: File.expand_path(space.rootdir),
46
+ directory: source.rootdir, destination: File.join(source.rootdir, source.default_ridir),
47
+ options: space.options, previous_outputs: previous_outputs(space, source), inputs: [], outputs: [],
48
+ environment: (space.options.doc_environment || {}).to_h, commands: [] }
49
+ end
50
+
51
+ def self.previous_outputs space, source
52
+ record = space.state.doc_results.find {|item| item[:source] == source.source_file }
53
+
54
+ Array(record&.[](:outputs))
55
+ end
56
+
57
+ def self.record_result space, context
58
+ records = space.state.doc_results
59
+ record = context.slice(:source, :destination, :inputs, :outputs, :commands)
60
+
61
+ record[:outputs] |= context[:previous_outputs] unless context[:collected]
62
+ records.reject! {|item| item[:source] == context[:source] }
63
+
64
+ records << record
65
+ end
66
+ end
67
+
68
+ require 'baltix/actor/doc/inputs'
69
+ require 'baltix/actor/doc/generate'
70
+ require 'baltix/actor/doc/collect'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/concerns'
4
+
5
+ # Writes generated metadata with the same explicit destinations as file actors.
6
+ module Baltix::Actor::Gen
7
+ extend Baltix::Concerns::FileDestination
8
+
9
+ def self.apply context
10
+ directory = context.fetch('target_dir')
11
+ file = context.fetch('file')
12
+ destination = File.join(context['target_prefix'] || '', directory, file)
13
+
14
+ prepare_file_destination(destination)
15
+ File.write(destination, context.fetch('body'))
16
+
17
+ File.chmod(context['mode'] || 0o644, destination)
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs private application, support and data trees without public script discovery.
4
+ module Baltix::Actor::Install::Data
5
+ KINDS = %i[app conf log test sup data].freeze
6
+
7
+ def self.apply context
8
+ return unless Baltix::Actor::Install.core_enabled?(context)
9
+
10
+ target = context[:target]
11
+
12
+ KINDS.each {|kind| Baltix::Actor::Install::Trees.copy(context, kind, target.datadir) }
13
+
14
+ return if target.source.is_a?(Baltix::Source::Gem)
15
+
16
+ Baltix::Actor::Install::Trees.copy(context, :exe, target.datadir)
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs ready RI stores and sectioned man pages without rebuilding documentation.
4
+ module Baltix::Actor::Install::Documentation
5
+ def self.apply context
6
+ target = context[:target]
7
+
8
+ if Baltix::Actor::Install.part_enabled?(context[:options], :doc)
9
+ target.source.ritree.each do |directory, files|
10
+ files.uniq.each do |file|
11
+ context[:transfer].copy(File.join(target.source.rootdir, directory, file), File.join(target.ridir, file))
12
+ end
13
+ end
14
+ end
15
+
16
+ install_manpages(context)
17
+ end
18
+
19
+ def self.install_manpages context
20
+ target = context[:target]
21
+
22
+ return unless manpages_enabled?(context)
23
+
24
+ target.source.manual_pages.each {|file| install_manpage(context, file) }
25
+ end
26
+
27
+ def self.manpages_enabled? context
28
+ part = context[:target].manual_part
29
+
30
+ Baltix::Actor::Install.part_enabled?(context[:options], part)
31
+ end
32
+
33
+ def self.install_manpage context, file
34
+ target = context[:target]
35
+ source = target.source
36
+ input =
37
+ if file.end_with?('.ronn')
38
+ source.compiled_manual(file, context[:options])
39
+ else
40
+ File.join(source.rootdir, file)
41
+ end
42
+ destination = File.join(target.mandir, source.manual_destination(file))
43
+
44
+ destination = "#{destination}.gz" if input.end_with?('.gz')
45
+
46
+ context[:transfer].copy(input, destination)
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs declared gem commands, Ruby shebangs and relocatable public symlinks.
4
+ module Baltix::Actor::Install::Executable
5
+ def self.apply context
6
+ target = context[:target]
7
+
8
+ return unless target.source.is_a?(Baltix::Source::Gem)
9
+ return unless Baltix::Actor::Install.part_enabled?(context[:options], :exec)
10
+
11
+ Baltix::Actor::Install::Trees.copy(context, :exe, target.exedir, preserve_directory: false, mode: 0o755)
12
+
13
+ target.source.executables.each {|file| finish_command(context, file) }
14
+ end
15
+
16
+ def self.finish_command context, file
17
+ target = context[:target]
18
+ private_path = File.join(target.exedir, file)
19
+ path = context[:transfer].staged(private_path)
20
+
21
+ raise(Errno::ENOENT, path) unless File.file?(path)
22
+
23
+ Baltix::Actor::Install::Shebang.apply(context, path)
24
+
25
+ context[:transfer].link(private_path, File.join(target.public_bindir, file))
26
+ end
27
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs built native results and marks completion only after successful transfers.
4
+ module Baltix::Actor::Install::Extension
5
+ def self.apply context
6
+ target = context[:target]
7
+
8
+ return unless target.source.is_a?(Baltix::Source::Gem) && target.source.spec.extensions.any?
9
+ return unless Baltix::Actor::Install.core_enabled?(context)
10
+
11
+ marker = File.join(target.dldir, 'gem.build_complete')
12
+
13
+ FileUtils.rm_f(context[:transfer].staged(marker))
14
+ install_outputs(context)
15
+
16
+ context[:transfer].touch(marker)
17
+ end
18
+
19
+ def self.install_outputs context
20
+ target = context[:target]
21
+ count = 0
22
+
23
+ target.source.dltree.each do |directory, files|
24
+ files.uniq.grep(/\.#{Regexp.escape(RbConfig::CONFIG['DLEXT'])}\z/).each do |file|
25
+ install_output(context, directory, file)
26
+
27
+ count += 1
28
+ end
29
+ end
30
+
31
+ raise(Baltix::Actor::Install::MissingNativeOutputError, target.source.source_file) if count.zero?
32
+ end
33
+
34
+ def self.install_output context, directory, file
35
+ target = context[:target]
36
+ destination = File.join(target.dldir, file)
37
+
38
+ mode = context[:options].rpm_env ? Baltix::Spec::Rpm::Layout::EXTENSION_MODE : 0o755
39
+
40
+ context[:transfer].copy(File.join(target.source.rootdir, directory, file), destination, mode: mode)
41
+
42
+ context[:transfer].link(destination, File.join(target.require_fulllibdir, file))
43
+ end
44
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs selected public headers under the configured include directory.
4
+ module Baltix::Actor::Install::Headers
5
+ def self.apply context
6
+ return unless Baltix::Actor::Install.part_enabled?(context[:options], :devel)
7
+
8
+ Baltix::Actor::Install::Trees.copy(context, :inc, context[:target].incdir, preserve_directory: false)
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Installs library files under the existing gem or site library target.
4
+ module Baltix::Actor::Install::Library
5
+ def self.apply context
6
+ return unless Baltix::Actor::Install.core_enabled?(context)
7
+
8
+ target = context[:target]
9
+ gem = target.source.is_a?(Baltix::Source::Gem)
10
+
11
+ Baltix::Actor::Install::Trees.copy(context, :lib, target.libdir, preserve_directory: gem)
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generates installed metadata without source checkout paths or an incompatible source lock.
4
+ module Baltix::Actor::Install::Metadata
5
+ def self.apply context
6
+ return unless Baltix::Actor::Install.core_enabled?(context)
7
+
8
+ target = context[:target]
9
+
10
+ install_gemspec(context, target) if target.source.is_a?(Baltix::Source::Gem)
11
+
12
+ context[:transfer].generate(File.join(target.datadir, 'Gemfile'), target.source.dsl.to_installed_gemfile)
13
+ end
14
+
15
+ def self.install_gemspec context, target
16
+ source = target.source
17
+ path = File.join(target.specdir, "#{source.fullname}.gemspec")
18
+
19
+ context[:transfer].generate(path, source.dsl.to_ruby)
20
+ end
21
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Validates and tracks paths used by actual installation operations.
4
+ module Baltix::Actor::Install::Paths
5
+ class OutsideRootError < StandardError; end
6
+ class ConflictingDestinationError < StandardError; end
7
+
8
+ def self.staged context, destination
9
+ root = context[:target].chroot
10
+ result = File.expand_path(context[:target].staged(destination))
11
+
12
+ raise(OutsideRootError, result) unless result.start_with?(File.join(root, ''))
13
+
14
+ validate_parents(root, File.dirname(result))
15
+
16
+ result
17
+ end
18
+
19
+ def self.source context, path
20
+ result = File.realpath(path)
21
+ root = File.realpath(context[:project_root])
22
+
23
+ raise(OutsideRootError, result) unless result.start_with?(File.join(root, ''))
24
+
25
+ result
26
+ end
27
+
28
+ def self.validate_parents root, path
29
+ while path.start_with?(File.join(root, ''))
30
+ raise(OutsideRootError, path) if File.symlink?(path)
31
+
32
+ path = File.dirname(path)
33
+ end
34
+ end
35
+
36
+ def self.claim context, destination
37
+ owner = context[:target].source.rootdir
38
+ previous = context[:owners][destination]
39
+
40
+ raise(ConflictingDestinationError, destination) if previous && previous != owner
41
+
42
+ context[:owners][destination] = owner
43
+ end
44
+
45
+ def self.missing_directories path, root
46
+ result = []
47
+
48
+ while path.start_with?(File.join(root, '')) && !File.directory?(path)
49
+ result << path
50
+
51
+ path = File.dirname(path)
52
+ end
53
+
54
+ result
55
+ end
56
+
57
+ def self.remove_owned root, paths
58
+ paths.each do |file|
59
+ next unless File.expand_path(file).start_with?(File.join(root, ''))
60
+
61
+ FileUtils.rm_f(file) unless File.directory?(file) && !File.symlink?(file)
62
+ end
63
+ end
64
+
65
+ def self.remove_empty_directories root, paths
66
+ paths.sort_by(&:size).reverse_each do |directory|
67
+ next unless File.expand_path(directory).start_with?(File.join(root, ''))
68
+ next unless File.directory?(directory) && !File.symlink?(directory) && Dir.empty?(directory)
69
+
70
+ Dir.rmdir(directory)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ # Generates RubyGems plugin loaders using relocatable installed library paths.
6
+ module Baltix::Actor::Install::Plugin
7
+ def self.apply context
8
+ target = context[:target]
9
+
10
+ return unless target.source.is_a?(Baltix::Source::Gem) && Baltix::Actor::Install.core_enabled?(context)
11
+
12
+ file = target.source.rubygems_plugin_file
13
+
14
+ return unless file
15
+
16
+ install_plugin(context, target, File.join(target.libdir, file))
17
+ end
18
+
19
+ def self.install_plugin context, target, plugin
20
+ relative = Pathname.new(plugin).relative_path_from(Pathname.new(target.plugindir)).to_s
21
+ path = File.join(target.plugindir, "#{target.source.name}_plugin.rb")
22
+
23
+ context[:transfer].generate(path, "require_relative #{relative.dump}\n")
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Retains actual owned files and removes obsolete results only after success.
4
+ module Baltix::Actor::Install::Record
5
+ def self.apply space, context
6
+ records = space.state.install_results
7
+ previous = previous_record(records, context)
8
+
9
+ reconcile(context, previous)
10
+ records.delete(previous)
11
+
12
+ records << definition(context)
13
+ end
14
+
15
+ def self.previous_record records, context
16
+ source = context[:target].source.source_file
17
+ root = context[:target].chroot
18
+
19
+ records.find {|item| item[:source] == source && item[:root] == root }
20
+ end
21
+
22
+ def self.definition context
23
+ { source: context[:target].source.source_file, root: context[:target].chroot,
24
+ outputs: context[:outputs].uniq, directories: context[:directories].uniq,
25
+ success: context[:completed] }
26
+ end
27
+
28
+ def self.reconcile context, previous
29
+ return unless previous
30
+
31
+ if context[:completed]
32
+ remove_obsolete(context, previous)
33
+ else
34
+ context[:outputs] |= previous[:outputs]
35
+ end
36
+
37
+ context[:directories] |= Array(previous[:directories]).select {|directory| File.directory?(directory) }
38
+ end
39
+
40
+ def self.remove_obsolete context, previous
41
+ root = context[:target].chroot
42
+ paths = Baltix::Actor::Install::Paths
43
+
44
+ paths.remove_owned(root, previous[:outputs] - context[:outputs])
45
+
46
+ paths.remove_empty_directories(root, Array(previous[:directories]) - context[:directories])
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Updates Ruby interpreter lines while retaining flags and other interpreter types.
4
+ module Baltix::Actor::Install::Shebang
5
+ RUBY_LINE = /\A#![^\r\n]*\bruby[\d.]*([ \t][^\r\n]*)?\r?\n/
6
+
7
+ def self.apply context, path
8
+ mode = context[:options].shebang
9
+
10
+ return if [false, ''].include?(mode)
11
+
12
+ replacement = interpreter(context[:options], mode)
13
+ body = File.binread(path)
14
+ updated = body.sub(RUBY_LINE) { "#!#{replacement}#{Regexp.last_match(1)}\n" }
15
+
16
+ File.binwrite(path, updated) if updated != body
17
+ end
18
+
19
+ def self.interpreter options, mode
20
+ case mode
21
+ when nil, 'auto', 'ruby'
22
+ RbConfig.ruby
23
+ when 'env'
24
+ "#{options.envprog || '/usr/bin/env'} -S ruby"
25
+ else
26
+ mode
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ # Applies shared file actors and records their concrete results for later cleanup.
6
+ class Baltix::Actor::Install::Transfer
7
+ def initialize context
8
+ @context = context
9
+ @target = context[:target]
10
+ end
11
+
12
+ def copy source, destination, mode: 0o644
13
+ source = Baltix::Actor::Install::Paths.source(@context, source)
14
+ arguments = primitive(destination).merge('source_dir' => File.dirname(source),
15
+ 'file' => File.basename(source),
16
+ 'as' => File.basename(destination), 'mode' => mode)
17
+
18
+ perform(destination) { Baltix::Actor::Copy.apply(arguments) }
19
+ end
20
+
21
+ def link source, destination
22
+ parent = Pathname.new(File.dirname(File.expand_path(destination, '/')))
23
+ directory = Pathname.new(File.dirname(File.expand_path(source, '/'))).relative_path_from(parent).to_s
24
+ arguments = primitive(destination).merge('source_dir' => directory)
25
+
26
+ perform(destination) { Baltix::Actor::Link.apply(arguments) }
27
+ end
28
+
29
+ def touch destination
30
+ perform(destination) { Baltix::Actor::Touch.apply(primitive(destination)) }
31
+ end
32
+
33
+ def generate destination, body
34
+ arguments = primitive(destination).merge('body' => body)
35
+
36
+ perform(destination) { Baltix::Actor::Gen.apply(arguments) }
37
+ end
38
+
39
+ def staged destination
40
+ Baltix::Actor::Install::Paths.staged(@context, destination)
41
+ end
42
+
43
+ private
44
+
45
+ def primitive destination
46
+ { 'target_prefix' => @target.chroot, 'target_dir' => File.dirname(destination),
47
+ 'file' => File.basename(destination) }
48
+ end
49
+
50
+ def perform destination
51
+ path = staged(destination)
52
+ paths = Baltix::Actor::Install::Paths
53
+ directories = paths.missing_directories(File.dirname(path), @target.chroot)
54
+
55
+ paths.claim(@context, path)
56
+ yield
57
+
58
+ @context[:outputs] |= [path]
59
+
60
+ path
61
+ ensure
62
+ @context[:directories] |= directories.select {|directory| File.directory?(directory) } if directories
63
+ end
64
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copies selected Source trees using Target destinations and source boundaries.
4
+ module Baltix::Actor::Install::Trees
5
+ METADATA_INPUTS = %w[Gemfile Gemfile.lock gemfile gemfile.lock].freeze
6
+
7
+ def self.selected source, kind
8
+ tree = source.public_send("#{kind}tree")
9
+
10
+ source.is_a?(Baltix::Source::Gem) ? source.allfiles_for(tree) : tree
11
+ end
12
+
13
+ def self.copy context, kind, destination, preserve_directory: true, mode: 0o644
14
+ source = context[:target].source
15
+
16
+ selected(source, kind).each do |directory, files|
17
+ files.uniq.each do |file|
18
+ next if has_source_input?(context, directory, file)
19
+
20
+ relative = preserve_directory ? File.join(directory, file) : file
21
+
22
+ context[:transfer].copy(File.join(source.rootdir, directory, file),
23
+ File.join(destination, relative), mode: mode)
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.has_source_input? context, directory, file
29
+ path = File.join(directory, file).delete_prefix('./')
30
+
31
+ METADATA_INPUTS.include?(path) ||
32
+ context[:options].rpm_env && Baltix::Spec::Rpm::Layout.has_vcs_metadata?(path)
33
+ end
34
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/concerns'
4
+ require 'baltix/spec'
5
+
6
+ # Coordinates source/target installation roles and retains actual file ownership.
7
+ module Baltix::Actor::Install
8
+ extend Baltix::Concerns::Parts
9
+
10
+ class MissingStagingRootError < StandardError; end
11
+ class MissingNativeOutputError < StandardError; end
12
+
13
+ ROLES = %i[Library Data Extension Executable Metadata Documentation Headers Plugin].freeze
14
+
15
+ def self.context_kind
16
+ Baltix::Space
17
+ end
18
+
19
+ def self.apply_to space
20
+ space.prepare
21
+ validate_root(space.options)
22
+
23
+ space.state.install_results ||= []
24
+ owners = {}
25
+
26
+ space.targets.flat_map {|target| install_source(space, target, owners) }.uniq
27
+ end
28
+
29
+ def self.validate_root options
30
+ prefix = options.install_prefix || options.buildroot
31
+
32
+ raise(MissingStagingRootError, 'install requires an explicit staging root') unless prefix
33
+
34
+ raise(MissingStagingRootError, 'the staging root must differ from /') if File.expand_path(prefix) == '/'
35
+ end
36
+
37
+ def self.install_source space, target, owners
38
+ context = { target: target, options: space.options, project_root: File.expand_path(space.rootdir),
39
+ outputs: [], directories: [], owners: owners, completed: false }
40
+
41
+ context[:transfer] = Transfer.new(context)
42
+
43
+ ROLES.each {|name| const_get(name).apply(context) }
44
+
45
+ context[:completed] = true
46
+
47
+ context[:outputs]
48
+ ensure
49
+ Record.apply(space, context) if context
50
+ end
51
+
52
+ def self.core_enabled? context
53
+ part = context[:target].source.is_a?(Baltix::Source::Gem) ? :lib : :app
54
+
55
+ !context[:options][:"no_#{part}"]
56
+ end
57
+ end
58
+
59
+ require 'baltix/actor/install/paths'
60
+ require 'baltix/actor/install/transfer'
61
+ require 'baltix/actor/install/trees'
62
+ require 'baltix/actor/install/record'
63
+ require 'baltix/actor/install/library'
64
+ require 'baltix/actor/install/data'
65
+ require 'baltix/actor/install/extension'
66
+ require 'baltix/actor/install/executable'
67
+ require 'baltix/actor/install/shebang'
68
+ require 'baltix/actor/install/metadata'
69
+ require 'baltix/actor/install/documentation'
70
+ require 'baltix/actor/install/headers'
71
+ require 'baltix/actor/install/plugin'