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,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Combines gemspec, Gemfile and native extension requirements.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
def dep
|
|
6
|
+
Bundler::Dependency.new(name.to_s, Gem::Requirement.new(["~> #{version}"]), 'type' => :runtime)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def deps groups = nil
|
|
10
|
+
spec&.dependencies&.select {|dep| !groups || [groups].flatten.include?(dep.type) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def dependencies type = nil
|
|
14
|
+
(dsl.dependencies(type) | deps).group_by(&:name).reduce([]) do |res, (_name, dependencies)|
|
|
15
|
+
dependency = merge_source_dependencies(dependencies)
|
|
16
|
+
|
|
17
|
+
!type || dependency.type == type ? res | [dependency] : res
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def merge_source_dependencies dependencies
|
|
22
|
+
dependencies.reduce do |result, dependency|
|
|
23
|
+
requirement = result.requirement.merge(dependency.requirement)
|
|
24
|
+
|
|
25
|
+
Gem::Dependency.new(result.name, requirement, [result.type, dependency.type].max)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def provide
|
|
30
|
+
spec.version && Gem::Dependency.new(spec.name, Gem::Requirement.new(["= #{spec.version}"]), :runtime) ||
|
|
31
|
+
Gem::Dependency.new(spec.name)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def compilable?
|
|
35
|
+
compilables.any?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def compilables
|
|
39
|
+
@compilables ||=
|
|
40
|
+
begin
|
|
41
|
+
extensions =
|
|
42
|
+
spec.extensions.each do |_extension|
|
|
43
|
+
Baltix::Source::Gem.specifics.filter_map do |file, data|
|
|
44
|
+
next unless match_file?(file)
|
|
45
|
+
|
|
46
|
+
dsl.assign_dependencies(extension_requirements(data) | extension_gems(data))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
extensions.map {|extension| File.join(rootdir, extension) }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def extension_requirements data
|
|
55
|
+
data[:requires].flat_map do |requirement|
|
|
56
|
+
dsl.dependencies.filter_map do |dependency|
|
|
57
|
+
next unless /#{requirement.gsub(%r{[-_./]}, '[-_./]+')}/.match?(dependency.name)
|
|
58
|
+
|
|
59
|
+
Bundler::Dependency.new(dependency.name, Gem::Requirement.new(dependency.requirement), 'group' => :build)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def extension_gems data
|
|
65
|
+
data[:gems].map do |dependency|
|
|
66
|
+
Bundler::Dependency.new(dependency.first.first, Gem::Requirement.new(dependency.first.last), 'group' => :build)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Discovers and loads candidate gem specifications in loader priority order.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
def self.search dir, options_in = {}
|
|
6
|
+
files = source_candidates(dir)
|
|
7
|
+
|
|
8
|
+
debug("Found source file list: #{files.map {|(_, file)| file }.join("\n\t")}")
|
|
9
|
+
|
|
10
|
+
sources =
|
|
11
|
+
candidate_specifications(files, dir).flat_map do |file, data|
|
|
12
|
+
data[:gemspecs].map do |gemspec|
|
|
13
|
+
new(source_options(options_in.merge(spec: gemspec, source_file: file, loader: data[:loader])))
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
infer_dependency_platforms(sources.tap(&:compact!))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.candidate_specifications files, dir
|
|
21
|
+
files.reduce({}) do |res, (regexp, file)|
|
|
22
|
+
result = load_candidate(regexp, file, dir)
|
|
23
|
+
|
|
24
|
+
result ? res.merge({ file => candidate_metadata(result, file, dir) }) : res
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.source_candidates dir
|
|
29
|
+
files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH).select {|file| File.file?(file) }
|
|
30
|
+
candidates = files.filter_map {|file| matching_loader(file) }
|
|
31
|
+
|
|
32
|
+
candidates.sort {|left, right| compare_candidates(left, right) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.matching_loader file
|
|
36
|
+
LOADERS.reduce(nil) {|res, (regexp, _method_name)| res || regexp =~ file && [regexp, file] || nil }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.compare_candidates left, right
|
|
40
|
+
order = LOADERS.keys.index(left.first) <=> LOADERS.keys.index(right.first)
|
|
41
|
+
|
|
42
|
+
order.zero? && left.last <=> right.last || order
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.load_candidate regexp, file, dir
|
|
46
|
+
[LOADERS[regexp]].flatten.reduce(nil) do |res, method_name|
|
|
47
|
+
next res if res
|
|
48
|
+
|
|
49
|
+
result = send(method_name, file, dir)
|
|
50
|
+
|
|
51
|
+
result&.objects&.any? && [result, method_name]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.candidate_metadata load_result, file, dir
|
|
56
|
+
gemspecs =
|
|
57
|
+
load_result.first.objects.reject do |spec|
|
|
58
|
+
spec.loaded_from && spec.loaded_from !~ /#{dir}/
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
gemspecs.each {|spec| spec.loaded_from = file }
|
|
62
|
+
log_candidate(load_result)
|
|
63
|
+
|
|
64
|
+
{ gemspecs: gemspecs.compact, loader: load_result.last }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.log_candidate load_result
|
|
68
|
+
debug("load messages:\n\t#{load_result.first.log.join("\n\t")}") unless load_result.first.log.blank?
|
|
69
|
+
|
|
70
|
+
debug("Load errors:\n\t#{load_result.errlog.join("\n\t")}") unless load_result.first.errlog.blank?
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Selects packaged gem files and documentation from gemspec declarations.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
NATIVE_DOCUMENTATION_RE = /\.(?:c|h)$/i
|
|
6
|
+
|
|
7
|
+
DOCSRC_RE =
|
|
8
|
+
lambda do |source|
|
|
9
|
+
extras = Regexp.union(source.spec.extra_rdoc_files)
|
|
10
|
+
|
|
11
|
+
Regexp.union(/\.(?:rb|c|h)$/i, /\A(?:#{extras})\z/)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# tree
|
|
15
|
+
def datatree
|
|
16
|
+
# TODO: deep_merge
|
|
17
|
+
@datatree ||= super { { '.' => spec.files | default_files }}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def allfiles
|
|
21
|
+
@allfiles = required_path_files | executable_files | spec.files | default_files
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def required_path_files
|
|
25
|
+
files = require_pure_paths.flat_map {|path| Dir.glob(File.join(path, '**', '*'), base: rootdir) }
|
|
26
|
+
|
|
27
|
+
files.select {|file| File.file?(File.join(rootdir, file)) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def executable_files
|
|
31
|
+
prefix = File.join(rootdir, '')
|
|
32
|
+
|
|
33
|
+
spec.executables.filter_map do |file|
|
|
34
|
+
path = File.join(rootdir, spec.bindir, file)
|
|
35
|
+
|
|
36
|
+
path.delete_prefix(prefix) if File.file?(path)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def allfiles_for list_in
|
|
41
|
+
list_in.to_h do |directory, files|
|
|
42
|
+
selected = files_relative_to(directory)
|
|
43
|
+
|
|
44
|
+
[directory, files.select {|file| selected.include?(file.delete_prefix('./')) }]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def files_relative_to directory
|
|
49
|
+
directory = directory.delete_prefix('./').delete_suffix('/')
|
|
50
|
+
prefix = directory == '.' ? '' : "#{directory}/"
|
|
51
|
+
|
|
52
|
+
allfiles.filter_map do |file|
|
|
53
|
+
path = file.delete_prefix('./')
|
|
54
|
+
|
|
55
|
+
path.delete_prefix(prefix) if path.start_with?(prefix)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def exttree
|
|
60
|
+
@exttree ||= super
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def testtree
|
|
64
|
+
@testtree ||= allfiles_for(super)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def exetree
|
|
68
|
+
@exetree ||=
|
|
69
|
+
super do
|
|
70
|
+
Dir.chdir(rootdir) do
|
|
71
|
+
exedirs.to_h do |dir|
|
|
72
|
+
[dir, Dir.chdir(File.join(rootdir, dir)) do
|
|
73
|
+
Dir.glob("{#{spec.executables.join(',')}}")
|
|
74
|
+
end]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def docsrctree
|
|
81
|
+
@docsrctree ||= super { { '.' => spec.extra_rdoc_files | native_documentation_files }}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def native_documentation_files
|
|
85
|
+
spec.files.grep(NATIVE_DOCUMENTATION_RE)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def packaged_native_documentation_file? file
|
|
89
|
+
NATIVE_DOCUMENTATION_RE.match?(file) && spec.files.include?(file)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def docs
|
|
93
|
+
# TODO: make docs to docdir with lib/.rb replace to .ri
|
|
94
|
+
(!spec.rdoc_options.blank? && [default_ridir] || libfiles) | spec.extra_rdoc_files |
|
|
95
|
+
native_documentation_files
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def extroot_for file
|
|
99
|
+
extroots.find {|extroot| extroot == file[0...extroot.size] }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def files kind = nil, &block
|
|
103
|
+
kind ? super : spec.files | default_files
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def require_pure_paths
|
|
107
|
+
@require_pure_paths ||=
|
|
108
|
+
begin
|
|
109
|
+
paths = spec.require_paths.grep_v(%r{^/})
|
|
110
|
+
|
|
111
|
+
paths.any? && paths || ['lib']
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Delegates optional gem metadata while preventing alias recursion.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
def aliased_locks
|
|
6
|
+
@aliased_locks ||= {}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def aliased &block
|
|
10
|
+
aliases.reduce(nil) {|res, a| res || a != self && block[a] }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Exposes gem identity and localized RubyGems metadata.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
def original_spec
|
|
6
|
+
return @original_spec if @original_spec.is_a?(Gem::Specification)
|
|
7
|
+
|
|
8
|
+
@original_spec =
|
|
9
|
+
if @original_spec.is_a?(String)
|
|
10
|
+
Baltix.load(@original_spec)
|
|
11
|
+
else
|
|
12
|
+
self.class.spec_for(options)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def spec
|
|
17
|
+
return @spec if @spec
|
|
18
|
+
|
|
19
|
+
if aliases.any?
|
|
20
|
+
@spec ||=
|
|
21
|
+
aliases.reduce(original_spec) do |spec, als|
|
|
22
|
+
spec.merge(als.original_spec)
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
original_spec
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def name
|
|
30
|
+
spec.name
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def version
|
|
34
|
+
version = spec&.version&.to_s || '0'
|
|
35
|
+
parts = version.split('.')
|
|
36
|
+
extra = parts.drop(3).filter_map {|part| part.to_i <= 1024 && part || nil }
|
|
37
|
+
|
|
38
|
+
(parts[0..2] + extra).join('.')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def fullname
|
|
42
|
+
[name, version].compact.join('-')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# +valid?+ returns state of validity of the gem: true or false
|
|
46
|
+
# Returns true when all the conditiona are true:
|
|
47
|
+
# * gem's name of the gem is set
|
|
48
|
+
# * gem's name is not a system's one (has zero char)
|
|
49
|
+
# * gem's version is present
|
|
50
|
+
# * gem's platform is "ruby" or compatible with the selected ALT target
|
|
51
|
+
#
|
|
52
|
+
def valid?
|
|
53
|
+
!name.nil? &&
|
|
54
|
+
spec.version &&
|
|
55
|
+
Baltix::AltArchitecture.platform_allowed?(platform, target: @target_arch) &&
|
|
56
|
+
!spec.name.include?("\u0000")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def platform
|
|
60
|
+
spec.platform
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def required_ruby_version
|
|
64
|
+
spec&.required_ruby_version || super
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def required_rubygems_version
|
|
68
|
+
spec&.required_rubygems_version || super
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Default group
|
|
72
|
+
def group
|
|
73
|
+
'Development/Ruby'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def summaries
|
|
77
|
+
localize(spec.summary) || aliased {|s| s.localize(s.summary) } || descriptions
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def descriptions
|
|
81
|
+
localize(spec.description) || aliased {|s| localize(s.description) }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def localize text
|
|
85
|
+
text && OpenStruct.new(Baltix::I18n.default_locale => text)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Default prefix "gem" for gem names
|
|
89
|
+
def name_prefix
|
|
90
|
+
'gem'
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def uri
|
|
94
|
+
spec.homepage || spec.metadata['homepage_uri'] || aliased_uri
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def vcs
|
|
98
|
+
spec.metadata&.[]('source_code_uri')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def licenses
|
|
102
|
+
spec.licenses
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Applies explicit gem metadata and infers dependency platforms from variants.
|
|
4
|
+
class Baltix::Source::Gem
|
|
5
|
+
def self.spec_for options_in = {}
|
|
6
|
+
spec_in = options_in['spec']
|
|
7
|
+
spec = spec_in.is_a?(String) && Baltix.load(spec_in) || spec_in
|
|
8
|
+
version = replacement_version(spec, options_in)
|
|
9
|
+
|
|
10
|
+
spec.version = Gem::Version.new(version) if version
|
|
11
|
+
spec.require_paths = options_in['source-lib-folders'] if options_in['source-lib-folders']
|
|
12
|
+
|
|
13
|
+
spec
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.replacement_version spec, options_in
|
|
17
|
+
if options_in[:version_replaces] && options_in[:version_replaces][spec.name]
|
|
18
|
+
options_in[:version_replaces][spec.name]
|
|
19
|
+
elsif options_in[:gem_version_replace] && !options_in[:gem_version_replace].empty?
|
|
20
|
+
prever = options_in[:gem_version_replace].find {|(n, _v)| n == spec.name }&.last
|
|
21
|
+
|
|
22
|
+
/(?:[=><]+\s*)?(?<version>.*)/ =~ prever
|
|
23
|
+
version
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.name_for options_in = {}
|
|
28
|
+
spec_for(options_in).name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Infers dependency platforms from variants of the same gem.
|
|
32
|
+
# @param sources [Array<Baltix::Source::Gem>] discovered gem sources
|
|
33
|
+
# @return [Array<Baltix::Source::Gem>] the supplied sources with platform hints
|
|
34
|
+
# Sources are compared only within the same root, name and version. If a
|
|
35
|
+
# dependency occurs in any generic gemspec, it remains unrestricted. If it
|
|
36
|
+
# occurs only in platform variants, their declared platforms are recorded
|
|
37
|
+
# on the generic sources, including variants unavailable on the host.
|
|
38
|
+
def self.infer_dependency_platforms sources
|
|
39
|
+
sources.group_by {|source| [source.rootdir, source.name, source.version] }.each_value do |variants|
|
|
40
|
+
generic, specific = variants.partition {|source| source.platform.to_s == Gem::Platform::RUBY }
|
|
41
|
+
platforms = variant_dependency_platforms(generic, specific)
|
|
42
|
+
|
|
43
|
+
generic.each {|source| source.dependency_platforms = platforms }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sources
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.variant_dependency_platforms generic, specific
|
|
50
|
+
shared_names = generic.flat_map {|source| source.spec.dependencies.map(&:name) }.uniq
|
|
51
|
+
|
|
52
|
+
specific.each_with_object({}) do |source, result|
|
|
53
|
+
record_dependency_platforms(source, shared_names, result)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.record_dependency_platforms source, shared_names, result
|
|
58
|
+
source.spec.dependencies.each do |dependency|
|
|
59
|
+
next if shared_names.include?(dependency.name)
|
|
60
|
+
|
|
61
|
+
result[dependency.name] ||= []
|
|
62
|
+
result[dependency.name] |= [Gem::Platform.new(source.platform.to_s)]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|