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,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Keeps distinct native roots and selects their actual gem or application sources.
4
+ class Baltix::Spec::Rpm
5
+ def is_same_source? source_in
6
+ source_in && source == source_in
7
+ end
8
+
9
+ def kind
10
+ @kind ||= source.is_a?(Baltix::Source::Gem) && :lib || :app
11
+ end
12
+
13
+ def state_kind
14
+ @state_kind ||= pre_name&.kind || state['file_list'].blank? && default_state_kind
15
+ end
16
+
17
+ def default_state_kind
18
+ 'app'
19
+ end
20
+
21
+ def assign_space space
22
+ @space = space
23
+
24
+ # TODO: clean variables
25
+
26
+ space
27
+ end
28
+
29
+ def doc
30
+ @doc ||= self
31
+ end
32
+
33
+ def names
34
+ @names ||= [name.to_s] | secondaries.map {|sec| sec.name.to_s }.tap(&:uniq!)
35
+ end
36
+
37
+ # A distinct input package owning a real gem subpackage is not that gem.
38
+ # Keep the native/application root even when its literal name aliases the gem.
39
+ def distinct_root_package?
40
+ return @distinct_root_package if defined?(@distinct_root_package)
41
+
42
+ @distinct_root_package = false
43
+ candidate = space&.main_source
44
+
45
+ return false unless candidate.is_a?(Baltix::Source::Gem) && state.name
46
+
47
+ gem_name = Name.for_gem(candidate.name).to_s
48
+
49
+ @distinct_root_package = distinct_gem_subpackage?(candidate.name, gem_name)
50
+ end
51
+
52
+ def distinct_gem_subpackage? source_name, gem_name
53
+ return false if state.name.to_s == gem_name || root_provides_gem?(source_name)
54
+
55
+ Array(state.secondaries).any? {|package| package.name.to_s == gem_name }
56
+ end
57
+
58
+ def root_provides_gem? name
59
+ Array(state.provides).any? {|dependency| dependency.is_a?(Gem::Dependency) && dependency.name == name }
60
+ end
61
+
62
+ def render_main_files?
63
+ return false if implicit_collection_root? && !original_main_files?
64
+ return true unless distinct_root_package?
65
+
66
+ original_main_files?
67
+ end
68
+
69
+ def implicit_collection_root?
70
+ source.is_a?(Baltix::Source::Fake) && sources.any? do |item|
71
+ !item.is_a?(Baltix::Source::Fake) && File.file?(item.source_file.to_s)
72
+ end
73
+ end
74
+
75
+ def original_main_files?
76
+ keys = (state.preserved_file_lists || {}).to_h.keys.map(&:to_s)
77
+
78
+ keys.include?(state.name&.original_fullname)
79
+ end
80
+ end
81
+
82
+ require 'baltix/spec/rpm/root_source'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Keeps explicit native RPM architectures and extension-aware Ruby package headers.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ # Decides whether to write an explicit BuildArch for this package.
6
+ # @return [Boolean] whether the selected architecture belongs in the header
7
+ # Source-less packages of a distinct native project inherit RPM's build
8
+ # architecture unless an input header or caller explicitly selects one.
9
+ # Ruby packages retain their extension-aware architecture handling.
10
+ def render_build_arch?
11
+ return (of_options(:build_arch) || of_state(:build_arch)).present? if native_application_source?
12
+ return false if native_gem_package?(self) || native_document_packages?
13
+
14
+ self == doc ? !has_compilables?(:with_children) : !(is_lib? && has_compilables?)
15
+ end
16
+
17
+ def native_application_source?
18
+ source.is_a?(Baltix::Source::Fake) && doc.distinct_root_package?
19
+ end
20
+
21
+ def native_document_packages?
22
+ self == doc && valid_secondaries.any? {|package| native_gem_package?(package) }
23
+ end
24
+
25
+ def native_gem_package? package
26
+ package.is_lib? && package.source.is_a?(Baltix::Source::Gem) && package.source.platform.is_a?(Gem::Platform)
27
+ end
28
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Reads and combines the published OpenStruct state/options metadata pipelines.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ def of_source name
6
+ source.send(name) || nil
7
+ rescue NameError
8
+ nil
9
+ end
10
+
11
+ def of_state name
12
+ state[name.to_s] || state[name.to_sym]
13
+ end
14
+
15
+ def of_options name
16
+ options[name]
17
+ end
18
+
19
+ def of_space name
20
+ space.respond_to?(name) ? space.send(name) : nil
21
+ end
22
+
23
+ def of_default name
24
+ default = self.class::STATE[name][:default]
25
+
26
+ default.is_a?(Proc) ? default[self] : default
27
+ end
28
+
29
+ def [] name
30
+ instance_variable_get(:"@#{name}")
31
+ end
32
+
33
+ def []= name, value
34
+ instance_variable_set(:"@#{name}", value)
35
+ end
36
+
37
+ def read_attribute name, seq = nil
38
+ (seq || self.class::STATE[name][:seq]).reduce(nil) do |value, function|
39
+ attribute_pipeline_step(name, value, function)
40
+ end
41
+ end
42
+
43
+ def attribute_pipeline_step name, previous, function
44
+ /(?<operation>[-|>])*(?<method_name>.*)/ =~ function
45
+
46
+ value = attribute_pipeline_value(method_name, name, previous)
47
+
48
+ case operation
49
+ when '|'
50
+ attribute_pipeline_array(previous) | attribute_pipeline_array(value)
51
+ when '-'
52
+ previous
53
+ when '>'
54
+ value
55
+ else
56
+ previous.present? && previous || value
57
+ end
58
+ end
59
+
60
+ def attribute_pipeline_value method_name, name, previous
61
+ if method_name[0] == '_'
62
+ method(method_name).arity.zero? ? send(method_name) : send(method_name, previous)
63
+ else
64
+ send(method_name, name)
65
+ end
66
+ end
67
+
68
+ def attribute_pipeline_array value
69
+ [value].compact.tap {|array| array.flatten!(1) }
70
+ end
71
+
72
+ def options= options
73
+ @options = options.to_os
74
+ end
75
+
76
+ def options
77
+ @options ||= {}.to_os
78
+ end
79
+
80
+ def state
81
+ @state ||= {}.to_os
82
+ end
83
+
84
+ def state= value
85
+ @name = name.merge(value.name) if value.name
86
+
87
+ @state = value.to_os
88
+ end
89
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Builds available gem ranges and combines configured dependency maps without changing their merge policy.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _available_gem_list value_in
8
+ value_in || options.available_gem_list
9
+ end
10
+
11
+ def _available_gem_ranges _value_in
12
+ available_gem_list.reduce({}.to_os) do |result, name, versions|
13
+ result[name] = available_gem_range(name, versions)
14
+
15
+ result
16
+ end
17
+ end
18
+
19
+ def available_gem_range name, versions
20
+ low = [versions].flatten.map! {|version| Gem::Version.new(version) }.min
21
+ bottom = [versions].flatten.map! {|version| Gem::Version.new(version.to_s.split('.')[0..1].join('.')).bump }.max
22
+
23
+ Gem::Dependency.new(name.to_s, Gem::Requirement.new([">= #{low}", "< #{bottom}"]))
24
+ end
25
+
26
+ def dep_list_merge first_in, second_in
27
+ first = first_in || {}.to_os
28
+ second = second_in || {}.to_os
29
+
30
+ first.reduce(second.dup) do |r, name, req|
31
+ if r[name]
32
+ r[name] = r[name].merge(req)
33
+
34
+ r
35
+ else
36
+ r.merge({ name => req }.to_os)
37
+ end
38
+ end
39
+ end
40
+
41
+ def dep_list_intersect *lists_in
42
+ lists = lists_in.map(&:to_os)
43
+
44
+ lists.reduce do |r_list, list|
45
+ list.reduce(r_list) do |r, name, req|
46
+ if r[name]
47
+ r[name] = Gem::Dependency.new('rake', req.requirement | r[name].requirement)
48
+
49
+ r
50
+ else
51
+ r.merge({ name => req }.to_os)
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def variables
58
+ @variables ||= context.__macros || {}.to_os
59
+ end
60
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Renders current gem/interpreter requirements, exclusions and exact internal capabilities in order.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Renders gem capabilities without resolving them as requirements.
8
+ # @param value_in [Array<Gem::Dependency, String>] provided capabilities
9
+ # @return [Array<String>] RPM Provides declarations with their selected versions
10
+ # Capability rendering bypasses the internal-requirement map to avoid recursive
11
+ # collection of Provides while dependencies are being rendered.
12
+ def _render_provided_deps value_in
13
+ render_deps(value_in, :provide)
14
+ end
15
+
16
+ # Renders requirements, conflicts or provided gem capabilities as RPM strings.
17
+ # @param deps_in [Array<Gem::Dependency, Hash, String>] constraints to render
18
+ # @param mode [Symbol] :debound for minimums, :negate for conflicts, :provide for capabilities
19
+ # @return [Array<String>] rendered dependency tags without duplicates
20
+ # Internal requirements use the exact version actually provided by this spec;
21
+ # internal conflicts are omitted. Capability rendering preserves its own bounds.
22
+ # External equality requirements become inclusive minimums. Strict external
23
+ # minimums and conflict boundaries retain >; provided capabilities and non-gem
24
+ # constraints retain their normal bound conversion. Requirements and conflicts
25
+ # on ignored gem names are omitted unless regard overrides that exclusion.
26
+ def render_deps deps_in, mode = :debound
27
+ function = mode == :negate ? :upper_negate_to_rpm : :lower_to_rpm
28
+ relax_gem_upper = mode == :negate && doc.send(:gem_dependency_mode) == :'no-upper'
29
+
30
+ deps_in.reduce([]) do |dependencies, dependency|
31
+ next dependencies if ignored_rendered_gem?(dependency, mode)
32
+ next dependencies if omitted_upper_conflict?(dependency, relax_gem_upper)
33
+
34
+ dependencies | rendered_dependency(dependency, mode, function, relax_gem_upper)
35
+ end
36
+ end
37
+
38
+ def ignored_rendered_gem? dependency, mode
39
+ mode != :provide && dependency.is_a?(Gem::Dependency) && ignored_name?(dependency.name)
40
+ end
41
+
42
+ def omitted_upper_conflict? dependency, relax
43
+ relax && dependency.is_a?(String) &&
44
+ dependency.match?(/\A(?:gem|rubygem|ruby-gem)\([^)]+\)\s+(?:>=|>)\s+\S+\z/)
45
+ end
46
+
47
+ def rendered_dependency dependency, mode, function, relax
48
+ if dependency.is_a?(Gem::Dependency)
49
+ rendered_gem_dependency(dependency, mode, function, relax)
50
+ elsif dependency.is_a?(Hash)
51
+ rendered_interpreter_dependencies(dependency, function)
52
+ else
53
+ [dependency]
54
+ end
55
+ end
56
+
57
+ def rendered_gem_dependency dependency, mode, function, relax
58
+ supplied = provided_gem_versions[dependency.name] unless mode == :provide
59
+
60
+ boundary = gem_dependency_boundary(dependency, mode, function, relax, supplied)
61
+ boundaries = boundary.blank? ? [] : [boundary]
62
+
63
+ boundaries |= Baltix::Deps.exclusions_to_rpm(dependency.requirement) if mode == :negate && !supplied
64
+
65
+ boundaries.map {|operator, version| "#{prefix}(#{dependency.name}) #{operator} #{version}" }
66
+ end
67
+
68
+ def gem_dependency_boundary dependency, mode, function, relax, supplied
69
+ return mode == :negate ? [] : ['=', supplied] if supplied
70
+
71
+ boundary = relax ? [] : Baltix::Deps.send(function, dependency.requirement)
72
+
73
+ mode == :debound && boundary.first == '=' ? ['>=', boundary.last] : boundary
74
+ end
75
+
76
+ def rendered_interpreter_dependencies declarations, function
77
+ declarations.filter_map do |name, requirement|
78
+ boundary = Baltix::Deps.send(function, requirement)
79
+
80
+ boundary.blank? ? nil : "#{name} #{boundary.first} #{boundary.last}"
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Composes localized descriptions while retaining stored auxiliary text and translated labels.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _proceed_description value_in
8
+ value_in.map {|_locale, desc| desc.is_a?(Array) ? desc.join("\n") : desc }
9
+ end
10
+
11
+ def _descriptions value_in
12
+ source_name = of_source(:name)
13
+ summary = source_description_summary
14
+ summaries_in = description_summaries(summary)
15
+ descriptions_in = source_descriptions
16
+ translated =
17
+ Baltix::I18n.locales.map do |locale|
18
+ sum = Baltix::I18n.t(:"spec.rpm.#{kind}.description", locale: locale, binding: binding)
19
+
20
+ [locale, sum]
21
+ end
22
+
23
+ localized_descriptions(translated, value_in, summaries_in, descriptions_in)
24
+ end
25
+
26
+ def source_description_summary
27
+ of_source(:summary)&.match("(.*?)[.,-_\s]+$")&.[](1)
28
+ end
29
+
30
+ def description_summaries summary
31
+ @host && summaries || { Baltix::I18n.default_locale => summary }
32
+ end
33
+
34
+ def source_descriptions
35
+ @host && host.descriptions || of_source(:descriptions) || of_source(:summaries) || {}.to_os
36
+ end
37
+
38
+ def localized_descriptions translated, value_in, summaries_in, descriptions_in
39
+ translated.filter_map do |locale, text|
40
+ description = description_for_locale(locale, text, value_in, summaries_in, descriptions_in)
41
+
42
+ [locale, description] unless description.blank?
43
+ end.to_os
44
+ end
45
+
46
+ def description_for_locale locale, _text, value_in, summaries_in, descriptions_in
47
+ if locale.to_s == Baltix::I18n.default_locale
48
+ if gem_metadata_source? && !PRIMARY_PACKAGE_KINDS.include?(kind)
49
+ auxiliary_description(summaries_in[locale], descriptions_in[locale])
50
+ else
51
+ value_in[locale] || descriptions_in[locale]
52
+ end
53
+ else
54
+ translated_description(locale, value_in, summaries_in)
55
+ end
56
+ end
57
+
58
+ def auxiliary_description summary, rest_in
59
+ first = summary && "#{summary}."
60
+
61
+ /(?<re>.*)\.$/ =~ rest_in
62
+
63
+ rest = first&.include?(re || rest_in || '') ? nil : rest_in
64
+
65
+ [first, rest].compact.join("\n\n")
66
+ end
67
+
68
+ def translated_description locale, value_in, summaries_in
69
+ summary_in = summaries_in[locale]
70
+
71
+ if gem_metadata_source?
72
+ /(?<s>.+)\.?$/ =~ summary_in && s && "#{s}." || value_in[locale]
73
+ else
74
+ value_in[locale]
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Resolves package relationships and installed documentation/application data directories.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Resolves a documentation package's directory from its host gem version.
8
+ # Takes no parameters.
9
+ # @return [String] RPM macro or explicit path to the installed gem documentation
10
+ # If this is the main gem and the RPM and host versions agree, use the main
11
+ # directory macro. Otherwise use the host version explicitly, even when an
12
+ # older spec assigned a different RPM version to the documentation package.
13
+ def documentation_directory
14
+ return application_documentation_directory if source.is_a?(Baltix::Source::Gemfile)
15
+
16
+ if doc.is_same_source?(source) && version == host.version
17
+ '%ruby_gemdocdir'
18
+ else
19
+ "%ruby_gemsdocdir/#{source&.name || name}-#{host.version}"
20
+ end
21
+ end
22
+
23
+ def application_documentation_directory
24
+ File.join(doc.space.options.ridir || '%_datadir/ri', source.name)
25
+ end
26
+
27
+ def is_dochost?
28
+ respond_to?(:space)
29
+ end
30
+
31
+ def is_host?
32
+ !respond_to?(:host)
33
+ end
34
+
35
+ def is_aux?
36
+ %i[devel doc exec].include?(kind)
37
+ end
38
+
39
+ # Owns the private data tree installed for a Gemfile application by setup-rb.
40
+ # @return [String, nil] RPM path for the application's site target
41
+ # Gem and auxiliary packages retain their own file lists. Use the source
42
+ # name because the RPM package can have a different, historical name.
43
+ def site_data_directory
44
+ return unless source.is_a?(Baltix::Source::Gemfile) && !is_aux?
45
+
46
+ "%_libexecdir/#{source.name}"
47
+ end
48
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Selects executable package names with the existing shared-character algorithm.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ # +executable_name+ returns a name of the executable package, based on
6
+ # the all the sources executables.
7
+ #
8
+ # spec.executable_name # => foo
9
+ #
10
+ def executable_name
11
+ @executable_name =
12
+ if executables.size > 1
13
+ common_executable_name
14
+ else
15
+ executables.first&.gsub(/[_.]/, '-') || ''
16
+ end
17
+ end
18
+
19
+ def common_executable_name
20
+ suffix =
21
+ executable_codepoints.transpose.reverse!.reduce([]) do |result, chars|
22
+ common_executable_characters?(chars) ? result.push(chars.first) : []
23
+ end
24
+
25
+ suffix.reverse.pack('U*').sub(/[-_.]+$/, '')
26
+ end
27
+
28
+ def executable_codepoints
29
+ maximum = executables.map(&:size).max
30
+
31
+ executables.map {|command| (command + ' ' * (maximum - command.size)).unpack('U*') }
32
+ end
33
+
34
+ def common_executable_characters? characters
35
+ (characters | EXECUTABLE_NAME_SEPARATORS).size == characters.size || ([characters.first] | characters).size == 1
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Applies host names and Ruby prefixes once to each supporting package relationship.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Applies the selected host relationship and package-type prefix to an RPM name.
8
+ # @param value_in [Name] selected package name before host normalization
9
+ # @return [Name] name retaining its host and a single generated packaging prefix
10
+ # Gem hosts supply the standard prefix for non-executable packages. Gemfile and
11
+ # Rakefile hosts keep the original full form unless its prefix would be added
12
+ # again by name rendering; in that case the base name is used. Other names remain.
13
+ def _local_rename value_in
14
+ return value_in if value_in.options&.[](:rpm_name)
15
+
16
+ return independent_source_name(value_in) if independent_core_source?
17
+
18
+ value_in.support_name = host.name if host
19
+
20
+ renamed_host_name(value_in)
21
+ end
22
+
23
+ def independent_core_source?
24
+ host == doc && (is_lib? || is_app?) &&
25
+ (source.is_a?(Baltix::Source::Gem) || source.is_a?(Baltix::Source::Gemfile))
26
+ end
27
+
28
+ def independent_source_name value
29
+ prefix = is_lib? ? value.class.default_prefix : nil
30
+
31
+ value.class.parse(value, kind: kind.to_s, prefix: prefix, support_name: nil)
32
+ end
33
+
34
+ def renamed_host_name value
35
+ return gem_host_name(value) if host&.source.is_a?(Baltix::Source::Gem) && !is_exec?
36
+ return repository_host_name(value) if host && repository_metadata_host?
37
+
38
+ value
39
+ end
40
+
41
+ def gem_host_name value
42
+ value.class.parse(value, prefix: value.class.default_prefix, support_name: value.support_name)
43
+ end
44
+
45
+ def repository_metadata_host?
46
+ host.source.is_a?(Baltix::Source::Gemfile) || host.source.is_a?(Baltix::Source::Rakefile)
47
+ end
48
+
49
+ def repository_host_name value
50
+ base_name = repository_part_name(value)
51
+
52
+ value.class.parse(value, support_name: value.support_name, name: base_name)
53
+ end
54
+
55
+ def repository_part_name value
56
+ return host.name.to_s if host == doc && source.is_a?(Baltix::Source::Gemfile) && is_aux?
57
+
58
+ value.prefix && value.prefix == value.autoprefix ? value.name : value.original_fullname
59
+ end
60
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Merges numeric interpreter and RubyGems constraints without expanding opaque RPM expressions.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Replaces parsed numeric interpreter and RubyGems minimums with merged requirements.
8
+ # @param value_in [Array<String>] retained non-gem RPM requirements
9
+ # @return [Array<String, Hash>] opaque requirements and combined Ruby/RubyGems bounds
10
+ # Numeric Ruby and RubyGems constraints are merged; unrelated packages and RPM
11
+ # macros remain unchanged. Rendering selects the strictest lower boundary for each interpreter.
12
+ # Merged bounds occupy the first numeric interpreter entry's position. If none
13
+ # exists, they are appended so source-only generation and updates keep the same order.
14
+ def _requires_ruby value_in
15
+ return value_in if doc.distinct_root_package? && source.is_a?(Baltix::Source::Fake)
16
+
17
+ dependencies = Array(value_in)
18
+ position = dependencies.index {|dependency| ruby_dependency(dependency) } || dependencies.length
19
+
20
+ dependencies.reject {|dependency| ruby_dependency(dependency) }.insert(position, ruby_requirements).uniq
21
+ end
22
+
23
+ # Replaces numeric interpreter and RubyGems conflicts with merged requirements.
24
+ # @param value_in [Array<String>] retained non-gem RPM conflicts
25
+ # @return [Array<String, Hash>] opaque conflicts and combined Ruby/RubyGems bounds
26
+ # Numeric Ruby and RubyGems conflicts are merged; unrelated RPM entries remain
27
+ # unchanged. Rendering selects the strictest upper boundary for each interpreter.
28
+ def _conflicts_ruby value_in
29
+ return value_in if doc.distinct_root_package? && source.is_a?(Baltix::Source::Fake)
30
+
31
+ Array(value_in).reject {|dependency| ruby_dependency(dependency) } | [ruby_requirements]
32
+ end
33
+
34
+ # Parses one numeric interpreter constraint without expanding RPM expressions.
35
+ # @param dependency [Object] an imported RPM dependency
36
+ # @return [Array<String>, nil] package name, operator and version, or no match
37
+ # Ruby, RubyGems and engines declared by this library/application are recognized.
38
+ # Other packages, non-string inputs and opaque versions are left untouched.
39
+ def ruby_dependency dependency
40
+ return unless dependency.is_a?(String)
41
+
42
+ match = /\A(?<name>\S+)\s+(?<operator>!=|>=|<=|=|>|<)\s+(?<version>\S+)\z/.match(dependency)
43
+ engines = %w[ruby rubygems] | (%i[lib app].include?(kind) ? source.dsl.required_rubies.keys : [])
44
+
45
+ return unless match && engines.include?(match[:name]) && Gem::Version.correct?(match[:version])
46
+
47
+ match.values_at(:name, :operator, :version)
48
+ end
49
+
50
+ # Intersects this package's source and imported interpreter/RubyGems requirements.
51
+ # @return [Hash<String, Gem::Requirement>] merged interpreter and RubyGems requirements
52
+ # Libraries and applications include interpreter and RubyGems source declarations,
53
+ # excluding implicit unconstrained defaults. Other packages use only imported
54
+ # constraints. Explicit options take precedence over parsed RPM tags.
55
+ # Parsed conflicts are inverted into allowed bounds before the shared merger is
56
+ # used; macros and unrelated dependencies are preserved by the caller.
57
+ def ruby_requirements
58
+ @ruby_requirements ||=
59
+ begin
60
+ requirements = source_ruby_requirements
61
+
62
+ INTERPRETER_DEPENDENCY_TAGS.each do |tag|
63
+ imported_ruby_declarations(tag).each do |dependency|
64
+ merge_ruby_declaration(requirements, dependency, tag)
65
+ end
66
+ end
67
+
68
+ requirements
69
+ end
70
+ end
71
+
72
+ def source_ruby_requirements
73
+ declarations =
74
+ if PRIMARY_PACKAGE_KINDS.include?(kind)
75
+ source.dsl.required_rubies.merge('rubygems' => source.dsl.required_rubygems)
76
+ else
77
+ {}
78
+ end
79
+
80
+ declarations.reject {|_name, requirement| requirement == Gem::Requirement.default }
81
+ end
82
+
83
+ def imported_ruby_declarations tag
84
+ value = of_options(tag)
85
+
86
+ value = of_state(tag) unless value.present?
87
+
88
+ Array(value)
89
+ end
90
+
91
+ def merge_ruby_declaration requirements, dependency, tag
92
+ parsed = ruby_dependency(dependency)
93
+
94
+ return unless parsed
95
+
96
+ name, operator, version = parsed
97
+
98
+ operator = RUBY_CONFLICT_OPERATORS.fetch(operator) if tag == :conflicts
99
+
100
+ incoming = Gem::Requirement.new("#{operator} #{version}")
101
+ requirements[name] = requirements[name] ? requirements[name].merge(incoming) : incoming
102
+ end
103
+ end