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,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Resolves native, imported and executable package identities without losing aliases.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _name value_in
8
+ native = native_rpm_name
9
+
10
+ return native if native
11
+
12
+ name, aliases, kind, support = selected_name_parts(value_in)
13
+
14
+ Baltix::Spec::Rpm::Name.parse(name, kind: kind, prefix: options[:name_prefix], aliases: aliases,
15
+ support_name: support)
16
+ end
17
+
18
+ def native_rpm_name
19
+ return stated_native_rpm_name if native_application_source? && of_state(:rpm_name)
20
+ return unless self == doc && doc.distinct_root_package?
21
+
22
+ Baltix::Spec::Rpm::Name.parse(state.name.original_fullname, kind: 'app')
23
+ end
24
+
25
+ def stated_native_rpm_name
26
+ Baltix::Spec::Rpm::Name.for_rpm(of_state(:rpm_name), aliases: of_state(:name).aliases)
27
+ end
28
+
29
+ def selected_name_parts value
30
+ if is_exec?
31
+ [selected_executable_name(value), executables, kind]
32
+ elsif value.is_a?(Baltix::Spec::Rpm::Name)
33
+ imported_name_parts(value)
34
+ else
35
+ [value, [], kind]
36
+ end
37
+ end
38
+
39
+ def selected_executable_name value
40
+ if render_source_executable_name?
41
+ source.name
42
+ elsif state.name
43
+ state.name.to_s
44
+ elsif executable_name.size >= 3
45
+ executable_name
46
+ else
47
+ value
48
+ end
49
+ end
50
+
51
+ def render_source_executable_name?
52
+ doc.space.options.autorender_name && doc.source.is_a?(Baltix::Source::Gem)
53
+ end
54
+
55
+ def imported_name_parts value
56
+ selected, aliases = imported_name_aliases(value)
57
+
58
+ [selected, aliases, value.kind, value.support_name]
59
+ end
60
+
61
+ def imported_name_aliases value
62
+ if source.is_a?(Baltix::Source::Gem)
63
+ [source.name, value.aliases]
64
+ elsif value.alias_map[kind.to_s]
65
+ [value.alias_map[kind.to_s].first, []]
66
+ else
67
+ [value.name, value.aliases]
68
+ end
69
+ end
70
+
71
+ def _post_name value_in
72
+ state_aliases = of_state(:name)&.alias_map
73
+ state_name = state_aliases&.[](nil)&.first
74
+
75
+ change(:rename) if state_name && of_state(:name) != value_in
76
+ # change(:rename) if state_name && value_in != state_name
77
+
78
+ value_in
79
+ end
80
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Tracks real package renames and retains their explicit RPM compatibility declarations.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _obsoletes value_in
8
+ value_in.reduce([]) do |res, o|
9
+ if names.include?(o)
10
+ res
11
+ else
12
+ /^[^\s]+$/.match?(o) ? res | ["#{o} < %EVR"] : res | [o]
13
+ end
14
+ end.compact
15
+ end
16
+
17
+ def _find_obsoletes value_in
18
+ obsolete = renamed_rpm_package? ? ["#{state.name.original_fullname} < %EVR"] : []
19
+
20
+ value_in | obsolete
21
+ end
22
+
23
+ # Distinguishes a real rename from preserving an unexpanded native selector.
24
+ # @return [Boolean] whether the previous RPM name needs compatibility tags
25
+ # A native ABI macro and its expanded parsed name denote the same package.
26
+ def renamed_rpm_package?
27
+ return false unless of_state(:name)
28
+ return of_state(:rpm_name) != name.fullname if name.options&.[](:rpm_name)
29
+
30
+ of_state(:name).original_fullname != name.fullname
31
+ end
32
+
33
+ def _filter_out_obsolete value_in
34
+ value_in.reject do |value|
35
+ value.is_a?(Gem::Dependency) || !use_gem_obsolete_list.[](value.match(/^(?<name>[^\s]+)/)[:name]).nil?
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Selects dependency lists by RPM kind while retaining the existing group mapping.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Selects dependencies for the current RPM package kind.
8
+ # Takes no parameters.
9
+ # @return [Array<Gem::Dependency, String>] dependencies before RPM rendering
10
+ # Applications combine main-source runtime declarations with real gem sources'
11
+ # capabilities; fake and Gemfile-only sources add no synthetic gem requirement.
12
+ # Libraries use runtime dependencies. Development packages of the main
13
+ # application use its development dependencies; other development and executable
14
+ # packages use their own dependency lists. Other kinds add no dependencies.
15
+ def _kind_deps
16
+ return [] if doc.distinct_root_package? && source.is_a?(Baltix::Source::Fake)
17
+
18
+ case kind
19
+ when :app then application_dependencies
20
+ when :lib then runtime_dependencies
21
+ when :devel then development_package_dependencies
22
+ when :exec then binary_dependencies
23
+ else []
24
+ end
25
+ end
26
+
27
+ def application_dependencies
28
+ main = doc.space.main_source.dsl.all_dependencies_for(kinds_in: :runtime)
29
+ depended =
30
+ doc.space.valid_sources.grep(Baltix::Source::Gem).reject do |source|
31
+ source == doc.space.main_source
32
+ end
33
+
34
+ Baltix::DSL.merge_dependencies(main, depended.map!(&:provide)).sort
35
+ end
36
+
37
+ def development_package_dependencies
38
+ host.is_app? && host == doc ? host.space.dependencies_for(kinds_in: :devel) : devel_dependencies
39
+ end
40
+
41
+ def _prepare_dependencies value_in
42
+ value_in.filter_map do |dep|
43
+ if (m = dep.match(/gem\((.*)\) ([>=<]+) ([\w\d.-]+)/))
44
+ Gem::Dependency.new(m[1], Gem::Requirement.new(["#{m[2]} #{m[3]}"]), :runtime)
45
+ else
46
+ dep
47
+ end
48
+ end
49
+ end
50
+
51
+ def _dependencies_sort value_in
52
+ value_in.sort
53
+ end
54
+
55
+ def _replace_versioning_dependencies value_in
56
+ provide_names = doc.secondaries.filter_map {|secondary| secondary.source&.provide&.name }.tap(&:uniq!)
57
+
58
+ replace_versioning(value_in).reject {|dependency| omitted_versioned_dependency?(dependency, provide_names) }
59
+ end
60
+
61
+ def omitted_versioned_dependency? dependency, provide_names
62
+ return false unless dependency.is_a?(Gem::Dependency)
63
+
64
+ dependency.type == :development && options.devel_dep_setup == :skip || provide_names.include?(dependency.name)
65
+ end
66
+
67
+ def _render_bottom_dep value_in
68
+ render_deps(value_in)
69
+ end
70
+
71
+ def _render_top_dep value_in
72
+ render_deps(value_in, :negate)
73
+ end
74
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Retains plain RPM requirements and regenerates auxiliary host/development requirements.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Selects RPM requirements that are not regenerated from package metadata.
8
+ # @param value_in [Array<Gem::Dependency, String>] parsed requirements
9
+ # @return [Array<String>] retained non-gem RPM requirements
10
+ # Gem requirements are reconstructed from sources. For an auxiliary package
11
+ # of an application, its host RPM requirement is also reconstructed so a prior
12
+ # exact release cannot survive alongside the host's current release.
13
+ def _requires_plain_only value_in
14
+ @requires_plain_only ||= value_in&.reject {|dependency| dependency.is_a?(Gem::Dependency) || generated_host_requirement?(dependency) }
15
+ end
16
+
17
+ def generated_host_requirement? dependency
18
+ is_aux? && host&.is_app? && dependency.is_a?(String) &&
19
+ application_host_names.include?(dependency.split.first)
20
+ end
21
+
22
+ def application_host_names
23
+ return [host.name.to_s] unless host.source.is_a?(Baltix::Source::Gemfile)
24
+
25
+ [host.name.to_s, host.source.name, File.basename(host.source.rootdir)]
26
+ end
27
+
28
+ def _conflicts_plain_only value_in
29
+ @conflicts_plain_only ||= value_in&.reject {|dep| dep.is_a?(Gem::Dependency) }
30
+ end
31
+
32
+ def _host_require value_in
33
+ return value_in if doc.distinct_root_package? && source.is_a?(Baltix::Source::Fake)
34
+ return unless is_aux?
35
+
36
+ [host_requirement].compact
37
+ end
38
+
39
+ def host_requirement
40
+ if host.is_app?
41
+ "#{host.name} = #{host.evr}"
42
+ else
43
+ source.is_a?(Baltix::Source::Fake) ? host.provide_dep : provide_dep
44
+ end
45
+ end
46
+
47
+ def _devel_requires value_in
48
+ value_tmp = value_in || source&.dependencies(:development) || []
49
+ deps_versioned = replace_versioning(value_tmp)
50
+
51
+ render_deps(append_versioning(deps_versioned))
52
+ end
53
+
54
+ def _devel_conflicts value_in
55
+ value_tmp = value_in || source&.dependencies(:development) || []
56
+ deps_versioned = replace_versioning(value_tmp)
57
+
58
+ render_deps(append_versioning(deps_versioned), :negate)
59
+ end
60
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Selects an initial RPM name using configured, parsed and source-root names in order.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _pre_name value_in
8
+ return value_in if value_in.is_a?(Baltix::Spec::Rpm::Name)
9
+
10
+ selected = @name || of_options(:name) || of_state(:name) || root_basename || value_in
11
+
12
+ if selected.is_a?(Baltix::Spec::Rpm::Name)
13
+ selected
14
+ else
15
+ Baltix::Spec::Rpm::Name.parse(selected,
16
+ prefix: options[:name_prefix])
17
+ end
18
+ end
19
+
20
+ def root_basename
21
+ rootdir&.split('/')&.last
22
+ end
23
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Keeps typed gem capabilities separate from legacy plain RPM package aliases.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Collects exact gem capabilities supplied by packages in this generated spec.
8
+ # Takes no parameters.
9
+ # @return [Hash<String, String>] gem names mapped to their actual Provides versions
10
+ # Only exact rendered gem capabilities participate; non-gem aliases and
11
+ # unversioned or ranged capabilities are ignored. The current package and its
12
+ # host, when present, also participate so custom templates rendering saved
13
+ # metadata retain their own exact host requirements. Results are cached per package.
14
+ def provided_gem_versions
15
+ return @provided_gem_versions if @provided_gem_versions
16
+
17
+ packages = ([doc] + doc.valid_secondaries) | [self]
18
+
19
+ packages |= [host].compact if respond_to?(:host)
20
+
21
+ @provided_gem_versions =
22
+ packages.each_with_object({}) do |package, result|
23
+ record_provided_versions(package, result)
24
+ end
25
+ end
26
+
27
+ def record_provided_versions package, result
28
+ package.provides.each do |capability|
29
+ match = capability.match(/\Agem\(([^)]+)\)\s+=\s+(\S+)\z/)
30
+
31
+ result[match[1]] = match[2] if match
32
+ end
33
+ end
34
+
35
+ # Builds the gem capability with its original name and selected package version.
36
+ # @return [Gem::Dependency] the provided gem with an exact version requirement
37
+ # If a source exists, its literal name is retained even when legacy RPM aliases
38
+ # or version overrides also match another gem. Without a source, the space name
39
+ # supplies the capability. A previously built dependency is returned unchanged.
40
+ def provide_dep
41
+ return @provide_dep if @provide_dep
42
+
43
+ provide_dep_pre = source&.provide || space.name
44
+
45
+ @provide_dep = Gem::Dependency.new(provide_dep_pre.name, version)
46
+ end
47
+
48
+ # Retains explicit capabilities without converting gems into plain RPM aliases.
49
+ # @param value_in [Array<Gem::Dependency, String>] capabilities from configuration or state
50
+ # @return [Array<Gem::Dependency, String>] explicit capabilities awaiting rendering
51
+ # Packaged gems' capabilities are regenerated with their selected versions.
52
+ # Other gem capabilities retain their type and bounds. Plain aliases matching
53
+ # the current gem's literal name are removed, with or without version bounds.
54
+ # Other RPM aliases retain the existing deduplication and implicit EVR behavior.
55
+ # Packaged sources are queried only when a parsed gem capability needs handling.
56
+ # The current gem's name is also checked when no typed gem capability was given.
57
+ def _provides value_in
58
+ packaged_names = provided_source_names(value_in)
59
+
60
+ gem_name = source.name if source.is_a?(Baltix::Source::Gem)
61
+
62
+ value_in.reduce([]) do |result, capability|
63
+ result | retained_capability(capability, packaged_names, gem_name)
64
+ end.compact
65
+ end
66
+
67
+ def provided_source_names declarations
68
+ if declarations.any?(Gem::Dependency)
69
+ (Array(doc.sources) | [source]).grep(Baltix::Source::Gem).map(&:name)
70
+ else
71
+ []
72
+ end
73
+ end
74
+
75
+ def retained_capability capability, packaged_names, gem_name
76
+ if capability.is_a?(Gem::Dependency)
77
+ packaged_names.include?(capability.name) ? [] : [capability]
78
+ elsif names.include?(capability) || capability.split.first == gem_name
79
+ []
80
+ else
81
+ [/^[^\s]+$/.match?(capability) ? "#{capability} = %EVR" : capability]
82
+ end
83
+ end
84
+
85
+ def _post_provides value_in
86
+ change(:explicit_deps) if value_in.present? && !state.provides
87
+ end
88
+
89
+ def _lib_provide
90
+ render_deps([provide_dep].compact, :provide) if kind == :lib
91
+ end
92
+
93
+ # Builds a compatibility capability when an imported RPM package is renamed.
94
+ # @return [Array<String>] the old RPM name with EVR, or an empty list
95
+ # No alias is emitted without a renamed input package. For a real gem source,
96
+ # its literal name is also excluded: the typed gem capability represents it.
97
+ # Other legacy RPM names retain their compatibility alias.
98
+ def _find_provides
99
+ return [] unless renamed_rpm_package?
100
+ return [] if source.is_a?(Baltix::Source::Gem) && state.name.original_fullname == source.name
101
+
102
+ ["#{state.name.original_fullname} = %EVR"]
103
+ end
104
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Selects declared documentation and repository README files with their source-relative paths.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Selects documentation entries and resolves existing files from their source root.
8
+ # @param _in [Object] unused value from the property pipeline
9
+ # @return [String] space-separated documentation paths relative to the repository root
10
+ # If an entry exists under its source directory, its emitted path includes
11
+ # that directory relative to the repository. Root-level paths remain unchanged.
12
+ # Otherwise the declaration is retained for shared root files and metadata-only
13
+ # inputs. If the main gem is nested and declares no README, repository README
14
+ # documents supplement its entries, including its auxiliary packages. Sibling
15
+ # gems retain their own documentation. Entries with the same basename retain
16
+ # the first declaration.
17
+ def _readme _in
18
+ grouped =
19
+ readme_candidates.grep(%r{^[^/]*(#{Baltix::Source::Base::DEFAULT_FILES.join('|')})}i).group_by do |file|
20
+ File.basename(file)
21
+ end
22
+
23
+ grouped.map {|_name, declarations| readme_file_path(declarations.first) }.join(' ')
24
+ end
25
+
26
+ def readme_candidates
27
+ candidates = files
28
+ source_root = source && File.expand_path(source.rootdir)
29
+ repository_root = File.expand_path(doc.space.rootdir)
30
+
31
+ candidates |= repository_readme_files(repository_root) if supplement_root_readmes?(candidates, source_root,
32
+ repository_root)
33
+
34
+ candidates
35
+ end
36
+
37
+ def supplement_root_readmes? candidates, source_root, repository_root
38
+ source.is_a?(Baltix::Source::Gem) && source.equal?(doc.source) &&
39
+ source_root.start_with?(File.join(repository_root, '')) && candidates.grep(README_FILE_RE).empty?
40
+ end
41
+
42
+ def repository_readme_files repository_root
43
+ doc.space.default_fake_source.default_files.grep(README_FILE_RE).select do |file|
44
+ File.file?(File.join(repository_root, file))
45
+ end
46
+ end
47
+
48
+ def readme_file_path file
49
+ source_path = source && File.join(source.rootdir, file)
50
+
51
+ if source_path && File.exist?(source_path)
52
+ Pathname.new(source_path).relative_path_from(Pathname.new(doc.space.rootdir)).to_s
53
+ else
54
+ file
55
+ end
56
+ end
57
+
58
+ def _files _in
59
+ source&.files || []
60
+ rescue StandardError
61
+ []
62
+ end
63
+
64
+ def _docs _in = nil
65
+ of_source(:docs) || of_default(:docs)
66
+ end
67
+
68
+ # returns list of depencecies and devel sources without dep to itself
69
+ def _devel _in = nil
70
+ return [] if self == doc && doc.distinct_root_package?
71
+
72
+ source.all_dependencies.reject {|x| x.name === source.name } | devel_sources
73
+ end
74
+
75
+ def _devel_sources _in = nil
76
+ files.grep(/.*\.h(pp)?$/)
77
+ end
78
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the published cached metadata accessors and package-kind predicates on includers.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ def self.included object
6
+ object::STATE.each {|name, settings| define_attribute_pipeline(object, name, settings) }
7
+
8
+ PACKAGE_KINDS.each {|name| object.define_method("is_#{name}?") { kind.to_s == name }}
9
+ end
10
+
11
+ def self.define_attribute_pipeline object, name, settings
12
+ object.define_method(name) { self[name] ||= read_attribute(name, settings[:seq]) || of_default(name) }
13
+
14
+ object.define_method("has_#{name}?") do
15
+ options["#{name}_dep_setup"] != :skip && !read_attribute(name, settings['seq']).blank?
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Combines declared and statically loaded requirements without changing source minimums or dependency attributes.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Merges runtime requirements and applies effective gem version overrides.
8
+ # @param value_in [Array<Gem::Dependency>] runtime dependencies from existing state
9
+ # @return [Array<Gem::Dependency>] merged runtime dependencies with effective bounds
10
+ # If a dependency already exists, its source requirements are merged. External
11
+ # overrides are applied when available; dependencies on gems packaged in the
12
+ # same spec retain their source requirements.
13
+ def _runtime_dependencies value_in
14
+ initial = grouped_dependency_hash(value_in)
15
+ dependencies = merge_dependency_hash(initial, source.dsl.all_dependencies_for(kinds_in: :runtime)).values
16
+
17
+ infer_library_dependencies(dependencies) if source.is_a?(Baltix::Source::Gem)
18
+
19
+ replace_versioning(dependencies)
20
+ end
21
+
22
+ def grouped_dependency_hash dependencies
23
+ dependencies.group_by(&:name).transform_values do |values|
24
+ values.reduce do |result, dependency|
25
+ result.merge(dependency)
26
+ end
27
+ end
28
+ end
29
+
30
+ def merge_dependency_hash initial, dependencies
31
+ dependencies.reduce(initial.dup) do |result, dependency|
32
+ result[dependency.name] = result[dependency.name] ? result[dependency.name].merge(dependency) : dependency
33
+
34
+ result
35
+ end
36
+ end
37
+
38
+ def infer_library_dependencies dependencies
39
+ require('baltix/executable_dependencies')
40
+
41
+ reader = Baltix::ExecutableDependencies.new(source)
42
+
43
+ reader.library_dependencies.each {|inferred| append_inferred_dependency(dependencies, inferred) }
44
+
45
+ reader.warnings.each {|message| Kernel.warn(message) }
46
+ end
47
+
48
+ def append_inferred_dependency dependencies, inferred
49
+ existing = dependencies.find {|dependency| dependency.name == inferred.name }
50
+
51
+ if existing
52
+ replacement = existing.dup
53
+ requirement = existing.requirement.merge(inferred.requirement)
54
+
55
+ replacement.instance_variable_set(:@requirement, requirement)
56
+
57
+ dependencies[dependencies.index(existing)] = replacement
58
+ else
59
+ dependencies << inferred
60
+ end
61
+ end
62
+
63
+ def _devel_dependencies value_in
64
+ initial = grouped_dependency_hash(value_in)
65
+ declared = source.dsl.all_dependencies_for(kinds_in: :devel, kinds_out: :runtime)
66
+
67
+ merge_dependency_hash(initial, declared + source.build_tool_dependencies).values
68
+ end
69
+
70
+ def _binary_dependencies value_in
71
+ require('baltix/executable_dependencies')
72
+
73
+ initial = grouped_dependency_hash(value_in)
74
+ reader = Baltix::ExecutableDependencies.new(source)
75
+ dependencies = reader.dependencies
76
+
77
+ reader.warnings.each {|message| Kernel.warn(message) }
78
+
79
+ merge_dependency_hash(initial, dependencies).values
80
+ end
81
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Formats localized summaries with their original translation variables and source metadata.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ # Normalizes typographic punctuation in localized RPM package text.
8
+ # @param value_in [OpenStruct] summaries or descriptions indexed by locale
9
+ # @return [OpenStruct] text with plain quotes and ordinary interword spaces
10
+ # Language-specific letters and other Unicode characters remain unchanged.
11
+ # Nil locale values are retained. Normalization runs before description wrapping
12
+ # so non-breaking spaces do not join separate words into an oversized token.
13
+ def _normalize_text value_in
14
+ value_in.map {|_locale, text| text&.gsub(TEXT_CHARACTER_RE, TEXT_CHARACTERS) }
15
+ end
16
+
17
+ # Formats package summaries without reapplying labels to stored auxiliary text.
18
+ # @param value_in [OpenStruct] selected summaries indexed by locale
19
+ # @return [OpenStruct] localized summaries without surrounding label whitespace
20
+ # Parsed fake-source summaries are retained. If an auxiliary package has no
21
+ # host summary, its parsed summary is already complete and is retained as well.
22
+ # Otherwise gem and Gemfile sources use the translated package-kind labels;
23
+ # other source kinds retain the selected plain summaries.
24
+ def _summaries value_in
25
+ return value_in if retained_source_summary?
26
+ return value_in if retained_auxiliary_summary?
27
+
28
+ source_name = source&.name
29
+ summaries_in = source_summaries
30
+
31
+ Baltix::I18n.locales.map do |locale|
32
+ summary_for_locale(locale, value_in, summaries_in, source_name)
33
+ end.to_os.compact
34
+ end
35
+
36
+ def source_summaries
37
+ @host && host.summaries || of_source(:summaries) || {}.to_os
38
+ end
39
+
40
+ def retained_source_summary?
41
+ source.is_a?(Baltix::Source::Fake) && of_state(:summaries).present?
42
+ end
43
+
44
+ def retained_auxiliary_summary?
45
+ is_aux? && @host && @host.summaries.blank? && of_state(:summaries).present?
46
+ end
47
+
48
+ def summary_for_locale locale_in, value_in, summaries_in, source_name
49
+ locale = locale_in.blank? && Baltix::I18n.default_locale || locale_in
50
+ summary_pre = selected_summary(locale_in, locale, value_in, summaries_in)
51
+ summary = summary_pre&.match("(.*?)[-.,_\s]*?$")&.[](1)
52
+ default = Baltix::I18n.t(:"spec.rpm.#{kind}.summary", locale: locale, binding: binding)
53
+
54
+ [locale_in, gem_metadata_source? ? default&.strip : summary]
55
+ end
56
+
57
+ def selected_summary locale_in, locale, value_in, summaries_in
58
+ !PRIMARY_PACKAGE_KINDS.include?(kind) && summaries_in[locale_in] || value_in[locale] || value_in[locale_in] || nil
59
+ end
60
+
61
+ def gem_metadata_source?
62
+ source.is_a?(Baltix::Source::Gem) || source.is_a?(Baltix::Source::Gemfile)
63
+ end
64
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Wraps RPM descriptions while retaining paragraph and bullet boundaries.
4
+ module Baltix::Spec::Rpm::SpecCore
5
+ protected
6
+
7
+ def _format_descriptions value_in
8
+ value_in.map do |_name, description|
9
+ text = description.gsub(/\n{2,}/, "\x1F\x1F").gsub(/\n([*-])/, "\x1F\\1").tr("\n", "\s")
10
+ lines = text.split(/ +/).reduce([]) {|result, token| append_description_token(result, token) }
11
+
12
+ lines.join("\n")
13
+ end
14
+ end
15
+
16
+ def append_description_token lines, token
17
+ line = lines.last
18
+ word = token.gsub(/(\n[^\-*])/, "\n\\1").strip
19
+ text = [line, word].reject(&:blank?).join(' ')
20
+
21
+ text.size > 80 || !line ? lines << word : line.replace(text)
22
+ split_description_paragraph(lines)
23
+
24
+ lines
25
+ end
26
+
27
+ def split_description_paragraph lines
28
+ parts = lines.last.split("\x1F", -1)
29
+
30
+ return unless parts.size > 1
31
+
32
+ lines.last.replace(parts[0].strip)
33
+
34
+ lines.concat(parts.drop(1).map!(&:strip))
35
+ end
36
+ end