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,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Includes only options that can change the corresponding phase's results.
4
+ module Baltix::ActionFlow::Options
5
+ ENVIRONMENT = %w[CC CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS ARCHFLAGS MAKEFLAGS RUBYOPT RUBYLIB
6
+ GEM_HOME GEM_PATH BUNDLE_GEMFILE BUNDLE_WITHOUT].freeze
7
+ COMMON = %i[spec_file replace_list version_replaces gem_version_replace alias_names
8
+ ignored_names regarded_names aliased_names ignored_path_tokens
9
+ regarded_path_tokens skip_platforms target_arch use_gem_version_list].freeze
10
+ PHASES = {
11
+ 'build' => %i[rubyprog makeprog makeopt extconfopt build_rake_tasks build_environment native_postprocess],
12
+ 'doc' => %i[rubyprog rdocopt doc_environment no_doc with_parts],
13
+ 'install' => %i[install_prefix buildroot gem_home bindir libexecdir includedir mandir ridir shebang envprog
14
+ rpm_env no_lib no_app no_doc no_exec no_devel with_parts compress_manpages],
15
+ 'predeps' => %i[name rpm_package_name release predep_dir package no_lib no_app no_doc no_exec no_devel with_parts
16
+ gem_dependency_mode available_gem_list use_gem_obsolete_list]
17
+ }.freeze
18
+
19
+ def self.fingerprint space, name
20
+ settings = values(space, name)
21
+ environment = ENV.to_h.slice(*ENVIRONMENT)
22
+ identity = [Baltix::VERSION, RUBY_VERSION, RUBY_PLATFORM, RbConfig.ruby]
23
+
24
+ Digest::SHA256.hexdigest(Marshal.dump(normalized([identity, settings, environment])))
25
+ end
26
+
27
+ def self.normalized value
28
+ case value
29
+ when String then normalized_string(value)
30
+ when Array then [Array, value.map {|item| normalized(item) }]
31
+ when Hash then [Hash, value.to_h {|key, item| [normalized(key), normalized(item)] }]
32
+ else normalized_object(value)
33
+ end
34
+ end
35
+
36
+ def self.normalized_string value
37
+ value.ascii_only? ? value.b : value
38
+ end
39
+
40
+ def self.normalized_object value
41
+ case value
42
+ when Gem::Version, Pathname then [value.class, normalized(value.to_s)]
43
+ when Gem::Requirement then [value.class, normalized(value.requirements)]
44
+ when ::Extensions::OpenStruct then [value.class, normalized(value.to_h)]
45
+ else value
46
+ end
47
+ end
48
+
49
+ def self.values space, name
50
+ keys = COMMON | Array(PHASES[name]) | space.options.to_h.keys.grep(/^source/)
51
+
52
+ keys |= %i[no_doc no_exec with_parts compress_manpages] if has_ronn_build_inputs?(space, name)
53
+
54
+ name == 'config' ? space.options.to_h : space.options.to_h.slice(*keys)
55
+ end
56
+
57
+ def self.has_ronn_build_inputs? space, name
58
+ name == 'build' && space.valid_sources.any?(&:has_ronn_pages?)
59
+ end
60
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/concerns'
4
+
5
+ # Runs public CLI phase prerequisites and reuses only verified current results.
6
+ class Baltix::ActionFlow
7
+ include Baltix::Concerns::Parts
8
+
9
+ RECIPES = { 'make' => %w[config build doc predeps], 'install' => %w[build],
10
+ 'test' => %w[build install] }.freeze
11
+ CACHED = %w[config build doc install predeps].freeze
12
+ PERSISTED = (CACHED | %w[test clean distclean make]).freeze
13
+
14
+ def initialize space
15
+ @space = space
16
+ @journal = Journal.new(space)
17
+ end
18
+
19
+ def run name
20
+ name = name.to_s
21
+
22
+ return Baltix::Actor.for!('test', @space).apply_to(@space) if name == 'test' && test_disabled?
23
+
24
+ Array(RECIPES[name]).each {|dependency| run(dependency) }
25
+
26
+ name == 'make' ? true : execute(name)
27
+ end
28
+
29
+ def test_disabled?
30
+ @space.options.no_test || !part_enabled?(@space.options, :check)
31
+ end
32
+
33
+ def execute name
34
+ return cached_result(name) if CACHED.include?(name) && @journal.current?(name)
35
+
36
+ @journal.invalidate(name)
37
+
38
+ before = @journal.test_snapshot if name == 'test'
39
+
40
+ result = Baltix::Actor.for!(name, @space).apply_to(@space)
41
+
42
+ @journal.record_test_outputs(before) if before
43
+ @journal.record(name) if CACHED.include?(name)
44
+
45
+ result
46
+ ensure
47
+ persist(name) if PERSISTED.include?(name)
48
+ end
49
+
50
+ def cached_result name
51
+ name == 'config' ? @space.prepare : @journal.outputs(name)
52
+ end
53
+
54
+ def persist name
55
+ return if name == 'distclean'
56
+ return if name == 'clean' && !File.file?(File.join(@space.rootdir, '.space'))
57
+
58
+ @space.save_configuration
59
+ end
60
+ end
61
+
62
+ require 'baltix/action_flow/files'
63
+ require 'baltix/action_flow/inputs'
64
+ require 'baltix/action_flow/options'
65
+ require 'baltix/action_flow/journal'
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'pathname'
5
+
6
+ # Places native results in the existing Source DL tree, retaining namespaces.
7
+ module Baltix::Actor::Build::Collect
8
+ class MissingOutputError < StandardError; end
9
+ class InvalidOutputPathError < StandardError; end
10
+
11
+ def self.apply context
12
+ source = context[:target].source
13
+ root = File.join(source.rootdir, Baltix::Source::Base::DL_DIRS.call(source))
14
+ files = outputs(context)
15
+
16
+ raise(MissingOutputError, context[:extension]) if files.empty?
17
+
18
+ Baltix::Actor::Build::Postprocess.apply(context, files)
19
+
20
+ context[:outputs] = []
21
+
22
+ files.each {|file| context[:outputs] << copy_output(context, file, root) }
23
+
24
+ context[:outputs]
25
+ end
26
+
27
+ def self.outputs context
28
+ pattern = context[:strategy] == :rake ? '**/*' : '*'
29
+
30
+ Dir.glob(File.join(context[:directory], "#{pattern}.#{RbConfig::CONFIG['DLEXT']}")).reject do |file|
31
+ context[:excluded_roots].any? {|root| file.start_with?(File.join(root, '')) }
32
+ end
33
+ end
34
+
35
+ def self.copy_output context, file, root
36
+ destination = File.expand_path(relative_output(context, file), root)
37
+
38
+ raise(InvalidOutputPathError, destination) unless destination.start_with?(File.join(root, ''))
39
+
40
+ FileUtils.mkdir_p(File.dirname(destination))
41
+ FileUtils.cp(file, destination)
42
+
43
+ destination
44
+ end
45
+
46
+ def self.relative_output context, file
47
+ return prefixed_output(context, file) unless context[:strategy] == :rake
48
+
49
+ root = rake_output_root(context, file)
50
+
51
+ Pathname.new(file).relative_path_from(Pathname.new(root)).to_s
52
+ end
53
+
54
+ def self.prefixed_output context, file
55
+ prefix = makefile_prefix(context)
56
+
57
+ File.join(prefix, File.basename(file)).delete_prefix('/')
58
+ end
59
+
60
+ def self.rake_output_root context, file
61
+ source = context[:target].source
62
+ roots = source.spec.require_paths.map {|path| File.expand_path(path, source.rootdir) }
63
+
64
+ roots.find {|path| file.start_with?(File.join(path, '')) } || context[:directory]
65
+ end
66
+
67
+ def self.makefile_prefix context
68
+ text = File.read(File.join(context[:directory], 'Makefile'))
69
+
70
+ (text[/^target_prefix[ \t]*=[ \t]*([^\r\n]*)/, 1] || '').strip.delete_prefix('/')
71
+ end
72
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Selects one extension strategy and records only newly generated local files.
4
+ module Baltix::Actor::Build::Compile
5
+ def self.apply context
6
+ before = files(context)
7
+
8
+ if File.basename(context[:extension]).match?(/\Arakefile(?:\.rb)?\z/i)
9
+ context[:strategy] = :rake
10
+
11
+ Baltix::Actor::Build::Rake.apply(context)
12
+ else
13
+ context[:strategy] = :extconf
14
+
15
+ Baltix::Actor::Build::Extconf.apply(context)
16
+ Baltix::Actor::Build::Make.apply(context)
17
+ end
18
+ ensure
19
+ context[:generated] = files(context) - before
20
+ end
21
+
22
+ def self.files context
23
+ Dir.glob(File.join(context[:directory], '**/*'), File::FNM_DOTMATCH).select {|file| File.file?(file) }
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Runs extension configuration in a child Ruby, leaving caller RbConfig intact.
4
+ module Baltix::Actor::Build::Extconf
5
+ extend Baltix::Concerns::Command
6
+
7
+ def self.apply context
8
+ options = context[:options]
9
+ ruby = command_arguments(options.rubyprog, [RbConfig.ruby])
10
+ arguments = command_arguments(options.extconfopt)
11
+
12
+ run_command(context, [*ruby, File.basename(context[:extension]), *arguments])
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Runs the system make program, distinct from Baltix's aggregate make action.
4
+ module Baltix::Actor::Build::Make
5
+ class MissingMakefileError < StandardError; end
6
+
7
+ extend Baltix::Concerns::Command
8
+
9
+ def self.apply context
10
+ raise(MissingMakefileError, context[:directory]) unless File.file?(File.join(context[:directory], 'Makefile'))
11
+
12
+ options = context[:options]
13
+ program = command_arguments(options.makeprog, ['make'])
14
+ arguments = command_arguments(options.makeopt)
15
+
16
+ run_command(context, [*program, *arguments])
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Applies optional native processing only when the caller supplies its argv.
4
+ module Baltix::Actor::Build::Postprocess
5
+ extend Baltix::Concerns::Command
6
+
7
+ def self.apply context, files
8
+ arguments = command_arguments(context[:options].native_postprocess)
9
+
10
+ return if arguments.empty?
11
+
12
+ files.each {|file| run_command(context, [*arguments, file]) }
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Uses the existing runtime Rake runner with isolated directory and environment.
4
+ module Baltix::Actor::Build::Rake
5
+ extend Baltix::Concerns::Command
6
+
7
+ RUNNER = 'Baltix::Rake.new(ARGV.shift, runtime: true).run_tasks(ARGV)'
8
+
9
+ def self.apply context
10
+ options = context[:options]
11
+ ruby = command_arguments(options.rubyprog, [RbConfig.ruby])
12
+ tasks = command_arguments(options.build_rake_tasks, ['default'])
13
+ library = File.expand_path('../../..', __dir__)
14
+
15
+ run_command(context, [*ruby, '-I', library, '-rbaltix', '-rbaltix/rake', '-e', RUNNER,
16
+ context[:extension], *tasks])
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+ require 'zlib'
5
+
6
+ # Compiles selected Ronn inputs into reusable manual pages for the installer.
7
+ module Baltix::Actor::Build::Ronn
8
+ extend Baltix::Concerns::Command
9
+ extend Baltix::Concerns::Parts
10
+
11
+ def self.apply space, target
12
+ return [] unless part_enabled?(space.options, target.manual_part)
13
+
14
+ target.source.manual_pages.grep(/\.ronn\z/).flat_map {|file| compile(space, target.source, file) }
15
+ end
16
+
17
+ def self.compile space, source, file
18
+ path = File.join(source.rootdir, file)
19
+ destination = source.compiled_manual(file, space.options)
20
+ context = { manual: path, directory: File.dirname(path), commands: [], outputs: [],
21
+ environment: (space.options.build_environment || {}).to_h }
22
+ result = run_command(context, ['ronn', '--roff', '--pipe', path])
23
+
24
+ write_manual(destination, result[:stdout])
25
+
26
+ context[:outputs] << destination
27
+ ensure
28
+ Baltix::Actor::Build.record_result(space, context) if context
29
+ end
30
+
31
+ def self.write_manual destination, content
32
+ directory = File.dirname(destination)
33
+
34
+ raise(ArgumentError, "Symbolic link at manual build directory: #{directory}") if File.symlink?(directory)
35
+
36
+ FileUtils.mkdir_p(directory)
37
+
38
+ Tempfile.create('manual-', directory) do |file|
39
+ file.binmode
40
+ destination.end_with?('.gz') ? write_gzip(file, content) : file.write(content)
41
+ file.close
42
+ File.chmod(0o644, file.path)
43
+ File.rename(file.path, destination)
44
+ end
45
+ end
46
+
47
+ def self.write_gzip file, content
48
+ gzip = Zlib::GzipWriter.new(file)
49
+ gzip.mtime = 0
50
+
51
+ gzip.write(content)
52
+
53
+ gzip.finish
54
+ end
55
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/concerns'
4
+
5
+ # Coordinates extension actors; documentation has its own public action.
6
+ module Baltix::Actor::Build
7
+ class MissingExtensionError < StandardError; end
8
+
9
+ def self.context_kind
10
+ Baltix::Space
11
+ end
12
+
13
+ def self.apply_to space
14
+ space.prepare
15
+
16
+ space.state.build_results ||= []
17
+
18
+ space.targets.flat_map do |target|
19
+ extensions = target.source.is_a?(Baltix::Source::Gem) ? target.source.spec.extensions : []
20
+
21
+ extensions.flat_map {|extension| build_extension(space, target, extension) } +
22
+ Ronn.apply(space, target)
23
+ end
24
+ end
25
+
26
+ def self.build_extension space, target, extension
27
+ context = extension_context(space, target, extension)
28
+
29
+ validate_extension(context)
30
+
31
+ Compile.apply(context)
32
+ Collect.apply(context)
33
+ ensure
34
+ record_result(space, context) if context
35
+ target.source.refresh_file_trees
36
+ end
37
+
38
+ def self.extension_context space, target, extension
39
+ file = File.expand_path(extension, target.source.rootdir)
40
+
41
+ { target: target, extension: file, directory: File.dirname(file), options: space.options,
42
+ environment: (space.options.build_environment || {}).to_h,
43
+ excluded_roots: nested_roots(space, target),
44
+ commands: [], outputs: [] }
45
+ end
46
+
47
+ def self.record_result space, context
48
+ record = context.slice(:extension, :manual, :directory, :commands, :outputs, :generated)
49
+ records = space.state.build_results
50
+ input = context.key?(:manual) ? :manual : :extension
51
+ previous = records.find {|item| item[input] == context[input] }
52
+
53
+ merge_record(record, previous)
54
+ records.delete(previous)
55
+
56
+ records << record
57
+ end
58
+
59
+ def self.validate_extension context
60
+ file = context[:extension]
61
+ root = File.join(File.expand_path(context[:target].source.rootdir), '')
62
+ nested = context[:excluded_roots].any? {|path| file.start_with?(File.join(path, '')) }
63
+
64
+ raise(MissingExtensionError, file) unless File.file?(file) && file.start_with?(root) && !nested
65
+ end
66
+
67
+ def self.merge_record record, previous
68
+ %i[generated outputs].each do |kind|
69
+ record[kind] = Array(previous&.[](kind)) | Array(record[kind])
70
+ end
71
+ end
72
+
73
+ def self.nested_roots space, target
74
+ prefix = File.join(File.expand_path(target.source.rootdir), '')
75
+ roots = space.targets.map {|item| File.expand_path(item.source.rootdir) }
76
+
77
+ roots.select {|root| root.start_with?(prefix) }
78
+ end
79
+ end
80
+
81
+ require 'baltix/actor/build/compile'
82
+ require 'baltix/actor/build/extconf'
83
+ require 'baltix/actor/build/rake'
84
+ require 'baltix/actor/build/make'
85
+ require 'baltix/actor/build/collect'
86
+ require 'baltix/actor/build/postprocess'
87
+ require 'baltix/actor/build/ronn'
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ # Deletes only recorded files with parents still contained in the recorded root.
6
+ module Baltix::Actor::Clean::Remove
7
+ def self.apply root, files
8
+ root = File.expand_path(root)
9
+
10
+ return [] unless File.directory?(root)
11
+
12
+ files.uniq.filter_map do |file|
13
+ next unless owned_path?(root, file)
14
+ next if File.directory?(file) && !File.symlink?(file)
15
+
16
+ FileUtils.rm_f(file)
17
+
18
+ prune(root, File.dirname(file))
19
+
20
+ file
21
+ end
22
+ end
23
+
24
+ def self.owned_path? root, file
25
+ return false unless File.expand_path(file).start_with?(File.join(root, ''))
26
+
27
+ parent = File.dirname(file)
28
+
29
+ return false unless File.directory?(parent)
30
+
31
+ real_root = File.realpath(root)
32
+ real_parent = File.realpath(parent)
33
+
34
+ real_parent == real_root || real_parent.start_with?(File.join(real_root, ''))
35
+ end
36
+
37
+ def self.prune root, directory
38
+ while directory.start_with?(File.join(root, '')) && File.directory?(directory) &&
39
+ !File.symlink?(directory) && Dir.empty?(directory)
40
+ Dir.rmdir(directory)
41
+
42
+ directory = File.dirname(directory)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Removes recorded phase results while preserving sources and installed files.
4
+ module Baltix::Actor::Clean
5
+ def self.context_kind
6
+ Baltix::Space
7
+ end
8
+
9
+ def self.apply_to space
10
+ files = source_outputs(space)
11
+ removed = Remove.apply(space.rootdir, files)
12
+ predeps = space.state.predep_results
13
+
14
+ removed |= Remove.apply(predeps[:root], predeps[:outputs]) if predeps
15
+
16
+ clear_results(space)
17
+ space.refresh_target_files
18
+
19
+ removed
20
+ end
21
+
22
+ def self.source_outputs space
23
+ builds = Array(space.state.build_results).flat_map {|record| Array(record[:outputs]) | Array(record[:generated]) }
24
+ docs = Array(space.state.doc_results).flat_map {|record| Array(record[:outputs]) }
25
+
26
+ builds | docs
27
+ end
28
+
29
+ def self.clear_results space
30
+ space.state.build_results = []
31
+ space.state.doc_results = []
32
+ space.state.predep_results = nil
33
+ space.state.action_journal = {}
34
+ end
35
+ end
36
+
37
+ require 'baltix/actor/clean/remove'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Prepares and saves project configuration without rendering an RPM spec.
4
+ module Baltix::Actor::Config
5
+ def self.context_kind
6
+ Baltix::Space
7
+ end
8
+
9
+ def self.apply_to space
10
+ space.prepare.save_configuration
11
+ end
12
+ end
@@ -1,7 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/concerns'
4
+
5
+ # Copies selected source files to the packaging tree.
1
6
  module Baltix::Actor::Copy
2
- class NoDestinationDirError < StandardError ;end
3
- class NoSourceDirError < StandardError ;end
4
- class NoFileError < StandardError ;end
7
+ extend Baltix::Concerns::FileDestination
8
+
9
+ class NoDestinationDirError < StandardError; end
10
+ class NoSourceDirError < StandardError; end
11
+ class NoFileError < StandardError; end
5
12
 
6
13
  class << self
7
14
  def apply context
@@ -9,11 +16,19 @@ module Baltix::Actor::Copy
9
16
  source_dir = context['source_dir'] || raise(NoSourceDirError)
10
17
  file = context['file'] || raise(NoFileError)
11
18
 
12
- target_file = File.join(context['target_prefix'] || '', target_dir, file)
19
+ target_file = File.join(context['target_prefix'] || '', target_dir, context['as'] || file)
13
20
  source_file = File.join(source_dir, file)
14
- FileUtils.mkdir_p(File.dirname(target_file))
15
- FileUtils.cp(source_file, target_file)
16
- $stdout.puts " #{source_file} => #{target_file}"
21
+
22
+ prepare_file_destination(target_file)
23
+ copy_file(context, source_file, target_file)
24
+
25
+ $stdout.puts(" #{source_file} => #{target_file}")
26
+ end
27
+
28
+ def copy_file context, source, destination
29
+ FileUtils.cp(source, destination)
30
+
31
+ File.chmod(context['mode'], destination) if context['mode']
17
32
  end
18
33
  end
19
34
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'baltix/actor/clean'
4
+
5
+ # Also removes configuration files created by Baltix, retaining pre-existing ones.
6
+ module Baltix::Actor::Distclean
7
+ def self.context_kind
8
+ Baltix::Space
9
+ end
10
+
11
+ def self.apply_to space
12
+ outputs = Baltix::Actor::Clean.apply_to(space)
13
+
14
+ outputs |= Baltix::Actor::Clean::Remove.apply(space.rootdir, Array(space.state.config_outputs))
15
+
16
+ space.state.config_outputs = []
17
+
18
+ outputs
19
+ end
20
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'pathname'
5
+
6
+ # Collects generated RI files and replaces only this actor's previous results.
7
+ module Baltix::Actor::Doc::Collect
8
+ class MissingDocumentationError < StandardError; end
9
+
10
+ def self.apply context, output
11
+ raise(MissingDocumentationError, output) unless File.file?(File.join(output, 'cache.ri'))
12
+
13
+ remove_previous_outputs(context)
14
+
15
+ files = Dir.glob(File.join(output, '**/*')).select {|file| File.file?(file) }
16
+
17
+ files.each {|file| context[:outputs] << copy_output(context, output, file) }
18
+
19
+ context[:collected] = true
20
+
21
+ context[:outputs]
22
+ end
23
+
24
+ def self.remove_previous_outputs context
25
+ prefix = File.join(File.expand_path(context[:destination]), '')
26
+
27
+ context[:previous_outputs].each {|file| FileUtils.rm_f(file) if File.expand_path(file).start_with?(prefix) }
28
+ end
29
+
30
+ def self.copy_output context, output, file
31
+ relative = Pathname.new(file).relative_path_from(Pathname.new(output)).to_s
32
+ destination = File.join(context[:destination], relative)
33
+
34
+ FileUtils.mkdir_p(File.dirname(destination))
35
+ FileUtils.cp(file, destination)
36
+
37
+ destination
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ # Uses explicit RDoc options/files rather than its implicit directory discovery.
6
+ module Baltix::Actor::Doc::Generate
7
+ extend Baltix::Concerns::Command
8
+
9
+ RUNNER = <<~RUBY
10
+ class BaltixRDocOptions < RDoc::Options
11
+ attr_accessor :selected_files
12
+
13
+ def finish
14
+ super
15
+
16
+ self.files = selected_files.dup if selected_files
17
+
18
+ self
19
+ end
20
+ end
21
+ count = Integer(ARGV.shift)
22
+ files = ARGV.last(count)
23
+ options = BaltixRDocOptions.new
24
+ options.selected_files = files
25
+ options.parse(ARGV)
26
+ RDoc::RDoc.new.document(options)
27
+ RUBY
28
+
29
+ def self.apply context, output
30
+ ruby = command_arguments(context[:options].rubyprog, [RbConfig.ruby])
31
+ flags = generation_flags(context, output)
32
+
33
+ Bundler.with_unbundled_env do
34
+ run_command(context, [*ruby, '-rrdoc/rdoc', '-e', RUNNER, '--', context[:inputs].size.to_s,
35
+ *flags, *context[:inputs]])
36
+ end
37
+ end
38
+
39
+ def self.generation_flags context, output
40
+ source = context[:target].source
41
+ flags = source.is_a?(Baltix::Source::Gem) ? source.spec.rdoc_options.dup : []
42
+
43
+ flags.concat(command_arguments(context[:options].rdocopt))
44
+
45
+ flags.push('--root', context[:project_root], '--ri', '--op', output, '--force-update', '--quiet', '--')
46
+ end
47
+ end