baltix 0.1.1
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 +7 -0
- data/.github/workflows/ci.yml +44 -0
- data/.gitignore +10 -0
- data/Gemfile +8 -0
- data/LICENSE +8 -0
- data/README.md +60 -0
- data/Rakefile +8 -0
- data/TODO +84 -0
- data/baltix.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/baltix +4 -0
- data/lib/baltix/actor/copy.rb +19 -0
- data/lib/baltix/actor/link.rb +20 -0
- data/lib/baltix/actor/spec.rb +25 -0
- data/lib/baltix/actor/touch.rb +17 -0
- data/lib/baltix/actor.rb +75 -0
- data/lib/baltix/cli.rb +173 -0
- data/lib/baltix/deps.rb +280 -0
- data/lib/baltix/dsl.rb +311 -0
- data/lib/baltix/extensions.rb +536 -0
- data/lib/baltix/i18n.rb +64 -0
- data/lib/baltix/loader/cmake.rb +11 -0
- data/lib/baltix/loader/git-version-gen.rb +36 -0
- data/lib/baltix/loader/mast.rb +139 -0
- data/lib/baltix/loader/pom.rb +27 -0
- data/lib/baltix/loader/rookbook.rb +26 -0
- data/lib/baltix/loader/yaml.rb +18 -0
- data/lib/baltix/loader.rb +192 -0
- data/lib/baltix/log.rb +73 -0
- data/lib/baltix/rake.rb +57 -0
- data/lib/baltix/scheme.erb.yaml +20 -0
- data/lib/baltix/source/base.rb +438 -0
- data/lib/baltix/source/fake.rb +17 -0
- data/lib/baltix/source/gem.rb +407 -0
- data/lib/baltix/source/gemfile.rb +35 -0
- data/lib/baltix/source/rakefile.rb +24 -0
- data/lib/baltix/source.rb +57 -0
- data/lib/baltix/space/spec.rb +11 -0
- data/lib/baltix/space.rb +424 -0
- data/lib/baltix/spec/rpm/name.rb +155 -0
- data/lib/baltix/spec/rpm/parser.rb +412 -0
- data/lib/baltix/spec/rpm/secondary.rb +170 -0
- data/lib/baltix/spec/rpm/spec_core.rb +580 -0
- data/lib/baltix/spec/rpm.erb +188 -0
- data/lib/baltix/spec/rpm.rb +822 -0
- data/lib/baltix/spec.rb +48 -0
- data/lib/baltix/version.rb +3 -0
- data/lib/baltix.rb +19 -0
- data/locale/en_US.UTF-8.yaml +27 -0
- data/locale/ru_RU.UTF-8.yaml +23 -0
- metadata +216 -0
@@ -0,0 +1,822 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
require 'baltix/spec'
|
4
|
+
require 'baltix/i18n'
|
5
|
+
|
6
|
+
class Baltix::Spec::Rpm
|
7
|
+
attr_reader :spec, :comment, :space
|
8
|
+
|
9
|
+
%w(Name Parser Secondary SpecCore).reduce({}) do |types, name|
|
10
|
+
autoload(:"#{name}", File.dirname(__FILE__) + "/rpm/#{name.tableize.singularize}")
|
11
|
+
end
|
12
|
+
|
13
|
+
OPTIONS = %w(source conflicts uri vcs maintainer_name maintainer_email
|
14
|
+
source_files patches build_pre_requires context comment
|
15
|
+
readme executables ignored_names main_source dependencies
|
16
|
+
valid_sources available_gem_list rootdir aliased_names
|
17
|
+
time_stamp devel_dep_setup use_gem_version_list use_gem_obsolete_list)
|
18
|
+
|
19
|
+
PARTS = {
|
20
|
+
lib: nil,
|
21
|
+
exec: :has_executables?,
|
22
|
+
doc: :has_docs?,
|
23
|
+
devel: :has_devel?,
|
24
|
+
}
|
25
|
+
|
26
|
+
STATE_CHANGE_NAMES = %w(name version summaries licenses group uri vcs
|
27
|
+
packager build_arch source_files build_pre_requires descriptions secondaries
|
28
|
+
prep build install check file_list)
|
29
|
+
|
30
|
+
STATE = {
|
31
|
+
name: {
|
32
|
+
seq: %w(of_options of_state of_source of_default _name _global_rename),
|
33
|
+
default: "",
|
34
|
+
},
|
35
|
+
pre_name: {
|
36
|
+
seq: %w(of_options of_state of_default _pre_name),
|
37
|
+
default: "",
|
38
|
+
},
|
39
|
+
epoch: {
|
40
|
+
seq: %w(of_options of_source of_state),
|
41
|
+
default: nil,
|
42
|
+
},
|
43
|
+
version: {
|
44
|
+
seq: %w(of_options of_source of_state of_default _version),
|
45
|
+
default: ->(this) { this.options.time_stamp || Time.now.strftime("%Y%m%d") },
|
46
|
+
},
|
47
|
+
release: {
|
48
|
+
seq: %w(of_options of_state _release),
|
49
|
+
default: "alt1",
|
50
|
+
},
|
51
|
+
build_arch: {
|
52
|
+
seq: %w(of_options of_state of_source),
|
53
|
+
default: "noarch",
|
54
|
+
},
|
55
|
+
summaries: {
|
56
|
+
seq: %w(of_options of_state of_source of_default _summaries),
|
57
|
+
default: ""
|
58
|
+
},
|
59
|
+
group: {
|
60
|
+
seq: %w(of_options of_state of_source),
|
61
|
+
default: ->(this) { t("spec.rpm.#{this.kind}.group") },
|
62
|
+
},
|
63
|
+
requires: {
|
64
|
+
seq: %w(of_options of_state of_default _filter_out_obsolete _requires_plain_only _requires),
|
65
|
+
default: [],
|
66
|
+
},
|
67
|
+
conflicts: {
|
68
|
+
seq: %w(of_options of_state of_default _conflicts_plain_only _conflicts),
|
69
|
+
default: [],
|
70
|
+
},
|
71
|
+
provides: {
|
72
|
+
seq: %w(of_options of_state of_default _provides),
|
73
|
+
default: [],
|
74
|
+
},
|
75
|
+
obsoletes: {
|
76
|
+
seq: %w(of_options of_state of_default _obsoletes),
|
77
|
+
default: [],
|
78
|
+
},
|
79
|
+
file_list: {
|
80
|
+
seq: %w(of_options of_state of_source),
|
81
|
+
default: "",
|
82
|
+
},
|
83
|
+
licenses: {
|
84
|
+
seq: %w(of_options of_state _licenses),
|
85
|
+
default: [],
|
86
|
+
},
|
87
|
+
uri: {
|
88
|
+
seq: %w(of_options of_state of_source),
|
89
|
+
default: nil,
|
90
|
+
},
|
91
|
+
vcs: {
|
92
|
+
seq: %w(of_options of_state of_source _vcs),
|
93
|
+
default: nil,
|
94
|
+
},
|
95
|
+
packager: {
|
96
|
+
seq: %w(of_options of_state),
|
97
|
+
default: ->(this) do
|
98
|
+
OpenStruct.new(
|
99
|
+
name: this.options.maintainer_name || "Spec Author",
|
100
|
+
email: this.options.maintainer_email || "author@example.org"
|
101
|
+
)
|
102
|
+
end
|
103
|
+
},
|
104
|
+
source_files: {
|
105
|
+
seq: %w(of_options of_state of_default _source_files),
|
106
|
+
default: { "0": "%name-%version.tar" }.to_os,
|
107
|
+
},
|
108
|
+
patches: {
|
109
|
+
seq: %w(of_options of_state),
|
110
|
+
default: {}.to_os,
|
111
|
+
},
|
112
|
+
build_dependencies: {
|
113
|
+
seq: %w(of_options of_state of_default _build_dependencies _build_dependencies_sort),
|
114
|
+
default: [],
|
115
|
+
},
|
116
|
+
build_requires: {
|
117
|
+
seq: %w(of_options of_state of_default _filter_out_build_auto_requires _filter_out_obsolete _build_requires),
|
118
|
+
default: [],
|
119
|
+
},
|
120
|
+
build_conflicts: {
|
121
|
+
seq: %w(of_options of_state of_default _build_conflicts),
|
122
|
+
default: [],
|
123
|
+
},
|
124
|
+
build_pre_requires: {
|
125
|
+
seq: %w(of_options of_state of_default _build_pre_requires),
|
126
|
+
default: [ "rpm-build-ruby" ],
|
127
|
+
},
|
128
|
+
changes: {
|
129
|
+
seq: %w(of_options of_state of_source of_default _changes),
|
130
|
+
default: ->(this) do
|
131
|
+
version = this.version
|
132
|
+
description = Baltix::I18n.t("spec.rpm.change.new", binding: binding)
|
133
|
+
release = this.of_options(:release) || this.of_state(:release) || "alt1"
|
134
|
+
|
135
|
+
[ OpenStruct.new(
|
136
|
+
date: Date.today.strftime("%a %b %d %Y"),
|
137
|
+
author: this.packager.name,
|
138
|
+
email: this.packager.email,
|
139
|
+
version: version,
|
140
|
+
release: release,
|
141
|
+
description: description) ]
|
142
|
+
end,
|
143
|
+
},
|
144
|
+
prep: {
|
145
|
+
seq: %w(of_options of_state),
|
146
|
+
default: "%setup",
|
147
|
+
},
|
148
|
+
build: {
|
149
|
+
seq: %w(of_options of_state),
|
150
|
+
default: "%ruby_build",
|
151
|
+
},
|
152
|
+
install: {
|
153
|
+
seq: %w(of_options of_state),
|
154
|
+
default: "%ruby_install",
|
155
|
+
},
|
156
|
+
check: {
|
157
|
+
seq: %w(of_options of_state),
|
158
|
+
default: "%ruby_test",
|
159
|
+
},
|
160
|
+
secondaries: {
|
161
|
+
seq: %w(of_options of_state of_default _secondaries),
|
162
|
+
default: [],
|
163
|
+
},
|
164
|
+
context: {
|
165
|
+
seq: %w(of_options of_state),
|
166
|
+
default: {},
|
167
|
+
},
|
168
|
+
comment: {
|
169
|
+
seq: %w(of_options of_state),
|
170
|
+
default: nil,
|
171
|
+
},
|
172
|
+
spec_template: {
|
173
|
+
seq: %w(of_options of_state),
|
174
|
+
default: ->(_) { IO.read(File.join(File.dirname(__FILE__), "rpm.erb")) },
|
175
|
+
},
|
176
|
+
compilables: {
|
177
|
+
seq: %w(of_options of_state of_source),
|
178
|
+
default: [],
|
179
|
+
},
|
180
|
+
descriptions: {
|
181
|
+
seq: %w(of_options of_state of_source of_default _proceed_description _descriptions _format_descriptions),
|
182
|
+
default: {}.to_os
|
183
|
+
},
|
184
|
+
valid_sources: {
|
185
|
+
seq: %w(of_state of_space of_default),
|
186
|
+
default: []
|
187
|
+
},
|
188
|
+
readme: {
|
189
|
+
seq: %w(of_options of_source _readme of_state),
|
190
|
+
default: nil,
|
191
|
+
},
|
192
|
+
executables: {
|
193
|
+
seq: %w(of_options of_source of_state),
|
194
|
+
default: [],
|
195
|
+
},
|
196
|
+
docs: {
|
197
|
+
seq: %w(of_options _docs of_state),
|
198
|
+
default: nil,
|
199
|
+
},
|
200
|
+
devel: {
|
201
|
+
seq: %w(of_options _devel of_state),
|
202
|
+
default: nil,
|
203
|
+
},
|
204
|
+
devel_requires: {
|
205
|
+
seq: %w(of_options of_state _devel_requires),
|
206
|
+
default: nil,
|
207
|
+
},
|
208
|
+
devel_conflicts: {
|
209
|
+
seq: %w(of_options of_state _devel_conflicts),
|
210
|
+
default: nil,
|
211
|
+
},
|
212
|
+
devel_sources: {
|
213
|
+
seq: %w(of_options _devel_sources of_state),
|
214
|
+
default: [],
|
215
|
+
},
|
216
|
+
files: {
|
217
|
+
seq: %w(of_options _files of_state),
|
218
|
+
default: []
|
219
|
+
},
|
220
|
+
dependencies: {
|
221
|
+
seq: %w(of_options of_state of_source),
|
222
|
+
default: []
|
223
|
+
},
|
224
|
+
development_dependencies: {
|
225
|
+
seq: %w(of_options of_state of_source),
|
226
|
+
default: []
|
227
|
+
},
|
228
|
+
ruby_alias_names: {
|
229
|
+
seq: %w(of_options of_state _ruby_alias_names _ruby_alias_names_local),
|
230
|
+
default: []
|
231
|
+
},
|
232
|
+
gem_versionings: {
|
233
|
+
seq: %w(of_options of_state _gem_versionings_with_use),
|
234
|
+
default: []
|
235
|
+
},
|
236
|
+
ignored_names: {
|
237
|
+
seq: %w(of_options of_state),
|
238
|
+
default: []
|
239
|
+
},
|
240
|
+
aliased_names: {
|
241
|
+
seq: %w(of_options of_state),
|
242
|
+
default: []
|
243
|
+
},
|
244
|
+
available_gem_list: {
|
245
|
+
seq: %w(of_options of_state _available_gem_list),
|
246
|
+
default: {}
|
247
|
+
},
|
248
|
+
versioned_gem_list: {
|
249
|
+
seq: %w(of_options of_state _versioned_gem_list),
|
250
|
+
default: {}
|
251
|
+
},
|
252
|
+
available_gem_ranges: {
|
253
|
+
seq: %w(of_options of_state _available_gem_ranges),
|
254
|
+
default: {}.to_os
|
255
|
+
},
|
256
|
+
use_gem_version_list: {
|
257
|
+
seq: %w(of_options of_state _use_gem_version_list),
|
258
|
+
default: {}.to_os
|
259
|
+
},
|
260
|
+
use_gem_obsolete_list: {
|
261
|
+
seq: %w(of_options of_state),
|
262
|
+
default: {}.to_os
|
263
|
+
},
|
264
|
+
rootdir: {
|
265
|
+
seq: %w(of_options of_state),
|
266
|
+
default: nil
|
267
|
+
},
|
268
|
+
rake_build_tasks: {
|
269
|
+
seq: %w(of_options of_source of_state of_default _rake_build_tasks),
|
270
|
+
default: ""
|
271
|
+
}
|
272
|
+
}.to_os(hash: true)
|
273
|
+
|
274
|
+
include Baltix::Spec::Rpm::SpecCore
|
275
|
+
include Baltix::I18n
|
276
|
+
|
277
|
+
def render spec = nil
|
278
|
+
b = binding
|
279
|
+
|
280
|
+
ERB.new(spec || spec_template, trim_mode: "<>-", eoutvar: "@spec").result(b).strip
|
281
|
+
end
|
282
|
+
|
283
|
+
def macros name
|
284
|
+
[ context.__macros[name] ].flatten(1).map { |x| "%#{name} #{x}" }.join("\n")
|
285
|
+
end
|
286
|
+
|
287
|
+
def is_same_source? source_in
|
288
|
+
source_in && source == source_in
|
289
|
+
end
|
290
|
+
|
291
|
+
def kind
|
292
|
+
@kind ||= source.is_a?(Baltix::Source::Gem) && :lib || :app
|
293
|
+
end
|
294
|
+
|
295
|
+
def state_kind
|
296
|
+
@state_kind ||= options.main_source.is_a?(Baltix::Source::Gem) && "lib" || state['file_list'].blank? && "app" || pre_name&.kind
|
297
|
+
end
|
298
|
+
|
299
|
+
def default_state_kind
|
300
|
+
"app"
|
301
|
+
end
|
302
|
+
|
303
|
+
def assign_space space
|
304
|
+
@space = space
|
305
|
+
|
306
|
+
#TODO clean variables
|
307
|
+
|
308
|
+
space
|
309
|
+
end
|
310
|
+
|
311
|
+
# +assign_state_sources+ infers all the unassigned state to convert to sources main and secondaries from the state
|
312
|
+
def assign_state_to_sources sources
|
313
|
+
packages = [ self ] | of_state(:secondaries)
|
314
|
+
|
315
|
+
packages.map do |package|
|
316
|
+
# binding.pry
|
317
|
+
package.options&.main_source ||
|
318
|
+
case package.state_kind || package.name.kind || default_state_kind
|
319
|
+
when "lib"
|
320
|
+
spec = Gem::Specification.new do |s|
|
321
|
+
s.name = package.name.autoname
|
322
|
+
s.version, s.summary =
|
323
|
+
if package.state
|
324
|
+
[ package.state["version"], package.state["summaries"]&.[]("") ]
|
325
|
+
elsif package.source
|
326
|
+
[ package.source.version, package.source.summary ]
|
327
|
+
else
|
328
|
+
[ package.version, package.summaries&.[]("") ]
|
329
|
+
end
|
330
|
+
end
|
331
|
+
# binding.pry
|
332
|
+
|
333
|
+
Baltix::Source::Gem.new({"spec" => spec})
|
334
|
+
when "app"
|
335
|
+
#name = package.of_options(:name) ||
|
336
|
+
# package.of_state(:name) ||
|
337
|
+
# rootdir && rootdir.split("/").last
|
338
|
+
name = package.pre_name
|
339
|
+
|
340
|
+
Baltix::Source::Gemfile.new({
|
341
|
+
"rootdir" => rootdir,
|
342
|
+
"name" => name.to_s,
|
343
|
+
"version" => of_options(:version) || of_state(:version)
|
344
|
+
})
|
345
|
+
end
|
346
|
+
end.compact
|
347
|
+
end
|
348
|
+
|
349
|
+
def state_sources
|
350
|
+
packages = [ self ] | (of_state(:secondaries) || of_default(:secondaries))
|
351
|
+
|
352
|
+
packages.map do |package|
|
353
|
+
package.options&.main_source ||
|
354
|
+
case package.state_kind || package.name.kind || default_state_kind
|
355
|
+
when "lib"
|
356
|
+
#binding.pry
|
357
|
+
spec = Gem::Specification.new do |s|
|
358
|
+
s.name = (package.is_a?(OpenStruct) ? package.name : package.pre_name).autoname
|
359
|
+
s.version, s.summary =
|
360
|
+
if package.state
|
361
|
+
[ package.state["version"], package.state["summaries"]&.[]("") ]
|
362
|
+
elsif package.source
|
363
|
+
[ package.source.version, package.source.summary ]
|
364
|
+
else
|
365
|
+
[ package.version, package.summaries&.[]("") ]
|
366
|
+
end
|
367
|
+
end
|
368
|
+
# binding.pry
|
369
|
+
|
370
|
+
Baltix::Source::Gem.new({"spec" => spec})
|
371
|
+
when "app"
|
372
|
+
#name = package.of_options(:name) ||
|
373
|
+
# package.of_state(:name) ||
|
374
|
+
# rootdir && rootdir.split("/").last
|
375
|
+
name = package.pre_name
|
376
|
+
|
377
|
+
if rootdir
|
378
|
+
Baltix::Source::Gemfile.new({
|
379
|
+
"rootdir" => rootdir,
|
380
|
+
"name" => name.to_s,
|
381
|
+
"version" => of_options(:version) || of_state(:version)
|
382
|
+
})
|
383
|
+
elsif space&.valid_sources&.first
|
384
|
+
space&.valid_sources&.first
|
385
|
+
else
|
386
|
+
Baltix::Source::Fake.new({
|
387
|
+
"rootdir" => rootdir,
|
388
|
+
"name" => name.to_s,
|
389
|
+
"version" => of_options(:version) || of_state(:version)
|
390
|
+
})
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end.compact
|
394
|
+
end
|
395
|
+
|
396
|
+
def pure_build_requires
|
397
|
+
build_requires.select {|r| r !~ /^gem\(.*\)/ }
|
398
|
+
end
|
399
|
+
|
400
|
+
def pure_build_conflicts
|
401
|
+
build_conflicts.select {|r| r !~ /^gem\(.*\)/ }
|
402
|
+
end
|
403
|
+
|
404
|
+
def gem_build_requires
|
405
|
+
build_requires.select {|r| r =~ /^gem\(.*\)/ }
|
406
|
+
end
|
407
|
+
|
408
|
+
def gem_build_conflicts
|
409
|
+
build_conflicts.select {|r| r =~ /^gem\(.*\)/ }
|
410
|
+
end
|
411
|
+
|
412
|
+
def has_gem_build_requires?
|
413
|
+
gem_build_requires.any?
|
414
|
+
end
|
415
|
+
|
416
|
+
def has_gem_build_conflicts?
|
417
|
+
gem_build_conflicts.any?
|
418
|
+
end
|
419
|
+
|
420
|
+
def source
|
421
|
+
@source ||= space&.main_source || sources.find {|source_in| pre_name == source_in.name }
|
422
|
+
end
|
423
|
+
|
424
|
+
def sources
|
425
|
+
@sources ||=
|
426
|
+
state_sources.reduce(valid_sources) do |res, source_in|
|
427
|
+
ignore = ignored_names.any? { |x| x === source_in.name }
|
428
|
+
|
429
|
+
ignore || res.find { |x| Name.parse(x.name) == Name.parse(source_in.name) } ? res : res | [ source_in ]
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def valid_secondaries
|
434
|
+
@valid_secondaries ||= secondaries.select do |s|
|
435
|
+
s.source&.source_file
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
protected
|
440
|
+
|
441
|
+
def ruby_build
|
442
|
+
@ruby_build ||= variables.ruby_build&.split(/\s+/) || []
|
443
|
+
end
|
444
|
+
|
445
|
+
def _versioned_gem_list value_in
|
446
|
+
dep_list = dep_list_intersect(value_in.to_os, available_gem_ranges, gem_versionings)
|
447
|
+
|
448
|
+
dep_list.select do |n, dep_in|
|
449
|
+
dependencies.select { |dep| dep.name == n.to_s }.any? do |dep|
|
450
|
+
dep_ver = combine_deps(dep, dep_in)
|
451
|
+
dep_ver.requirement.requirements != dep.requirement.expand.requirements
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
def _global_rename value_in
|
457
|
+
case source
|
458
|
+
when Baltix::Source::Gem
|
459
|
+
value_in.class.parse(value_in, prefix: value_in.class.default_prefix)
|
460
|
+
when Baltix::Source::Gemfile, Baltix::Source::Rakefile
|
461
|
+
value_in.class.parse(value_in, prefix: nil, kind: "app", name: value_in.original_fullname)
|
462
|
+
else
|
463
|
+
value_in
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
def _gem_versionings_with_use value_in
|
468
|
+
dep_list_merge(_gem_versionings(value_in), use_gem_version_list)
|
469
|
+
end
|
470
|
+
|
471
|
+
def _ruby_alias_names value_in
|
472
|
+
@ruby_alias_names ||= (value_in || []) | ruby_build.reduce([]) do |res, line|
|
473
|
+
case line
|
474
|
+
when /--use=(.*)/
|
475
|
+
res << [ $1 ]
|
476
|
+
when /--alias=(.*)/
|
477
|
+
res.last << $1
|
478
|
+
end
|
479
|
+
|
480
|
+
res
|
481
|
+
end.map do |aliases|
|
482
|
+
aliases |
|
483
|
+
[ aliased_names, [ autoaliases ]].map do |a|
|
484
|
+
a.reject { |x| (x & aliases).blank? }
|
485
|
+
end.flatten
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
def autoaliases
|
490
|
+
@autoaliases =
|
491
|
+
[ secondaries.map do |sec|
|
492
|
+
sec.name.name
|
493
|
+
end, secondaries.map do |sec|
|
494
|
+
sec.name.support_name&.name
|
495
|
+
end ].transpose.select do |x|
|
496
|
+
x.compact.uniq.size > 1
|
497
|
+
end.flatten
|
498
|
+
end
|
499
|
+
|
500
|
+
def _ruby_alias_names_local value_in
|
501
|
+
return @ruby_alias_names_local if @ruby_alias_names_local
|
502
|
+
|
503
|
+
names =
|
504
|
+
if source.kind_of?(Baltix::Source::Gem)
|
505
|
+
[ source&.name, name&.name ]
|
506
|
+
else
|
507
|
+
[ source&.name, name&.fullname ]
|
508
|
+
end.compact.uniq
|
509
|
+
|
510
|
+
@ruby_alias_names_local = value_in | (names.size > 1 && [ names ] || [])
|
511
|
+
end
|
512
|
+
|
513
|
+
def _use_gem_version_list value_in
|
514
|
+
value_in && value_in.map do |name, v|
|
515
|
+
Gem::Dependency.new(name.to_s, Gem::Requirement.new(v))
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def _secondaries value_in
|
520
|
+
names = value_in.map { |x| x.name }
|
521
|
+
|
522
|
+
# binding.pry
|
523
|
+
to_ignore = (names | [source&.name] | ignored_names).compact
|
524
|
+
secondaries = sources.reject do |source_in|
|
525
|
+
to_ignore.any? { |i| i === source_in.name }
|
526
|
+
end.map do |source|
|
527
|
+
sec = Secondary.new(source: source,
|
528
|
+
spec: self,
|
529
|
+
state: { context: context },
|
530
|
+
options: { name_prefix: name.prefix,
|
531
|
+
gem_versionings: gem_versionings,
|
532
|
+
available_gem_list: available_gem_list })
|
533
|
+
|
534
|
+
secondary_parts_for(sec, source)
|
535
|
+
end.concat(secondary_parts_for(self, source, )).flatten.uniq {|x| x.name.fullname }
|
536
|
+
|
537
|
+
# secondaries = secondaries.map do |sec|
|
538
|
+
# if presec = names.delete(sec.name)
|
539
|
+
# sub_sec = of_state(:secondaries).find do |osec|
|
540
|
+
# osec.name == presec
|
541
|
+
# end
|
542
|
+
#
|
543
|
+
# if sub_sec.is_a?(Secondary)
|
544
|
+
# sub_sec.resourced_from(sec)
|
545
|
+
# elsif sub_sec.is_a?(OpenStruct)
|
546
|
+
# #sec.state = sub_sec
|
547
|
+
# binding.pry
|
548
|
+
# sec
|
549
|
+
# end
|
550
|
+
# else
|
551
|
+
# sec
|
552
|
+
# end
|
553
|
+
# end
|
554
|
+
#
|
555
|
+
#binding.pry
|
556
|
+
secondaries =
|
557
|
+
names.reduce(secondaries) do |secs, an|
|
558
|
+
next secs if secs.find { |sec| sec.name == an }
|
559
|
+
sec = value_in.find { |sec| sec.name == an }
|
560
|
+
|
561
|
+
if sec.is_a?(Secondary)
|
562
|
+
secs | [sec]
|
563
|
+
elsif sec.is_a?(OpenStruct)
|
564
|
+
source = sources.find { |s| sec.name == s.name }
|
565
|
+
host = secs.find { |sec_in| sec_in.name.eql_by?(:name, sec.name) }
|
566
|
+
|
567
|
+
secs | [Secondary.new(spec: self,
|
568
|
+
kind: sec.name.kind,#an.kind
|
569
|
+
host: host,
|
570
|
+
state: sec,
|
571
|
+
source: source,
|
572
|
+
options: { name: sec.name,
|
573
|
+
gem_versionings: gem_versionings,
|
574
|
+
available_gem_list: available_gem_list })]
|
575
|
+
else
|
576
|
+
secs
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
#binding.pry
|
581
|
+
secondaries.select do |sec|
|
582
|
+
sec.kind != :devel || options.devel_dep_setup != :skip
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
def _build_dependencies value_in
|
587
|
+
deps_pre = value_in.map do |dep|
|
588
|
+
if !m = dep.match(/gem\((.*)\) ([>=<]+) ([\w\d\.\-]+)/)
|
589
|
+
dep
|
590
|
+
#Gem::Dependency.new(m[1], Gem::Requirement.new(["#{m[2]} #{m[3]}"]), :runtime)
|
591
|
+
end
|
592
|
+
end.compact | development_dependencies
|
593
|
+
|
594
|
+
dep_hash = deps_pre.group_by {|x|x.name}.map {|n, x| [n, x.reduce {|res, y| res.merge(y) } ] }.to_h
|
595
|
+
deps_all = secondaries.reduce(dep_hash.dup) do |res, x|
|
596
|
+
next res unless x.source# && !provide_names.any? {|y|x.name === y}
|
597
|
+
|
598
|
+
x.source.deps.reduce(res.dup) do |r, x|
|
599
|
+
r[x.name] = r[x.name] ? r[x.name].merge(x) : x
|
600
|
+
|
601
|
+
r
|
602
|
+
end
|
603
|
+
end.values
|
604
|
+
|
605
|
+
#TODO move fo filter options
|
606
|
+
provide_names = secondaries.filter_map { |x| x.source&.provide&.name }.uniq
|
607
|
+
filtered = replace_versioning(deps_all).reject do |dep|
|
608
|
+
if dep.is_a?(Gem::Dependency)
|
609
|
+
dep.type == :development && options.devel_dep_setup == :skip || provide_names.include?(dep.name)
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
613
|
+
reqs =
|
614
|
+
append_versioning(filtered).reject do |n_in|
|
615
|
+
n = n_in.is_a?(Gem::Dependency) && n_in.name || n_in
|
616
|
+
name.eql?(n, true)
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
def _build_dependencies_sort value_in
|
621
|
+
value_in.sort
|
622
|
+
end
|
623
|
+
|
624
|
+
def _filter_out_build_auto_requires value_in
|
625
|
+
value_in.reject do |value|
|
626
|
+
value.is_a?(String) and /^(#{Baltix::Spec::Rpm::Name::PREFICES.join('|')})[\-(]/ =~ value
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
def _build_requires value_in
|
631
|
+
render_deps(build_dependencies) | value_in
|
632
|
+
end
|
633
|
+
|
634
|
+
def _build_conflicts value_in
|
635
|
+
render_deps(build_dependencies, :negate)
|
636
|
+
end
|
637
|
+
|
638
|
+
def _vcs value_in
|
639
|
+
pre = URL_MATCHER.reduce(value_in) do |res, (rule, e)|
|
640
|
+
res || uri && (match = uri.match(rule)) && e[match] || nil
|
641
|
+
end
|
642
|
+
vcs = /github.com/ =~ pre.to_s && pre.gsub(/http:/, "https:") || pre
|
643
|
+
|
644
|
+
vcs && "#{vcs}#{/\.git/ !~ vcs && ".git" || ""}".downcase || nil
|
645
|
+
end
|
646
|
+
|
647
|
+
def _source_files value_in
|
648
|
+
source_files = value_in.dup
|
649
|
+
defaults = of_default(:source_files)[:"0"]
|
650
|
+
|
651
|
+
source_files[:"0"] = defaults if source_files[:"0"] != defaults
|
652
|
+
|
653
|
+
source_files
|
654
|
+
end
|
655
|
+
|
656
|
+
def _build_pre_requires value_in
|
657
|
+
build_pre_requires = value_in.dup || []
|
658
|
+
stated_name = of_state(:name)
|
659
|
+
|
660
|
+
if stated_name && stated_name.prefix != name.prefix
|
661
|
+
default = of_default(:build_pre_requires)[0]
|
662
|
+
|
663
|
+
build_pre_requires.unshift(default) unless build_pre_requires.include?(default)
|
664
|
+
end
|
665
|
+
|
666
|
+
build_pre_requires
|
667
|
+
end
|
668
|
+
|
669
|
+
def _licenses value_in
|
670
|
+
list = sources.map do |source|
|
671
|
+
source.licenses
|
672
|
+
end.flatten.uniq
|
673
|
+
|
674
|
+
!list.blank? && list || value_in.blank? && ["Unlicense"] || value_in
|
675
|
+
end
|
676
|
+
|
677
|
+
def state_changed?
|
678
|
+
@state_changed = STATE_CHANGE_NAMES.any? do |property|
|
679
|
+
if property == "secondary"
|
680
|
+
[ of_state(property), self.send(property) ].transpose.any? do |(first, second)|
|
681
|
+
first.name != second.name
|
682
|
+
end
|
683
|
+
else
|
684
|
+
of_state(property) != self.send(property)
|
685
|
+
end
|
686
|
+
#
|
687
|
+
# when String, Name, Gem::Version, NilClass,
|
688
|
+
# binding.prya
|
689
|
+
# when Array
|
690
|
+
# binding.pry
|
691
|
+
# of_state(property) == self.send(property)
|
692
|
+
# when OpenStruct
|
693
|
+
# binding.pry
|
694
|
+
# of_state(property) == self.send(property)
|
695
|
+
# else
|
696
|
+
# binding.pry
|
697
|
+
# end
|
698
|
+
#
|
699
|
+
# true
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
def _changes value_in
|
704
|
+
new_change =
|
705
|
+
if of_state(:version)
|
706
|
+
if self.version != of_state(:version)
|
707
|
+
# TODO move to i18n and settings file
|
708
|
+
previous_version = of_state(:version)
|
709
|
+
version = self.version
|
710
|
+
description = t("spec.rpm.change.upgrade", binding: binding)
|
711
|
+
release = "alt1"
|
712
|
+
elsif state_changed?
|
713
|
+
version = self.version
|
714
|
+
description = t("spec.rpm.change.fix", binding: binding)
|
715
|
+
release_version_bump =
|
716
|
+
# TODO suffix
|
717
|
+
/alt(?<release_version>.*)/ =~ of_state(:release)
|
718
|
+
release_version_bump =
|
719
|
+
if release_version && release_version.split(".").size > 1
|
720
|
+
Gem::Version.new(release_version).bump.to_s
|
721
|
+
elsif release_version
|
722
|
+
release_version + '.1'
|
723
|
+
else
|
724
|
+
"1"
|
725
|
+
end
|
726
|
+
release = "alt" + release_version_bump
|
727
|
+
end
|
728
|
+
|
729
|
+
packager_name = options.maintainer_name || packager.name
|
730
|
+
packager_email = options.maintainer_email || packager.email
|
731
|
+
OpenStruct.new(
|
732
|
+
date: Date.today.strftime("%a %b %d %Y"),
|
733
|
+
author: packager_name,
|
734
|
+
email: packager_email,
|
735
|
+
epoch: epoch,
|
736
|
+
version: version,
|
737
|
+
release: release,
|
738
|
+
description: description
|
739
|
+
)
|
740
|
+
end
|
741
|
+
|
742
|
+
value_in | [ new_change ].compact
|
743
|
+
end
|
744
|
+
|
745
|
+
def _release value_in
|
746
|
+
changes.last.release
|
747
|
+
end
|
748
|
+
|
749
|
+
def _rake_build_tasks value_in
|
750
|
+
/--pre=(?<list>[^\s]*)/ =~ %w(context __macros ruby_build).reduce(state) {|r, a| r&.[](a) }
|
751
|
+
|
752
|
+
value_in.split(",") | (of_state(:ruby_on_build_rake_tasks) || list || "").split(",")
|
753
|
+
end
|
754
|
+
|
755
|
+
def secondary_parts_for object, source
|
756
|
+
context_in = { context: context }.to_os
|
757
|
+
secondaries_in = of_state(:secondaries) || []
|
758
|
+
a=
|
759
|
+
PARTS.map do |(kind, func)|
|
760
|
+
next object.is_a?(Secondary) && object || nil if !func
|
761
|
+
|
762
|
+
if object.send(func)
|
763
|
+
# secondaries = secondaries.map do |sec|
|
764
|
+
# if presec = names.delete(sec.name)
|
765
|
+
# sub_sec = of_state(:secondaries).find do |osec|
|
766
|
+
# osec.name == presec
|
767
|
+
# end
|
768
|
+
#
|
769
|
+
# if sub_sec.is_a?(Secondary)
|
770
|
+
# sub_sec.resourced_from(sec)
|
771
|
+
# elsif sub_sec.is_a?(OpenStruct)
|
772
|
+
# #sec.state = sub_sec
|
773
|
+
# binding.pry
|
774
|
+
# sec
|
775
|
+
# end
|
776
|
+
# else
|
777
|
+
# sec
|
778
|
+
# end
|
779
|
+
# end
|
780
|
+
presec =
|
781
|
+
Secondary.new(source: source,
|
782
|
+
spec: self,
|
783
|
+
kind: kind,
|
784
|
+
host: object,
|
785
|
+
state: context_in,
|
786
|
+
options: { name_prefix: kind != :exec && name.prefix || nil,
|
787
|
+
gem_versionings: gem_versionings,
|
788
|
+
available_gem_list: available_gem_list })
|
789
|
+
|
790
|
+
state = secondaries_in.find { |osec| osec.name == presec }
|
791
|
+
presec.state = state if state
|
792
|
+
|
793
|
+
presec
|
794
|
+
end
|
795
|
+
end.compact
|
796
|
+
a
|
797
|
+
end
|
798
|
+
|
799
|
+
def initialize state: {}, options: {}, space: nil
|
800
|
+
@state = state
|
801
|
+
@options = options.to_os.merge(space.options)
|
802
|
+
@space = space || raise
|
803
|
+
end
|
804
|
+
|
805
|
+
class << self
|
806
|
+
def match? source_in
|
807
|
+
Parser.match?(source_in)
|
808
|
+
end
|
809
|
+
|
810
|
+
def parse source_in, options = {}.to_os, space = nil
|
811
|
+
state = Parser.new.parse(source_in, options)
|
812
|
+
space ||= options[:space]
|
813
|
+
|
814
|
+
Baltix::Spec::Rpm.new(state: state, options: options, space: space)
|
815
|
+
end
|
816
|
+
|
817
|
+
def render space, spec_in = nil
|
818
|
+
spec = space.spec || self.new(space: space)
|
819
|
+
spec.render(spec_in)
|
820
|
+
end
|
821
|
+
end
|
822
|
+
end
|