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
data/lib/baltix/cli.rb
CHANGED
|
@@ -1,173 +1,187 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'optparse'
|
|
2
4
|
require 'ostruct'
|
|
3
5
|
require 'yaml'
|
|
6
|
+
require 'shellwords'
|
|
4
7
|
|
|
5
8
|
require 'baltix'
|
|
6
9
|
require 'baltix/space'
|
|
7
10
|
require 'baltix/actor'
|
|
11
|
+
require 'baltix/action_flow'
|
|
8
12
|
require 'baltix/log'
|
|
13
|
+
require 'baltix/spec/rpm/pkglist'
|
|
14
|
+
require 'baltix/rake'
|
|
15
|
+
require 'baltix/spec/rpm/arch'
|
|
9
16
|
|
|
17
|
+
# Parses command-line configuration and runs packaging actions.
|
|
10
18
|
class Baltix::CLI
|
|
11
19
|
include Baltix::Log
|
|
12
20
|
|
|
13
21
|
DEFAULT_OPTIONS = {
|
|
14
22
|
rootdir: nil,
|
|
15
|
-
spec_type:
|
|
16
|
-
ignored_names: [],
|
|
17
|
-
regarded_names: [],
|
|
18
|
-
aliased_names: [],
|
|
19
|
-
ignored_path_tokens: [],
|
|
23
|
+
spec_type: 'rpm',
|
|
24
|
+
ignored_names: [].freeze,
|
|
25
|
+
regarded_names: [].freeze,
|
|
26
|
+
aliased_names: [].freeze,
|
|
27
|
+
ignored_path_tokens: [].freeze,
|
|
28
|
+
regarded_path_tokens: [].freeze,
|
|
20
29
|
spec_file: nil,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
available_gem_list: {}.to_os.freeze,
|
|
31
|
+
gem_dependency_mode: :'no-upper',
|
|
32
|
+
maintainer: {}.to_os.freeze,
|
|
33
|
+
packager: {}.to_os.freeze,
|
|
24
34
|
devel_dep_baltix: :include,
|
|
25
|
-
use_gem_version_list: {}.to_os,
|
|
26
|
-
use_gem_obsolete_list: {}.to_os,
|
|
35
|
+
use_gem_version_list: {}.to_os.freeze,
|
|
36
|
+
use_gem_obsolete_list: {}.to_os.freeze,
|
|
27
37
|
log_level: :info,
|
|
28
38
|
warn_io: 'stderr',
|
|
29
39
|
error_io: 'stderr',
|
|
30
40
|
info_io: 'stdout',
|
|
31
41
|
debug_io: 'stderr',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
opts.on("-r", "--rootdir=FOLDER", String, "Root folder to scan the sources") do |folder|
|
|
41
|
-
options[:rootdir] = folder
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
opts.on("--source-lib-folders=FOLDERS", Array, "Lib directories for the current source or at whole") do |list|
|
|
45
|
-
options[:source_lib_folders] = list.compact
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
opts.on("-I", "--ignore-names=LIST", Array, "Source names comma-separated ignore list") do |list|
|
|
49
|
-
options.ignored_names |= list.compact.map do |x|
|
|
50
|
-
m = /^\/(?<re>.*)/.match(x)
|
|
51
|
-
m && /#{m[:re]}/ || x
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
opts.on("-R", "--regard-names=LIST", Array, "Source names comma-separated regard list") do |list|
|
|
56
|
-
options.regarded_names |= list.compact.map do |x|
|
|
57
|
-
m = /^\/(?<re>.*)/.match(x)
|
|
58
|
-
m && /#{m[:re]}/ || x
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
opts.on("-A", "--alias-names=[LIST]", Array, "Source names comma-separated alias list") do |list|
|
|
63
|
-
options.aliased_names << list.compact
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
opts.on("-o", "--output-file=FILE", String, "Output file for a spec action") do |file|
|
|
67
|
-
options.output_file = file
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
opts.on("-s", "--spec-file=FILE", String, "Spec file for covering the baltix space") do |file|
|
|
71
|
-
options.spec_file = file
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
opts.on("-i", "--ignore-path-tokens=[LIST]", Array, "Ignore sources by a contained in its path token, and passed as a comma-separated list") do |list|
|
|
75
|
-
options.ignored_path_tokens.concat(list.compact)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
opts.on("--maintainer-name=NAME", String, "Name of the maintainer to use on spec generation") do |name|
|
|
79
|
-
options.maintainer_name = name
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
opts.on("--maintainer-email=EMAIL", String, "Email of the maintainer to use on spec generation") do |email|
|
|
83
|
-
options.maintainer_email = email
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
opts.on("--devel-dep-baltix=<TYPE>", %i(include skip), "Apply baltix type for devel dependencies to use with, defaulting to 'include'") do |type|
|
|
87
|
-
options.devel_dep_baltix = type
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
opts.on("-g", "--available-gem-list-file=[FILE]", String, "Path to a YAML-formatted file with the list of available gems to replace in dependencies") do |file|
|
|
91
|
-
options.available_gem_list = YAML.load(IO.read(file))
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
opts.on("--debug-io=[FILE|IO| |-|--]", String, "IO for debug level. Value is file name, or --/stderr for stderr, or -/stdout for stdout, or blank to disable") do |str|
|
|
95
|
-
options.debug_io = str
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
opts.on("-V", "--use-gem-version=[LIST]", Array, "Comma separated gem version pair list to forcely use in the baltix") do |gem_version|
|
|
99
|
-
hash = gem_version.map {|gv| gv.split(":") }.to_h
|
|
100
|
-
options.use_gem_version_list = options.use_gem_version_list.merge(hash)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
opts.on("-O", "--use-gem-obsolete=[LIST]", Array, "Comma separated gem obsolete list to forcely use in the baltix") do |gem_obsolete|
|
|
104
|
-
hash = gem_obsolete.map {|gv| gv.split(":") }.map {|(x, y)| [x, y.split(/,/)] }.to_h
|
|
105
|
-
options.use_gem_obsolete_list = options.use_gem_obsolete_list.merge(hash)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
opts.on("-v", "--verbose=[LEVEL]", String, "Run verbosely with levels: none, error, warn, info, or debug") do |v|
|
|
109
|
-
options.log_level = v
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
opts.on("-h", "--help", "This help") do |v|
|
|
113
|
-
puts opts
|
|
114
|
-
exit
|
|
115
|
-
end
|
|
116
|
-
end
|
|
42
|
+
high_default_dependencies_priority: false,
|
|
43
|
+
autorender_name: false,
|
|
44
|
+
rake_task_before: [].freeze,
|
|
45
|
+
skip_platforms: %i[jruby mingw mswin].freeze
|
|
46
|
+
}.to_os.freeze
|
|
47
|
+
|
|
48
|
+
def option_parser *default_argv
|
|
49
|
+
@option_parser ||= build_option_parser
|
|
117
50
|
|
|
118
51
|
if @argv
|
|
119
52
|
@option_parser.default_argv.replace(@argv)
|
|
120
|
-
|
|
121
|
-
@option_parser.default_argv
|
|
53
|
+
else
|
|
54
|
+
@option_parser.default_argv |= default_argv unless default_argv.empty?
|
|
55
|
+
@option_parser.default_argv << '-h' if @option_parser.default_argv.empty?
|
|
122
56
|
end
|
|
123
57
|
|
|
124
58
|
@option_parser
|
|
125
59
|
end
|
|
126
60
|
|
|
61
|
+
def default_options
|
|
62
|
+
file = File.join(Dir.home, '.baltix.yaml')
|
|
63
|
+
|
|
64
|
+
if File.file?(file)
|
|
65
|
+
Baltix.load_file(file)
|
|
66
|
+
else
|
|
67
|
+
{}
|
|
68
|
+
end.to_os(hash: true, array: true)
|
|
69
|
+
end
|
|
70
|
+
|
|
127
71
|
def options
|
|
128
|
-
@options ||= DEFAULT_OPTIONS.
|
|
72
|
+
@options ||= DEFAULT_OPTIONS.deep_dup.deep_merge(default_options)
|
|
129
73
|
end
|
|
130
74
|
|
|
131
75
|
def actions
|
|
132
|
-
@actions ||= parse.actions.select {
|
|
76
|
+
@actions ||= parse.actions.select {|a| Baltix::Actor.kinds.include?(a) }
|
|
133
77
|
end
|
|
134
78
|
|
|
79
|
+
# Parses options and commands in their original order.
|
|
80
|
+
# Takes no parameters.
|
|
81
|
+
# @return [OpenStruct] final options, action names and per-action option snapshots
|
|
82
|
+
# Each recognized action consumes rake_task_before. Later options affect later
|
|
83
|
+
# actions only, and repeated actions remain distinct. A task list without a
|
|
84
|
+
# following action raises OptionParser::MissingArgument; invalid options raise.
|
|
135
85
|
def parse!
|
|
136
86
|
return @parse if @parse
|
|
137
87
|
|
|
138
|
-
|
|
88
|
+
action_names = []
|
|
89
|
+
invocations = []
|
|
90
|
+
|
|
91
|
+
option_parser.order! do |name|
|
|
92
|
+
action_names << name
|
|
93
|
+
record_invocation(name, invocations)
|
|
94
|
+
end
|
|
95
|
+
validate_pending_tasks
|
|
139
96
|
|
|
140
|
-
@parse = OpenStruct.new(options: options, actions:
|
|
97
|
+
@parse = OpenStruct.new(options: options, actions: action_names, invocations: invocations)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def record_invocation name, invocations
|
|
101
|
+
return unless Baltix::Actor.kinds.include?(name)
|
|
102
|
+
|
|
103
|
+
invocations << { name: name, options: options.deep_dup }
|
|
104
|
+
|
|
105
|
+
options.rake_task_before = []
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def validate_pending_tasks
|
|
109
|
+
return if Array(options.rake_task_before).empty?
|
|
110
|
+
|
|
111
|
+
raise(OptionParser::MissingArgument, 'following command for --rake-task-before')
|
|
141
112
|
end
|
|
142
113
|
|
|
143
114
|
def parse
|
|
144
115
|
parse!
|
|
145
|
-
rescue OptionParser::InvalidOption
|
|
146
|
-
@parse = OpenStruct.new(options: options, actions: option_parser.default_argv)
|
|
147
116
|
end
|
|
148
117
|
|
|
149
118
|
def space
|
|
150
119
|
@space ||= Baltix::Space.load_from(options: parse.options)
|
|
151
120
|
end
|
|
152
121
|
|
|
153
|
-
|
|
154
|
-
@space = value
|
|
155
|
-
end
|
|
122
|
+
attr_writer :space
|
|
156
123
|
|
|
124
|
+
# Executes the parsed stream of actions and their associated Rake tasks.
|
|
125
|
+
# Takes no parameters.
|
|
126
|
+
# @return [Array<Object>] actor results in command-line order, including repeats
|
|
127
|
+
# If an action has preceding Rake tasks, they run before its sources are read.
|
|
128
|
+
# Every action receives its own options and space. Failures are logged and
|
|
129
|
+
# propagated so the actor and subsequent actions do not run after a failed task.
|
|
157
130
|
def run
|
|
158
|
-
|
|
159
|
-
|
|
131
|
+
parse.invocations.map {|invocation| run_invocation(invocation) }
|
|
132
|
+
rescue StandardError => error
|
|
133
|
+
error("[#{error.class}]: #{error.message}\n\t#{error.backtrace.join("\n\t")}")
|
|
134
|
+
raise
|
|
135
|
+
end
|
|
160
136
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
error("[#{e.class}]: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
|
|
137
|
+
def run_invocation invocation
|
|
138
|
+
load_action_space(invocation[:options])
|
|
139
|
+
|
|
140
|
+
run_rake_tasks_before(Array(space.options.rake_task_before))
|
|
141
|
+
|
|
142
|
+
Baltix::ActionFlow.new(space).run(invocation[:name])
|
|
168
143
|
end
|
|
169
144
|
|
|
145
|
+
# Creates a CLI from process arguments or an explicit argument sequence.
|
|
146
|
+
# @param argv [Array<String>, String, nil] tokens, a shell-style string, or ARGV
|
|
147
|
+
# @return [Baltix::CLI] the unparsed command interface
|
|
148
|
+
# Nil leaves OptionParser's process arguments in use; strings preserve quoted
|
|
149
|
+
# arguments through Shellwords, and arrays are copied without reordering.
|
|
170
150
|
def initialize argv = nil
|
|
171
|
-
@argv = argv
|
|
151
|
+
@argv = argv.is_a?(String) ? Shellwords.split(argv) : argv&.dup
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
private
|
|
155
|
+
|
|
156
|
+
# Manual YAML entries override generated versions, independently of option order.
|
|
157
|
+
# Without an explicit YAML file, pkglist entries override configured defaults.
|
|
158
|
+
def merge_available_indexes
|
|
159
|
+
defaults = @file_available_gems ? {} : (@initial_available_gems || {})
|
|
160
|
+
options.available_gem_list = defaults.merge(@pkglist_available_gems || {}).merge(@file_available_gems || {}).to_os
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Decodes a literal source name or a command-line regular expression.
|
|
164
|
+
# @param value [String] literal name, /pattern/, or legacy /pattern syntax
|
|
165
|
+
# @return [String, Regexp] unchanged literal name or the compiled pattern
|
|
166
|
+
# If the value starts with a slash, an unescaped final slash is a delimiter;
|
|
167
|
+
# an escaped final slash remains part of the expression. Without a leading
|
|
168
|
+
# slash the value stays literal, including any regexp metacharacters.
|
|
169
|
+
# @raise [RegexpError] when the supplied expression is invalid
|
|
170
|
+
def name_pattern value
|
|
171
|
+
return value unless value.start_with?('/')
|
|
172
|
+
|
|
173
|
+
expression = value[1, value.length]
|
|
174
|
+
|
|
175
|
+
expression = expression[0...-1] if expression.end_with?('/') && expression[0...-1][/\\*\z/].length.even?
|
|
176
|
+
|
|
177
|
+
Regexp.new(expression)
|
|
172
178
|
end
|
|
173
179
|
end
|
|
180
|
+
|
|
181
|
+
require 'baltix/cli/rake_tasks'
|
|
182
|
+
require 'baltix/cli/options'
|
|
183
|
+
require 'baltix/cli/source_options'
|
|
184
|
+
require 'baltix/cli/dependency_options'
|
|
185
|
+
require 'baltix/cli/output_options'
|
|
186
|
+
|
|
187
|
+
require 'baltix/cli/options/action'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'shellwords'
|
|
5
|
+
require 'baltix/log'
|
|
6
|
+
|
|
7
|
+
# Executes argv with an explicit directory/environment and retains diagnostics.
|
|
8
|
+
module Baltix::Concerns::Command
|
|
9
|
+
include Baltix::Log
|
|
10
|
+
|
|
11
|
+
# Preserves process output and status when an actor cannot complete.
|
|
12
|
+
class Failure < StandardError
|
|
13
|
+
attr_reader :result
|
|
14
|
+
|
|
15
|
+
def initialize result
|
|
16
|
+
@result = result
|
|
17
|
+
|
|
18
|
+
super("#{Shellwords.join(result[:argv])} failed in #{result[:directory]} " \
|
|
19
|
+
"(#{result[:exit_status]}):\n#{result[:stdout]}#{result[:stderr]}")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def run_command context, arguments
|
|
24
|
+
result = capture_command(arguments, context[:directory], context[:environment] || {})
|
|
25
|
+
|
|
26
|
+
(context[:commands] ||= []) << result
|
|
27
|
+
log_command(result)
|
|
28
|
+
raise(Failure, result) unless result[:success]
|
|
29
|
+
|
|
30
|
+
result
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def log_command result
|
|
34
|
+
info(result[:stdout]) unless result[:stdout].empty?
|
|
35
|
+
|
|
36
|
+
public_send(result[:success] ? :info : :error, result[:stderr]) unless result[:stderr].empty?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def capture_command arguments, directory, environment
|
|
40
|
+
stdout, stderr, status = Open3.capture3(environment, *arguments, chdir: directory)
|
|
41
|
+
|
|
42
|
+
{ argv: arguments, directory: directory, stdout: stdout, stderr: stderr,
|
|
43
|
+
exit_status: status.exitstatus, success: status.success? }
|
|
44
|
+
rescue SystemCallError => error
|
|
45
|
+
{ argv: arguments, directory: directory, stdout: '', stderr: error.message,
|
|
46
|
+
exit_status: nil, success: false }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def command_arguments value, default = []
|
|
50
|
+
value.is_a?(String) ? Shellwords.split(value) : Array(value || default)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'baltix/target'
|
|
4
|
+
|
|
5
|
+
# Prepares the same source/specification context for generation and execution.
|
|
6
|
+
module Baltix::Concerns::Configuration
|
|
7
|
+
def prepare
|
|
8
|
+
spec
|
|
9
|
+
valid_sources
|
|
10
|
+
targets
|
|
11
|
+
|
|
12
|
+
self
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def targets
|
|
16
|
+
@targets ||=
|
|
17
|
+
valid_sources.reject {|source| source.is_a?(Baltix::Source::Fake) }.map! do |source|
|
|
18
|
+
Baltix::Target.for(source, options)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def refresh_target_files
|
|
23
|
+
@targets&.each {|target| target.source.refresh_file_trees }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def save_configuration
|
|
27
|
+
path = File.join(rootdir, '.space')
|
|
28
|
+
|
|
29
|
+
state.config_outputs = Array(state.config_outputs) | [path] unless File.exist?(path)
|
|
30
|
+
|
|
31
|
+
File.write(path, Baltix::Space::Data.dump(configuration_data))
|
|
32
|
+
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def configuration_data
|
|
37
|
+
to_h
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'baltix/deps'
|
|
4
|
+
require 'baltix/deps/packages'
|
|
5
|
+
require 'baltix/concerns/inspection'
|
|
6
|
+
|
|
7
|
+
# Shares output mechanics while retaining the specification's dependency policy.
|
|
8
|
+
module Baltix::Concerns::DependencyOutput
|
|
9
|
+
include Baltix::Concerns::Inspection
|
|
10
|
+
|
|
11
|
+
def dependency_output space, kind
|
|
12
|
+
inspect_space(space) do
|
|
13
|
+
lists = Baltix::Deps::Packages.new(space).lists(kind)
|
|
14
|
+
values = lists.values.flatten.tap(&:uniq!)
|
|
15
|
+
|
|
16
|
+
write_output(space, values.map {|value| "#{value}\n" }.join)
|
|
17
|
+
|
|
18
|
+
lists
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
# Keeps metadata inspection from supplying stale native build configuration.
|
|
7
|
+
module Baltix::Concerns::ExtensionMetadata
|
|
8
|
+
METADATA_OUTPUTS = %w[Makefile mkmf.log extconf.h].freeze
|
|
9
|
+
|
|
10
|
+
def preserve_extension_files directory
|
|
11
|
+
Dir.mktmpdir('baltix-extconf-') do |backup|
|
|
12
|
+
copy_extension_files(directory, backup)
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
clear_extension_files(directory)
|
|
16
|
+
yield
|
|
17
|
+
ensure
|
|
18
|
+
restore_extension_files(backup, directory)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def copy_extension_files source, destination
|
|
24
|
+
METADATA_OUTPUTS.each do |name|
|
|
25
|
+
file = File.join(source, name)
|
|
26
|
+
|
|
27
|
+
FileUtils.copy_entry(file, File.join(destination, name), true) if File.exist?(file) || File.symlink?(file)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def clear_extension_files directory
|
|
32
|
+
METADATA_OUTPUTS.each {|name| FileUtils.rm_f(File.join(directory, name)) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def restore_extension_files source, destination
|
|
36
|
+
METADATA_OUTPUTS.each do |name|
|
|
37
|
+
file = File.join(source, name)
|
|
38
|
+
output = File.join(destination, name)
|
|
39
|
+
|
|
40
|
+
FileUtils.rm_f(output)
|
|
41
|
+
FileUtils.copy_entry(file, output, true) if File.exist?(file) || File.symlink?(file)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
# Prepares a file destination without removing directories or following old symlinks.
|
|
6
|
+
module Baltix::Concerns::FileDestination
|
|
7
|
+
def prepare_file_destination file
|
|
8
|
+
raise(Errno::EISDIR, file) if File.directory?(file) && !File.symlink?(file)
|
|
9
|
+
|
|
10
|
+
FileUtils.mkdir_p(File.dirname(file))
|
|
11
|
+
|
|
12
|
+
FileUtils.rm_f(file) if File.symlink?(file)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Keeps machine-readable action output separate from source inspection logs.
|
|
4
|
+
module Baltix::Concerns::Inspection
|
|
5
|
+
def context_kind
|
|
6
|
+
Baltix::Space
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def inspect_space space
|
|
10
|
+
previous = Baltix::Log.ios[:info]
|
|
11
|
+
|
|
12
|
+
Baltix::Log.ios[:info] = $stderr if previous == $stdout
|
|
13
|
+
|
|
14
|
+
space.prepare
|
|
15
|
+
yield
|
|
16
|
+
ensure
|
|
17
|
+
Baltix::Log.ios[:info] = previous
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def write_output space, body
|
|
21
|
+
if space.options.output_file
|
|
22
|
+
File.write(space.options.output_file, body)
|
|
23
|
+
else
|
|
24
|
+
$stdout.write(body)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Applies the same explicitly selected optional parts to execution actions.
|
|
4
|
+
module Baltix::Concerns::Parts
|
|
5
|
+
def part_enabled? options, part
|
|
6
|
+
return false if options[:"no_#{part}"]
|
|
7
|
+
|
|
8
|
+
selected = options.with_parts
|
|
9
|
+
|
|
10
|
+
selected.nil? || selected_parts(selected).include?(part.to_s)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def selected_parts value
|
|
14
|
+
Array(value).flat_map {|entry| entry.to_s.split(',').map(&:strip) }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Provides explicit source/configuration context shared by installation actors.
|
|
4
|
+
module Baltix::Concerns::TargetPaths
|
|
5
|
+
attr_reader :source, :options
|
|
6
|
+
|
|
7
|
+
def initialize source, options
|
|
8
|
+
@source = source
|
|
9
|
+
@options = options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def root
|
|
13
|
+
chroot
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def chroot
|
|
17
|
+
File.expand_path(options.install_prefix || options.buildroot || '/')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def mandir
|
|
21
|
+
options.mandir || RbConfig::CONFIG['mandir']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def manual_part
|
|
25
|
+
public_executables.any? ? :exec : :doc
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def optional_build_dependencies
|
|
29
|
+
source.build_tool_dependencies.map {|dependency| [dependency.name, manual_part] }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def incdir
|
|
33
|
+
options.includedir || RbConfig::CONFIG['includedir']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def public_bindir
|
|
37
|
+
options.bindir || RbConfig::CONFIG['bindir']
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def public_executables
|
|
41
|
+
source.is_a?(Baltix::Source::Gem) ? source.executables.map {|name| File.join(public_bindir, name) } : []
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def appdir
|
|
45
|
+
datadir
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
alias testdir appdir
|
|
49
|
+
alias supdir appdir
|
|
50
|
+
alias confdir appdir
|
|
51
|
+
alias logdir appdir
|
|
52
|
+
alias statedir appdir
|
|
53
|
+
|
|
54
|
+
def staged path
|
|
55
|
+
File.join(chroot, path.delete_prefix('/'))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Shared behavior composed into the source/target action objects.
|
|
4
|
+
module Baltix::Concerns
|
|
5
|
+
autoload :Configuration, 'baltix/concerns/configuration'
|
|
6
|
+
autoload :Command, 'baltix/concerns/command'
|
|
7
|
+
autoload :ExtensionMetadata, 'baltix/concerns/extension_metadata'
|
|
8
|
+
autoload :FileDestination, 'baltix/concerns/file_destination'
|
|
9
|
+
autoload :Parts, 'baltix/concerns/parts'
|
|
10
|
+
autoload :TargetPaths, 'baltix/concerns/target_paths'
|
|
11
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Retains Bundler groups, platforms and explicit version exclusions during dependency merging.
|
|
4
|
+
class Gem::Dependency
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def baltix_dependency_options dependency
|
|
8
|
+
result = { 'type' => :runtime, 'group' => (groups || []) | (dependency.groups || []) }
|
|
9
|
+
|
|
10
|
+
if respond_to?(:platforms) && dependency.respond_to?(:platforms)
|
|
11
|
+
result['platforms'] =
|
|
12
|
+
platforms & dependency.platforms
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
result
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def baltix_merged_requirement dependency
|
|
19
|
+
requirement = orig_merge(dependency).requirement
|
|
20
|
+
|
|
21
|
+
# Interval expansion cannot express holes: retain conjunctions containing !=.
|
|
22
|
+
requirement.requirements.any? {|operator, _| operator == '!=' } ? requirement : requirement.expand
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Expands requirement alternatives in the original operator and comparison order.
|
|
4
|
+
module Extensions::GemRequirement
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def baltix_expand_pass requirements
|
|
8
|
+
pending = requirements.dup
|
|
9
|
+
result = []
|
|
10
|
+
|
|
11
|
+
baltix_expand_pair(pending, result) until pending.empty?
|
|
12
|
+
|
|
13
|
+
result
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def baltix_expand_pair pending, result
|
|
17
|
+
left = pending.shift
|
|
18
|
+
right = pending.shift || left
|
|
19
|
+
operation = baltix_requirement_operation(left, right)
|
|
20
|
+
|
|
21
|
+
if operation
|
|
22
|
+
result.concat(operation[left.last, right.last])
|
|
23
|
+
elsif pending.empty?
|
|
24
|
+
result.push(left, right)
|
|
25
|
+
else
|
|
26
|
+
pending.unshift(right)
|
|
27
|
+
result.push(left)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def baltix_requirement_operation left, right
|
|
32
|
+
Gem::Requirement::OR_RELAS.find do |rule, _operation|
|
|
33
|
+
rule[0] == left.first && rule[1] == right.first &&
|
|
34
|
+
baltix_requirement_comparison?(rule[2], left.last, right.last)
|
|
35
|
+
end&.last
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def baltix_requirement_comparison? comparison, left, right
|
|
39
|
+
case comparison
|
|
40
|
+
when ::NilClass then true
|
|
41
|
+
when ::Integer then comparison == (left <=> right)
|
|
42
|
+
when ::Proc then comparison[left, right]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|