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.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +136 -10
- data/Rakefile +8 -3
- data/baltix.gemspec +47 -29
- data/bin/console +4 -3
- data/data/alt-licenses/README.md +26 -0
- data/data/alt-licenses/licenses.json +2991 -0
- data/data/alt-rpm/README.md +21 -0
- data/data/alt-rpm/architectures.json +613 -0
- data/data/spdx/README.md +22 -0
- data/data/spdx/licenses.json +9287 -0
- data/docs/action-flow.md +42 -0
- data/docs/actor-integration.md +71 -0
- data/docs/alt-architectures.md +27 -0
- data/docs/cleanup-actors.md +14 -0
- data/docs/dependency-actions.md +22 -0
- data/docs/installation-actors.md +35 -0
- data/docs/pkglist.md +56 -0
- data/docs/plans/revision-003.md +328 -0
- data/docs/plans/revision-004.md +416 -0
- data/docs/plans/revision-005.md +431 -0
- data/docs/plans/revision-006.md +439 -0
- data/docs/plans/revision-007.md +441 -0
- data/docs/plans/revision-008.md +445 -0
- data/docs/plans/revision-009.md +450 -0
- data/docs/plans/revision-010.md +486 -0
- data/docs/plans/revision-011.md +500 -0
- data/docs/plans/revision-012.md +501 -0
- data/docs/plans/revision-013.md +501 -0
- data/docs/plans/revision-014.md +501 -0
- data/docs/plans/revision-015.md +502 -0
- data/docs/plans/revision-016.md +503 -0
- data/docs/plans/revision-017.md +504 -0
- data/docs/plans/revision-018.md +505 -0
- data/docs/plans/revision-019.md +510 -0
- data/docs/plans/revision-020.md +524 -0
- data/docs/plans/revision-021.md +542 -0
- data/docs/plans/revision-022.md +542 -0
- data/docs/plans/revision-023.md +545 -0
- data/docs/plans/revision-024.md +567 -0
- data/docs/plans/revision-025.md +583 -0
- data/docs/plans/revision-026.md +241 -0
- data/docs/plans/revision-027.md +305 -0
- data/docs/plans/revision-028.md +298 -0
- data/docs/plans/revision-029.md +288 -0
- data/docs/rpm-action-macros.md +52 -0
- data/docs/rpm-parts.md +53 -0
- data/docs/ruby-dependencies.md +217 -0
- data/docs/ruby-policy-2.1.md +28 -0
- data/docs/ruby-versioning.md +61 -0
- data/docs/space-format.md +58 -0
- data/exe/baltix +1 -0
- data/lib/baltix/action_flow/files.rb +49 -0
- data/lib/baltix/action_flow/inputs.rb +60 -0
- data/lib/baltix/action_flow/journal.rb +60 -0
- data/lib/baltix/action_flow/options.rb +60 -0
- data/lib/baltix/action_flow.rb +65 -0
- data/lib/baltix/actor/build/collect.rb +72 -0
- data/lib/baltix/actor/build/compile.rb +25 -0
- data/lib/baltix/actor/build/extconf.rb +14 -0
- data/lib/baltix/actor/build/make.rb +18 -0
- data/lib/baltix/actor/build/postprocess.rb +14 -0
- data/lib/baltix/actor/build/rake.rb +18 -0
- data/lib/baltix/actor/build/ronn.rb +55 -0
- data/lib/baltix/actor/build.rb +87 -0
- data/lib/baltix/actor/clean/remove.rb +45 -0
- data/lib/baltix/actor/clean.rb +37 -0
- data/lib/baltix/actor/config.rb +12 -0
- data/lib/baltix/actor/copy.rb +22 -7
- data/lib/baltix/actor/distclean.rb +20 -0
- data/lib/baltix/actor/doc/collect.rb +39 -0
- data/lib/baltix/actor/doc/generate.rb +47 -0
- data/lib/baltix/actor/doc/inputs.rb +25 -0
- data/lib/baltix/actor/doc.rb +70 -0
- data/lib/baltix/actor/gen.rb +19 -0
- data/lib/baltix/actor/install/data.rb +18 -0
- data/lib/baltix/actor/install/documentation.rb +48 -0
- data/lib/baltix/actor/install/executable.rb +27 -0
- data/lib/baltix/actor/install/extension.rb +44 -0
- data/lib/baltix/actor/install/headers.rb +10 -0
- data/lib/baltix/actor/install/library.rb +13 -0
- data/lib/baltix/actor/install/metadata.rb +21 -0
- data/lib/baltix/actor/install/paths.rb +73 -0
- data/lib/baltix/actor/install/plugin.rb +25 -0
- data/lib/baltix/actor/install/record.rb +48 -0
- data/lib/baltix/actor/install/shebang.rb +29 -0
- data/lib/baltix/actor/install/transfer.rb +64 -0
- data/lib/baltix/actor/install/trees.rb +34 -0
- data/lib/baltix/actor/install.rb +71 -0
- data/lib/baltix/actor/link.rb +15 -6
- data/lib/baltix/actor/make.rb +14 -0
- data/lib/baltix/actor/predeps/write.rb +51 -0
- data/lib/baltix/actor/predeps.rb +41 -0
- data/lib/baltix/actor/provides.rb +12 -0
- data/lib/baltix/actor/requires.rb +12 -0
- data/lib/baltix/actor/show.rb +26 -0
- data/lib/baltix/actor/spec.rb +6 -3
- data/lib/baltix/actor/test/record.rb +8 -0
- data/lib/baltix/actor/test/run.rb +30 -0
- data/lib/baltix/actor/test/select.rb +16 -0
- data/lib/baltix/actor/test.rb +41 -0
- data/lib/baltix/actor/touch.rb +14 -5
- data/lib/baltix/actor.rb +43 -26
- data/lib/baltix/cli/dependency_options.rb +63 -0
- data/lib/baltix/cli/options/action.rb +32 -0
- data/lib/baltix/cli/options.rb +280 -0
- data/lib/baltix/cli/output_options.rb +56 -0
- data/lib/baltix/cli/rake_tasks.rb +59 -0
- data/lib/baltix/cli/source_options.rb +52 -0
- data/lib/baltix/cli.rb +130 -116
- data/lib/baltix/concerns/command.rb +52 -0
- data/lib/baltix/concerns/configuration.rb +39 -0
- data/lib/baltix/concerns/dependency_output.rb +21 -0
- data/lib/baltix/concerns/extension_metadata.rb +44 -0
- data/lib/baltix/concerns/file_destination.rb +14 -0
- data/lib/baltix/concerns/inspection.rb +27 -0
- data/lib/baltix/concerns/parts.rb +16 -0
- data/lib/baltix/concerns/target_paths.rb +57 -0
- data/lib/baltix/concerns.rb +11 -0
- data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
- data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
- data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
- data/lib/baltix/deps/executables.rb +30 -0
- data/lib/baltix/deps/packages.rb +32 -0
- data/lib/baltix/deps.rb +103 -194
- data/lib/baltix/dsl/dependency_groups.rb +77 -0
- data/lib/baltix/dsl/dependency_sources.rb +100 -0
- data/lib/baltix/dsl/filtering.rb +26 -0
- data/lib/baltix/dsl/loading.rb +72 -0
- data/lib/baltix/dsl/merging.rb +74 -0
- data/lib/baltix/dsl/rendering.rb +54 -0
- data/lib/baltix/dsl/requirements.rb +77 -0
- data/lib/baltix/dsl/temporary_files.rb +36 -0
- data/lib/baltix/dsl.rb +66 -273
- data/lib/baltix/executable_dependencies/features.rb +53 -0
- data/lib/baltix/executable_dependencies/library.rb +21 -0
- data/lib/baltix/executable_dependencies/library_features.rb +34 -0
- data/lib/baltix/executable_dependencies/syntax.rb +102 -0
- data/lib/baltix/executable_dependencies.rb +102 -0
- data/lib/baltix/extensions/bones.rb +173 -0
- data/lib/baltix/extensions/echoe.rb +143 -0
- data/lib/baltix/extensions/hoe/metadata.rb +89 -0
- data/lib/baltix/extensions/hoe/options.rb +84 -0
- data/lib/baltix/extensions/hoe/readme.rb +29 -0
- data/lib/baltix/extensions/hoe.rb +146 -0
- data/lib/baltix/extensions/jeweler.rb +95 -0
- data/lib/baltix/extensions/levitate.rb +74 -0
- data/lib/baltix/extensions/olddoc.rb +42 -0
- data/lib/baltix/extensions.rb +340 -419
- data/lib/baltix/i18n.rb +22 -19
- data/lib/baltix/license/catalog/capture.rb +58 -0
- data/lib/baltix/license/catalog.rb +75 -0
- data/lib/baltix/license.rb +76 -0
- data/lib/baltix/loader/capture.rb +91 -0
- data/lib/baltix/loader/cmake.rb +6 -3
- data/lib/baltix/loader/evaluation.rb +49 -0
- data/lib/baltix/loader/extconf.rb +27 -0
- data/lib/baltix/loader/feature_loading.rb +54 -0
- data/lib/baltix/loader/git-version-gen.rb +36 -21
- data/lib/baltix/loader/mast/properties.rb +58 -0
- data/lib/baltix/loader/mast.rb +97 -109
- data/lib/baltix/loader/object_capture.rb +27 -0
- data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
- data/lib/baltix/loader/pom.rb +36 -16
- data/lib/baltix/loader/rookbook.rb +19 -14
- data/lib/baltix/loader/yaml.rb +9 -5
- data/lib/baltix/loader.rb +85 -132
- data/lib/baltix/log.rb +26 -27
- data/lib/baltix/rake/metadata_adapter.rb +30 -0
- data/lib/baltix/rake/task_context.rb +59 -0
- data/lib/baltix/rake/task_libraries.rb +73 -0
- data/lib/baltix/rake.rb +62 -12
- data/lib/baltix/source/base/dependencies.rb +81 -0
- data/lib/baltix/source/base/file_queries.rb +67 -0
- data/lib/baltix/source/base/file_tree.rb +70 -0
- data/lib/baltix/source/base/metadata.rb +140 -0
- data/lib/baltix/source/base/options.rb +71 -0
- data/lib/baltix/source/base/roots.rb +53 -0
- data/lib/baltix/source/base.rb +95 -377
- data/lib/baltix/source/fake.rb +89 -5
- data/lib/baltix/source/gem/delegation.rb +32 -0
- data/lib/baltix/source/gem/dependencies.rb +69 -0
- data/lib/baltix/source/gem/discovery.rb +72 -0
- data/lib/baltix/source/gem/file_trees.rb +114 -0
- data/lib/baltix/source/gem/forwarding.rb +12 -0
- data/lib/baltix/source/gem/metadata.rb +104 -0
- data/lib/baltix/source/gem/specification.rb +65 -0
- data/lib/baltix/source/gem.rb +65 -312
- data/lib/baltix/source/gemfile.rb +55 -5
- data/lib/baltix/source/rakefile.rb +12 -5
- data/lib/baltix/source.rb +36 -24
- data/lib/baltix/space/configuration.rb +54 -0
- data/lib/baltix/space/data/collections.rb +33 -0
- data/lib/baltix/space/data/gem_metadata.rb +79 -0
- data/lib/baltix/space/data/models.rb +20 -0
- data/lib/baltix/space/data/values.rb +72 -0
- data/lib/baltix/space/data.rb +53 -0
- data/lib/baltix/space/dependencies.rb +53 -0
- data/lib/baltix/space/filters.rb +96 -0
- data/lib/baltix/space/initialization.rb +124 -0
- data/lib/baltix/space/metadata.rb +130 -0
- data/lib/baltix/space/source_order.rb +43 -0
- data/lib/baltix/space/source_selection.rb +136 -0
- data/lib/baltix/space/source_status.rb +114 -0
- data/lib/baltix/space/spec.rb +3 -0
- data/lib/baltix/space.rb +87 -367
- data/lib/baltix/spec/rpm/aliases.rb +79 -0
- data/lib/baltix/spec/rpm/arch.rb +119 -0
- data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
- data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
- data/lib/baltix/spec/rpm/build_queries.rb +61 -0
- data/lib/baltix/spec/rpm/changelog.rb +115 -0
- data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
- data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
- data/lib/baltix/spec/rpm/deps.rb +113 -0
- data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
- data/lib/baltix/spec/rpm/env.rb +76 -0
- data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
- data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
- data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
- data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
- data/lib/baltix/spec/rpm/layout.rb +14 -0
- data/lib/baltix/spec/rpm/manpages.rb +71 -0
- data/lib/baltix/spec/rpm/metadata.rb +78 -0
- data/lib/baltix/spec/rpm/name/equality.rb +68 -0
- data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
- data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
- data/lib/baltix/spec/rpm/name.rb +77 -108
- data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
- data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
- data/lib/baltix/spec/rpm/parser/context.rb +50 -0
- data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
- data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
- data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
- data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
- data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
- data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
- data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
- data/lib/baltix/spec/rpm/parser/values.rb +85 -0
- data/lib/baltix/spec/rpm/parser.rb +124 -269
- data/lib/baltix/spec/rpm/part_files.rb +64 -0
- data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
- data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
- data/lib/baltix/spec/rpm/part_switches.rb +65 -0
- data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
- data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
- data/lib/baltix/spec/rpm/pkglist.rb +116 -0
- data/lib/baltix/spec/rpm/preparation.rb +73 -0
- data/lib/baltix/spec/rpm/rendering.rb +66 -0
- data/lib/baltix/spec/rpm/repository_application.rb +33 -0
- data/lib/baltix/spec/rpm/revision.rb +58 -0
- data/lib/baltix/spec/rpm/root_source.rb +48 -0
- data/lib/baltix/spec/rpm/scripts.rb +85 -0
- data/lib/baltix/spec/rpm/secondaries.rb +82 -0
- data/lib/baltix/spec/rpm/secondary.rb +117 -64
- data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
- data/lib/baltix/spec/rpm/section_document.rb +84 -0
- data/lib/baltix/spec/rpm/section_guards.rb +116 -0
- data/lib/baltix/spec/rpm/source_selection.rb +82 -0
- data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
- data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
- data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
- data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
- data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
- data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
- data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
- data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
- data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
- data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
- data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
- data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
- data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
- data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
- data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
- data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
- data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
- data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
- data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
- data/lib/baltix/spec/rpm/spec_core.rb +75 -527
- data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
- data/lib/baltix/spec/rpm.rb +253 -644
- data/lib/baltix/spec.rb +16 -14
- data/lib/baltix/target/gem.rb +61 -0
- data/lib/baltix/target/site.rb +40 -0
- data/lib/baltix/target.rb +16 -0
- data/lib/baltix/version.rb +3 -1
- data/lib/baltix.rb +77 -5
- data/locale/en_US.UTF-8.yaml +4 -1
- data/locale/ru_RU.UTF-8.yaml +7 -1
- data/rpm/baltix.env +4 -0
- data/rpm/baltix.prov +8 -0
- data/rpm/baltix.prov.files +6 -0
- data/rpm/baltix.req +8 -0
- data/rpm/baltix.req.files +6 -0
- data/rpm/macros.baltix +24 -0
- data/utils/rubocop/compact_block_braces.rb +39 -0
- data/utils/rubocop/spacing.rb +96 -0
- data/utils/update_alt_architectures.rb +57 -0
- data/utils/update_alt_licenses.rb +19 -0
- data/utils/update_spdx_licenses.rb +21 -0
- metadata +526 -17
- data/.github/workflows/ci.yml +0 -44
- data/.gitignore +0 -10
- 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
|