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,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'rbconfig'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'open3'
|
|
7
|
+
|
|
8
|
+
# Architecture names, aliases and compatibility come from ALT RPM's own files.
|
|
9
|
+
# These are data files: no RPM macros or source code are executed here.
|
|
10
|
+
module Baltix::AltArchitecture
|
|
11
|
+
CATALOG = JSON.parse(File.read(File.expand_path('../../../../data/alt-rpm/architectures.json', __dir__))).freeze
|
|
12
|
+
CANONICAL = CATALOG.fetch('canonical').freeze
|
|
13
|
+
TRANSLATIONS = CATALOG.fetch('translations').freeze
|
|
14
|
+
COMPATIBILITY = CATALOG.fetch('compatibility').freeze
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
def families
|
|
18
|
+
CATALOG.fetch('families')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def names
|
|
22
|
+
@names ||= (CANONICAL.keys | CANONICAL.values | TRANSLATIONS.keys |
|
|
23
|
+
TRANSLATIONS.values | families.values.flatten).freeze
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def known? name
|
|
27
|
+
name.is_a?(String) && names.include?(name)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def canonical name
|
|
31
|
+
visited = []
|
|
32
|
+
|
|
33
|
+
until visited.include?(name)
|
|
34
|
+
visited << name
|
|
35
|
+
|
|
36
|
+
target = TRANSLATIONS[name] || CANONICAL[name]
|
|
37
|
+
|
|
38
|
+
break if target.nil? || target == name
|
|
39
|
+
|
|
40
|
+
name = target
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
name
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def compatible_names name
|
|
47
|
+
pending = [canonical(name)]
|
|
48
|
+
result = []
|
|
49
|
+
|
|
50
|
+
until pending.empty?
|
|
51
|
+
current = pending.shift
|
|
52
|
+
|
|
53
|
+
next if result.include?(current) || current == 'noarch'
|
|
54
|
+
|
|
55
|
+
result << current
|
|
56
|
+
pending.concat(Array(COMPATIBILITY[current]))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
result
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def default_target
|
|
63
|
+
return @default_target if defined?(@default_target)
|
|
64
|
+
|
|
65
|
+
begin
|
|
66
|
+
output, status = Open3.capture2e('rpm', '--eval', '%{_target_cpu}')
|
|
67
|
+
|
|
68
|
+
selected = output.strip if status.success? && known?(output.strip)
|
|
69
|
+
rescue Errno::ENOENT
|
|
70
|
+
selected = nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
@default_target = selected || RbConfig::CONFIG.fetch('host_cpu')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def platform_allowed? platform, target: nil
|
|
77
|
+
return true if platform.nil? || platform.to_s == 'ruby'
|
|
78
|
+
|
|
79
|
+
platform = Gem::Platform.new(platform) unless platform.is_a?(Gem::Platform)
|
|
80
|
+
|
|
81
|
+
return false unless linux_platform?(platform)
|
|
82
|
+
|
|
83
|
+
target ||= default_target
|
|
84
|
+
|
|
85
|
+
known?(target) && compatible_platform?(platform, target)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def linux_platform? platform
|
|
89
|
+
platform.is_a?(Gem::Platform) && platform.os == 'linux'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def compatible_platform? platform, target
|
|
93
|
+
case platform.version
|
|
94
|
+
when 'eabihf', 'gnueabihf'
|
|
95
|
+
hard_float_arm?(target) && (platform.cpu == 'arm' || compatible_cpu?(platform.cpu, target))
|
|
96
|
+
when nil, 'gnu'
|
|
97
|
+
compatible_cpu?(platform.cpu, target)
|
|
98
|
+
else
|
|
99
|
+
false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def hard_float_arm? target
|
|
104
|
+
cpu = canonical(target)
|
|
105
|
+
|
|
106
|
+
families.fetch('arm').include?(cpu) && CATALOG.fetch('float_abi')[cpu] == 'hard'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def compatible_cpu? source, target
|
|
110
|
+
source_cpu = platform_cpu(source)
|
|
111
|
+
|
|
112
|
+
compatible_names(target).any? {|cpu| platform_cpu(cpu) == source_cpu }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def platform_cpu cpu
|
|
116
|
+
known?(cpu) ? Gem::Platform.new("#{canonical(cpu)}-linux").cpu : cpu
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Combines available gem ranges without lowering source minimums or losing exclusions.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
# Builds an availability override without lowering any source minimum.
|
|
8
|
+
# @param available [Gem::Dependency, nil] optional range inferred from the available gem list
|
|
9
|
+
# @param dependencies [Array<Gem::Dependency>] current source requirements for this gem
|
|
10
|
+
# @return [Gem::Dependency, nil] the corrected range, or nil when all available versions are too old
|
|
11
|
+
# The lower bound is the greatest source minimum, independent of availability.
|
|
12
|
+
# The source upper bound is the least source maximum; availability may raise
|
|
13
|
+
# it, but cannot narrow it. If sources have no maximum, it stays unbounded.
|
|
14
|
+
# Exclusions retain their individual versions without adding minimums or
|
|
15
|
+
# maximums. Without an available list, the source interval
|
|
16
|
+
# is still returned.
|
|
17
|
+
# If a source uses >, its exclusive minimum is preserved; = and ~> supply
|
|
18
|
+
# inclusive minimums. If no available version reaches the source minimum,
|
|
19
|
+
# no override is produced. Historical spec macros do not participate.
|
|
20
|
+
def _available_dependency_override available, dependencies
|
|
21
|
+
requirements = dependencies.map(&:requirement).reduce {|left, right| left.merge(right) }
|
|
22
|
+
minimum = source_dependency_minimum(requirements)
|
|
23
|
+
|
|
24
|
+
return nil if available && !available_reaches_minimum?(available, minimum)
|
|
25
|
+
|
|
26
|
+
pairs = override_requirement_pairs(requirements, dependencies, available, minimum)
|
|
27
|
+
|
|
28
|
+
Gem::Dependency.new(dependencies.first.name, Gem::Requirement.new(pairs.map {|pair| pair.join(' ') }))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def source_dependency_minimum requirements
|
|
32
|
+
minimum = Baltix::Deps.lower_to_rpm(requirements)
|
|
33
|
+
|
|
34
|
+
minimum.first == '=' ? ['>=', minimum.last] : minimum
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def override_requirement_pairs requirements, dependencies, available, minimum
|
|
38
|
+
maximum = dependency_maximums(dependencies).min_by {|operator, version| [version, operator == '<' ? 0 : 1] }
|
|
39
|
+
pairs = [minimum]
|
|
40
|
+
|
|
41
|
+
pairs << available_maximum(maximum, available) if maximum
|
|
42
|
+
pairs.concat(requirements.requirements.find_all {|operator, _| operator == '!=' })
|
|
43
|
+
|
|
44
|
+
pairs
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def available_reaches_minimum? available, minimum
|
|
48
|
+
versions = Array(available_gem_list[available.name]).map {|version| Gem::Version.new(version.to_s) }
|
|
49
|
+
|
|
50
|
+
versions.any? {|version| minimum[0] == '>' ? version > minimum[1] : version >= minimum[1] }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def dependency_maximums dependencies
|
|
54
|
+
dependencies.flat_map do |dependency|
|
|
55
|
+
dependency.requirement.requirements.filter_map do |operator, version|
|
|
56
|
+
case operator
|
|
57
|
+
when '<', '<=' then [operator, version]
|
|
58
|
+
when '=' then ['<=', version]
|
|
59
|
+
when '~>' then ['<', version.bump]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def available_maximum maximum, available
|
|
66
|
+
available_maximums =
|
|
67
|
+
if available
|
|
68
|
+
available.requirement.requirements.find_all do |operator, _|
|
|
69
|
+
MAXIMUM_OPERATORS.include?(operator)
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
[]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
([maximum] + available_maximums).max_by {|operator, version| [version, operator == '<=' ? 1 : 0] }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Reads dependency override macros retained by the input spec parser.
|
|
79
|
+
# Takes no parameters.
|
|
80
|
+
# @return [Hash<String, Gem::Dependency>] imported requirements keyed by gem name
|
|
81
|
+
# Repeated declarations are merged. A name without a constraint receives
|
|
82
|
+
# >= 0; missing macros return an empty hash. Malformed declarations raise
|
|
83
|
+
# ArgumentError, and invalid requirements propagate RubyGems' parsing error.
|
|
84
|
+
def declared_gem_dependency_overrides
|
|
85
|
+
Array(variables.ruby_use_gem_dependency).flat_map {|line| line.split(',') }.reduce({}) do |result, declaration|
|
|
86
|
+
dependency = parsed_dependency_override(declaration)
|
|
87
|
+
result[dependency.name] = result[dependency.name] ? result[dependency.name].merge(dependency) : dependency
|
|
88
|
+
|
|
89
|
+
result
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def parsed_dependency_override declaration
|
|
94
|
+
match = declaration.strip.match(/\A([^\s<>=!~]+)\s*(.*)\z/)
|
|
95
|
+
|
|
96
|
+
raise(ArgumentError, "Invalid gem dependency override: #{declaration}") unless match
|
|
97
|
+
|
|
98
|
+
name, requirement = match.captures
|
|
99
|
+
|
|
100
|
+
Gem::Dependency.new(name, requirement.empty? ? '>= 0' : requirement)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def _gem_versionings_with_use value_in
|
|
104
|
+
dep_list_merge(_gem_versionings(value_in), use_gem_version_list)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rebuilds gem build/check requirements while retaining plain RPM prerequisites and their versions.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
def _build_dependencies value_in
|
|
8
|
+
Baltix::DSL.merge_dependencies(value_in, space.all_dependencies_for(kinds_in: :build))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def optional_build_dependency_parts
|
|
12
|
+
@optional_build_dependency_parts ||=
|
|
13
|
+
space.targets.flat_map(&:optional_build_dependencies).group_by(&:first).transform_values do |entries|
|
|
14
|
+
entries.map(&:last).tap(&:uniq!)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def optional_build_parts_for name
|
|
19
|
+
parts = optional_build_dependency_parts[name]
|
|
20
|
+
|
|
21
|
+
return [] unless parts
|
|
22
|
+
return [] if space.valid_sources.any? do |source|
|
|
23
|
+
source.dsl.all_dependencies_for(kinds_in: :build).any? {|dependency| dependency.name == name }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
parts
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def _build_dependencies_filter value_in
|
|
30
|
+
# binding.pry
|
|
31
|
+
value_in.select do |dep|
|
|
32
|
+
Baltix::DSL.match_kind_dep(dep, :build)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def _check_dependencies value_in
|
|
37
|
+
dep_hash = value_in.group_by(&:name).transform_values {|x| x.reduce {|res, y| res.merge(y) }}
|
|
38
|
+
|
|
39
|
+
dep_hash.values | space.all_dependencies_for(kinds_in: :test)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def _check_dependencies_filter value_in
|
|
43
|
+
# binding.pry
|
|
44
|
+
value_in.reject do |dep|
|
|
45
|
+
Baltix::DSL.match_kind_dep(dep, :build) && optional_build_parts_for(dep.name).empty?
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Retains only non-gem RPM constraints before rebuilding gem dependencies.
|
|
50
|
+
# @param value_in [Array<Gem::Dependency, String>] imported build/check constraints
|
|
51
|
+
# @return [Array<String>] manually declared RPM constraints to preserve
|
|
52
|
+
# Every imported gem dependency is discarded, including names absent from the
|
|
53
|
+
# current sources. Names, bounds and phases are rebuilt from source/discovery
|
|
54
|
+
# metadata. Obsolete Ruby package aliases are removed; explicit header packages
|
|
55
|
+
# and other non-gem requirements remain unchanged.
|
|
56
|
+
def _filter_out_build_auto_requires value_in
|
|
57
|
+
Array(value_in).reject do |value|
|
|
58
|
+
value.is_a?(Gem::Dependency) ||
|
|
59
|
+
(value.is_a?(String) && /^(#{Baltix::Spec::Rpm::Name::PREFICES.join('|')})[-(]/ =~ value &&
|
|
60
|
+
!value.match?(/\A\S+-headers-devel(?:\s|\z)/))
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def _build_requires _value_in
|
|
65
|
+
render_deps(build_dependencies)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def _check_requires _value_in
|
|
69
|
+
render_deps(check_dependencies)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def _build_conflicts _value_in
|
|
73
|
+
render_deps(build_dependencies, :negate)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def _check_conflicts _value_in
|
|
77
|
+
render_deps(check_dependencies, :negate)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Normalizes Ruby build prerequisites while retaining explicit version constraints.
|
|
81
|
+
# @param value_in [Array<String, Gem::Dependency>, nil] imported/grouped prerequisites
|
|
82
|
+
# @return [Array<String>] canonical prerequisite lines without duplicate Ruby entries
|
|
83
|
+
# Obsolete Ruby Policy 2.0's rpm-build-ruby is replaced with the Ruby Policy 2.1
|
|
84
|
+
# prerequisites rpm-macros-ruby, setup-rb and rake. If that legacy prerequisite
|
|
85
|
+
# is present or the package prefix changes, missing
|
|
86
|
+
# defaults are added. If a default package already has a versioned requirement,
|
|
87
|
+
# that requirement is kept instead of adding an unversioned one. Remaining
|
|
88
|
+
# unversioned defaults are grouped so parsing and rendering stay consistent.
|
|
89
|
+
# Imported gem prerequisites are discarded and rebuilt in their source-defined
|
|
90
|
+
# build/check phases. Embedded RPM expressions remain unexpanded.
|
|
91
|
+
def _build_pre_requires value_in
|
|
92
|
+
build_pre_requires = plain_prerequisites(value_in)
|
|
93
|
+
stated_name = of_state(:name)
|
|
94
|
+
defaults = of_default(:build_pre_requires)[0].split
|
|
95
|
+
legacy_ruby = build_pre_requires.delete('rpm-build-ruby')
|
|
96
|
+
|
|
97
|
+
if legacy_ruby || stated_name && stated_name.prefix != name.prefix
|
|
98
|
+
add_missing_prerequisites(build_pre_requires,
|
|
99
|
+
defaults)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
grouped_prerequisites(build_pre_requires, defaults)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def plain_prerequisites value
|
|
106
|
+
parser = Parser.new
|
|
107
|
+
prerequisites =
|
|
108
|
+
Array(value).flat_map do |line|
|
|
109
|
+
line.is_a?(Gem::Dependency) ? [] : parser.parse_dep([nil, line], preserve_versions: true)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
prerequisites.reject {|dependency| dependency.is_a?(Gem::Dependency) }.tap(&:uniq!)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def add_missing_prerequisites prerequisites, defaults
|
|
116
|
+
defaults.each do |dependency|
|
|
117
|
+
unless prerequisites.any? {|entry| entry == dependency || entry.start_with?("#{dependency} ") }
|
|
118
|
+
prerequisites << dependency
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def grouped_prerequisites prerequisites, defaults
|
|
124
|
+
plain_defaults = defaults.select {|dependency| prerequisites.delete(dependency) }
|
|
125
|
+
|
|
126
|
+
plain_defaults.reject! {|dependency| prerequisites.any? {|entry| entry.start_with?("#{dependency} ") }}
|
|
127
|
+
|
|
128
|
+
grouped = plain_defaults.empty? ? [] : [plain_defaults.join(' ')]
|
|
129
|
+
|
|
130
|
+
grouped + prerequisites
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Queries documentation, native extension directories and gem versus plain build headers.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
# +has_any_docs?+ returns true if self or child source has any doc
|
|
6
|
+
#
|
|
7
|
+
def has_any_docs?
|
|
8
|
+
all_docs.any?
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Checks this package's native extensions and, optionally, its subpackages.
|
|
12
|
+
# The compilables list itself remains local to the main package. With
|
|
13
|
+
# :with_children, emitted library subpackages are also checked; without it,
|
|
14
|
+
# only the local list is checked for file ownership.
|
|
15
|
+
# @param mode [Symbol, nil] :with_children includes library subpackages;
|
|
16
|
+
# nil checks only this package
|
|
17
|
+
# @return [Boolean] false when compilables_dep_setup is :skip; otherwise,
|
|
18
|
+
# true when the local list or an included library subpackage has compilables
|
|
19
|
+
def has_compilables? mode = nil
|
|
20
|
+
options['compilables_dep_setup'] != :skip &&
|
|
21
|
+
(!compilables.blank? || (mode == :with_children && valid_secondaries.any? do |secondary|
|
|
22
|
+
secondary.is_lib? && secondary.has_compilables?
|
|
23
|
+
end))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Checks whether the main manifest needs its generated extension directory.
|
|
27
|
+
# Takes no parameters.
|
|
28
|
+
# @return [Boolean] true when native extensions exist and no retained entry owns the directory
|
|
29
|
+
# If an existing file entry already names the same Ruby extension directory,
|
|
30
|
+
# including braced macros or ownership attributes, it supplies the entry.
|
|
31
|
+
# Packages without compilables need no generated directory declaration.
|
|
32
|
+
def needs_extension_directory?
|
|
33
|
+
has_compilables? && preserved_files(self).none? do |line|
|
|
34
|
+
line.match?(/(?:\A|\s)%(?:ruby_gemextdir|\{ruby_gemextdir\})\s*(?:#.*)?\z/)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def pure_build_requires
|
|
39
|
+
build_requires.grep_v(/^gem\(.*\)/)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def pure_build_conflicts
|
|
43
|
+
build_conflicts.grep_v(/^gem\(.*\)/)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def gem_build_requires
|
|
47
|
+
build_requires.grep(/^gem\(.*\)/)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def gem_build_conflicts
|
|
51
|
+
build_conflicts.grep(/^gem\(.*\)/)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def has_gem_build_requires?
|
|
55
|
+
gem_build_requires.any?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def has_gem_build_conflicts?
|
|
59
|
+
gem_build_conflicts.any?
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Retains historical changelog data and records existing version/spec revision changes.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
def _collect_changes value_in
|
|
8
|
+
%i[name version provides].each {|x| send(x) }
|
|
9
|
+
|
|
10
|
+
value_in
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def state_changed?
|
|
14
|
+
@state_changed =
|
|
15
|
+
STATE_CHANGE_NAMES.any? do |property|
|
|
16
|
+
if property == 'secondary'
|
|
17
|
+
[of_state(property), send(property)].transpose.any? do |(first, second)|
|
|
18
|
+
first.name != second.name
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
of_state(property) != send(property)
|
|
22
|
+
end
|
|
23
|
+
#
|
|
24
|
+
# when String, Name, Gem::Version, NilClass,
|
|
25
|
+
# binding.prya
|
|
26
|
+
# when Array
|
|
27
|
+
# binding.pry
|
|
28
|
+
# of_state(property) == self.send(property)
|
|
29
|
+
# when OpenStruct
|
|
30
|
+
# binding.pry
|
|
31
|
+
# of_state(property) == self.send(property)
|
|
32
|
+
# else
|
|
33
|
+
# binding.pry
|
|
34
|
+
# end
|
|
35
|
+
#
|
|
36
|
+
# true
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Appends a versioned changelog entry for the current package changes.
|
|
41
|
+
# @param value_in [Array<OpenStruct>] existing changelog history
|
|
42
|
+
# @return [Array<OpenStruct>] history with a new entry when changes are present
|
|
43
|
+
# Revision previews and unchanged specs retain the original history. If changes
|
|
44
|
+
# exist, the new entry uses the current package version and calculated release,
|
|
45
|
+
# plus the package epoch when set. Historical entries, including omitted EVRs,
|
|
46
|
+
# are retained unchanged; their missing fields never seed a new entry.
|
|
47
|
+
def _changes value_in
|
|
48
|
+
return value_in if @checking_revision || @unchanged_spec
|
|
49
|
+
|
|
50
|
+
new_change =
|
|
51
|
+
if change_list.any?
|
|
52
|
+
previous_version = of_state(:version)
|
|
53
|
+
version, release = evr_from_changes
|
|
54
|
+
|
|
55
|
+
change_record(version, release, binding)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
value_in | [new_change].compact
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def change_record version, release, context_binding
|
|
62
|
+
OpenStruct.new(
|
|
63
|
+
date: Date.today.strftime('%a %b %d %Y'),
|
|
64
|
+
author: options.maintainer&.name || packager.name,
|
|
65
|
+
email: options.maintainer&.email || packager.email,
|
|
66
|
+
epoch: epoch,
|
|
67
|
+
version: version,
|
|
68
|
+
release: release,
|
|
69
|
+
description: descriptions_from_changes(context_binding)
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def descriptions_from_changes b
|
|
74
|
+
change_list.sort_by {|x| -CHANGES_MAJORITY.keys.index(x) }.map do |ch|
|
|
75
|
+
Baltix::I18n.t("spec.rpm.change.#{ch}", binding: b)
|
|
76
|
+
end.join("\n")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def evr_from_changes
|
|
80
|
+
return [version, @spec_revision_release] if @spec_revision_release
|
|
81
|
+
|
|
82
|
+
changes = change_list.map {|change| CHANGES_MAJORITY[change] }.tap(&:uniq!)
|
|
83
|
+
|
|
84
|
+
if changes.include?(:new)
|
|
85
|
+
[version, initial_package_release]
|
|
86
|
+
elsif changes.include?(:version)
|
|
87
|
+
[version, of_options(:release) || 'alt1']
|
|
88
|
+
else
|
|
89
|
+
[version, bumped_change_release(changes)]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def initial_package_release
|
|
94
|
+
of_state(:release) || of_options(:release) || 'alt1'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def bumped_change_release changes
|
|
98
|
+
/alt(?<release_version>.*)/ =~ of_state(:release)
|
|
99
|
+
|
|
100
|
+
if changes.include?(:major)
|
|
101
|
+
"alt#{Gem::Version.new(release_version.split(/[._]/).first).bump}"
|
|
102
|
+
else
|
|
103
|
+
parts = release_version.split(/[._]/)
|
|
104
|
+
minor = Gem::Version.new(parts[1] || '0').bump.to_s
|
|
105
|
+
|
|
106
|
+
"alt#{parts[0]}.#{minor}"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def _release _value_in
|
|
111
|
+
return of_options(:release) || of_state(:release) || 'alt1' if @checking_revision
|
|
112
|
+
|
|
113
|
+
@spec_revision_release || changes.last&.release
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Selects current source overrides and applies the configured upper-bound policy.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
# Selects dependency overrides required by any packaged source.
|
|
8
|
+
# @param _value_in [OpenStruct, Hash, nil] historical overrides, superseded by current inputs
|
|
9
|
+
# @return [OpenStruct] override requirements keyed by dependency name
|
|
10
|
+
# An override is retained when it changes a dependency of the main source or
|
|
11
|
+
# another packaged source, so secondary gems also receive a build-time macro.
|
|
12
|
+
# Version exclusions are retained independently from the source interval;
|
|
13
|
+
# macros and RPM exact conflicts preserve the same excluded versions.
|
|
14
|
+
# If available versions are too old, exclusions still use the source interval.
|
|
15
|
+
# If a gem is itself packaged from these sources, it is excluded from external
|
|
16
|
+
# version overrides and retains its source version.
|
|
17
|
+
# In redep mode, generated and imported override macros retain only source
|
|
18
|
+
# minimums. All mode also selects gems with source or input RPM conflicts;
|
|
19
|
+
# inline comments do not introduce additional gem names.
|
|
20
|
+
# Historical names select the override policy only. A gem absent from current
|
|
21
|
+
# source/discovery metadata is omitted; old RPM tags and macro bounds never
|
|
22
|
+
# create dependencies or supply their minimums. Ignored dependency names do
|
|
23
|
+
# not produce override macros unless an explicit regard match enables them.
|
|
24
|
+
def _versioned_gem_list _value_in
|
|
25
|
+
packaged_sources = Array(sources) | [source].compact
|
|
26
|
+
packaged_names = packaged_sources.grep(Baltix::Source::Gem).map(&:name)
|
|
27
|
+
dependencies = override_source_dependencies(packaged_sources)
|
|
28
|
+
excluded_names = excluded_dependency_names(dependencies)
|
|
29
|
+
overrides = available_dependency_overrides(dependencies, packaged_names, excluded_names)
|
|
30
|
+
mode = gem_dependency_mode
|
|
31
|
+
|
|
32
|
+
return overrides if mode == :regular
|
|
33
|
+
|
|
34
|
+
selected = selected_override_names(overrides, dependencies, mode)
|
|
35
|
+
|
|
36
|
+
source_minimum_overrides(selected, dependencies, packaged_names)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def override_source_dependencies sources
|
|
40
|
+
sources.flat_map(&:all_dependencies).reject {|dependency| ignored_name?(dependency.name) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def excluded_dependency_names dependencies
|
|
44
|
+
dependencies.select do |dependency|
|
|
45
|
+
dependency.requirement.requirements.any? {|operator, _| operator == '!=' }
|
|
46
|
+
end.map!(&:name)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def available_dependency_overrides dependencies, packaged_names, excluded_names
|
|
50
|
+
names = available_gem_ranges.to_h.keys.map(&:to_s) | excluded_names
|
|
51
|
+
|
|
52
|
+
names.reduce({}.to_os) do |result, name|
|
|
53
|
+
available = available_gem_ranges[name]
|
|
54
|
+
|
|
55
|
+
next result if packaged_names.include?(name.to_s)
|
|
56
|
+
|
|
57
|
+
override = matching_available_override(available, name, dependencies, excluded_names)
|
|
58
|
+
|
|
59
|
+
result[name] = override if override
|
|
60
|
+
result
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def matching_available_override available, name, dependencies, excluded_names
|
|
65
|
+
matching = dependencies.select {|dependency| dependency.name == name.to_s }
|
|
66
|
+
|
|
67
|
+
changed_dependency_override(available, matching, excluded_names.include?(name)) unless matching.empty?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def changed_dependency_override available, matching, excluded
|
|
71
|
+
override = _available_dependency_override(available, matching)
|
|
72
|
+
|
|
73
|
+
override ||= _available_dependency_override(nil, matching) if excluded
|
|
74
|
+
|
|
75
|
+
if override && (excluded || matching.any? do |dependency|
|
|
76
|
+
combine_deps(dependency, override).requirement.requirements != dependency.requirement.expand.requirements
|
|
77
|
+
end)
|
|
78
|
+
override
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
require 'baltix/spec/rpm/dependency_policy'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Applies regular/redep/no-upper selection while preserving source minimums and exclusions.
|
|
4
|
+
class Baltix::Spec::Rpm
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
def selected_override_names overrides, dependencies, mode
|
|
8
|
+
selected = overrides.to_h.keys.map(&:to_s) | declared_gem_dependency_overrides.keys
|
|
9
|
+
|
|
10
|
+
if mode == :'no-upper'
|
|
11
|
+
selected |= source_upper_bound_names(dependencies)
|
|
12
|
+
selected |= imported_conflict_names
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
selected
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def source_upper_bound_names dependencies
|
|
19
|
+
dependencies.filter_map do |dependency|
|
|
20
|
+
dependency.name if dependency.requirement.requirements.any? do |operator, _|
|
|
21
|
+
UPPER_BOUND_OPERATORS.include?(operator)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def imported_conflict_names
|
|
27
|
+
state.original_spec.to_s.lines.grep(/^(?:BuildConflicts|Conflicts):/).flat_map do |line|
|
|
28
|
+
line.split('#', 2).first.scan(/(?:gem|rubygem|ruby-gem)\(([^)]+)\)/).flatten
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def source_minimum_overrides selected, dependencies, packaged_names
|
|
33
|
+
selected.reduce({}.to_os) do |result, name|
|
|
34
|
+
next result if packaged_names.include?(name)
|
|
35
|
+
|
|
36
|
+
matching = dependencies.select {|dependency| dependency.name == name }
|
|
37
|
+
|
|
38
|
+
next result if matching.empty?
|
|
39
|
+
|
|
40
|
+
result[name] = source_minimum_dependency(name, matching)
|
|
41
|
+
|
|
42
|
+
result
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def source_minimum_dependency name, matching
|
|
47
|
+
requirements =
|
|
48
|
+
_available_dependency_override(nil, matching).requirement.requirements.find_all do |operator, _|
|
|
49
|
+
MINIMUM_OVERRIDE_OPERATORS.include?(operator)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Gem::Dependency.new(name, requirements.map {|pair| pair.join(' ') })
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Resolves the configured gem upper-bound policy.
|
|
56
|
+
# Takes no parameters.
|
|
57
|
+
# @return [Symbol] :regular, :redep or :'no-upper'
|
|
58
|
+
# Missing configuration selects no-upper. Strings from YAML are accepted;
|
|
59
|
+
# the former all spelling is read as an alias for existing configurations.
|
|
60
|
+
# an unsupported configured value raises ArgumentError before rendering.
|
|
61
|
+
def gem_dependency_mode
|
|
62
|
+
mode = options.gem_dependency_mode.nil? ? :'no-upper' : options.gem_dependency_mode.to_s.to_sym
|
|
63
|
+
|
|
64
|
+
mode = :'no-upper' if mode == :all
|
|
65
|
+
raise(ArgumentError, "Unknown gem dependency mode: #{mode}") unless %i[regular redep no-upper].include?(mode)
|
|
66
|
+
|
|
67
|
+
mode
|
|
68
|
+
end
|
|
69
|
+
end
|