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,438 @@
|
|
1
|
+
require 'baltix/source'
|
2
|
+
require 'baltix/log'
|
3
|
+
|
4
|
+
class Baltix::Source::Base
|
5
|
+
extend ::Baltix::Log
|
6
|
+
|
7
|
+
OPTION_KEYS = %i(source_file source_names replace_list aliases alias_names)
|
8
|
+
|
9
|
+
DL_DIRS = ->(s) { ".so.#{s.name}#{RbConfig::CONFIG['sitearchdir']}" }
|
10
|
+
RI_DIRS = ->(s) { [ s.default_ridir, 'ri' ] }
|
11
|
+
INC_DIRS = %w(ext)
|
12
|
+
EXT_DIRS = %w(ext)
|
13
|
+
LIB_DIRS = %w(lib)
|
14
|
+
APP_DIRS = %w(app webpack script public)
|
15
|
+
EXE_DIRS = %w(bin exe)
|
16
|
+
CONF_DIRS = %w(etc config conf)
|
17
|
+
TEST_DIRS = %w(tests test spec features acceptance autotest)
|
18
|
+
MAN_DIRS = %w(doc docs Documentation man docs-source)
|
19
|
+
SUP_DIRS = %w(util yardoc benchmarks examples .git vendor sample)
|
20
|
+
LOG_DIRS = %w(log)
|
21
|
+
DATA_DIRS = %w(.)
|
22
|
+
STATE_DIRS = %w(tmp)
|
23
|
+
DOCSRC_DIRS = ->(s) { s.libdirs | s.appdirs | s.exedirs | s.confdirs }
|
24
|
+
|
25
|
+
DL_RE = ->(_) { /\.(#{RbConfig::CONFIG['DLEXT']}|build_complete)$/ }
|
26
|
+
RI_RE = /\.ri$/
|
27
|
+
INC_RE = /\.(h|hpp)$/
|
28
|
+
MAN_RE = /\.[1-8](.ronn)?$/
|
29
|
+
EXT_RE = /\b(.*\.rb|rakefile(\.rb)?)$/i
|
30
|
+
DATA_RE = ->(s) do
|
31
|
+
dirs = s.extdirs | s.libdirs | s.appdirs | s.exedirs |
|
32
|
+
s.confdirs | s.testdirs | s.mandirs | s.supdirs |
|
33
|
+
s.ridirs | s.dldirs | s.incdirs | s.logdirs | s.statedirs
|
34
|
+
|
35
|
+
dirs.empty? && /.*/ || /^(?!.*#{dirs.join('\b|').gsub('.', '\\\\.')}\b)/
|
36
|
+
end
|
37
|
+
DOCSRC_RE = /\.rb$/
|
38
|
+
|
39
|
+
GROUPS = constants.select { |c| c =~ /_DIRS/ }.map { |c| c.to_s.sub('_DIRS', '').downcase }
|
40
|
+
|
41
|
+
OPTIONS_IN = {
|
42
|
+
aliases: ->(o, name) { o.is_a?(Hash) && [ o[nil], o[name], o.values.map {|x|x.flatten}.select {|x|x.include?(name)}.map {|x|x.first}.flatten ].flatten.compact.uniq || o },
|
43
|
+
alias_names: ->(o, name) { o.is_a?(Hash) && [ o[nil], o[name], o.values.map {|x|x.flatten}.select {|x|x.include?(name)}.map {|x|x.first}.flatten ].flatten.compact.uniq || o },
|
44
|
+
version_replaces: true,
|
45
|
+
gem_version_replace: true,
|
46
|
+
source_file: ->(file, _name) { file.is_a?(String) && File.file?(file) && file || nil },
|
47
|
+
loader: true,
|
48
|
+
gemspec: true,
|
49
|
+
source_names: true,
|
50
|
+
name: true,
|
51
|
+
version: true,
|
52
|
+
"source-ri-folder-lists": :name_or_default,
|
53
|
+
"source-inc-folder-lists": :name_or_default,
|
54
|
+
"source-ext-folder-lists": :name_or_default,
|
55
|
+
"source-lib-folder-lists": :name_or_default,
|
56
|
+
"source-app-folder-lists": :name_or_default,
|
57
|
+
"source-exe-folder-lists": :name_or_default,
|
58
|
+
"source-conf-folder-lists": :name_or_default,
|
59
|
+
"source-test-folder-lists": :name_or_default,
|
60
|
+
"source-man-folder-lists": :name_or_default,
|
61
|
+
"source-sup-folder-lists": :name_or_default,
|
62
|
+
"source-data-folder-lists": :name_or_default,
|
63
|
+
"source-docsrc-folder-lists": :name_or_default,
|
64
|
+
"source-log-folder-lists": :name_or_default,
|
65
|
+
"source-state-folder-lists": :name_or_default,
|
66
|
+
"source-ri-folders": true,
|
67
|
+
"source-inc-folders": true,
|
68
|
+
"source-ext-folders": true,
|
69
|
+
"source-lib-folders": true,
|
70
|
+
"source-app-folders": true,
|
71
|
+
"source-exe-folders": true,
|
72
|
+
"source-conf-folders": true,
|
73
|
+
"source-test-folders": true,
|
74
|
+
"source-man-folders": true,
|
75
|
+
"source-sup-folders": true,
|
76
|
+
"source-data-folders": true,
|
77
|
+
"source-docsrc-folders": true,
|
78
|
+
"source-log-folders": true,
|
79
|
+
"source-state-folders": true,
|
80
|
+
}
|
81
|
+
|
82
|
+
attr_reader :options, :source_file, :loader
|
83
|
+
attr_writer :replace_list, :source_names
|
84
|
+
|
85
|
+
class << self
|
86
|
+
def opts
|
87
|
+
@opts ||= ancestors.reverse.map do |a|
|
88
|
+
a.constants.include?(:OPTIONS_IN) &&
|
89
|
+
a.const_get(:OPTIONS_IN).to_a ||
|
90
|
+
nil
|
91
|
+
end.compact.flatten(1).to_os
|
92
|
+
end
|
93
|
+
|
94
|
+
def name_for options_in
|
95
|
+
fullname = (options_in[:rootdir] || "").split('/').last
|
96
|
+
/^(?<name>.*)-([\d\.]+)$/ =~ fullname
|
97
|
+
name || fullname
|
98
|
+
end
|
99
|
+
|
100
|
+
def source_options options_in = {}.to_os
|
101
|
+
source_name = name_for(options_in)
|
102
|
+
|
103
|
+
opts.map do |name_in, rule|
|
104
|
+
value_in = options_in[name_in.to_s]
|
105
|
+
|
106
|
+
name, value = case rule
|
107
|
+
when true
|
108
|
+
[name_in, value_in]
|
109
|
+
when Proc
|
110
|
+
[name_in, rule[value_in, source_name] ]
|
111
|
+
when Symbol
|
112
|
+
method(rule)[value_in, name_in, source_name]
|
113
|
+
else
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
|
117
|
+
value
|
118
|
+
end.compact.to_os
|
119
|
+
end
|
120
|
+
|
121
|
+
def name_or_default value_in, name, source_name
|
122
|
+
value = value_in && (value_in[source_name] || value_in[nil]) || nil
|
123
|
+
|
124
|
+
value && [ name.make_singular, value ] || nil
|
125
|
+
end
|
126
|
+
|
127
|
+
def rootdir_or_default value_in, name, _
|
128
|
+
[ name, value_in || Dir.pwd ]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def options
|
133
|
+
@options ||= {}
|
134
|
+
end
|
135
|
+
|
136
|
+
# +fullname+ returns full name of the source, by default it is the name of the current folder,
|
137
|
+
# if it is the root folder the name is "root".
|
138
|
+
# A mixin can redefine the method to return the proper value
|
139
|
+
#
|
140
|
+
# source.name #=> "source_name"
|
141
|
+
#
|
142
|
+
def fullname
|
143
|
+
@fullname ||= rootdir.split('/').last || "root"
|
144
|
+
end
|
145
|
+
|
146
|
+
# +name+ returns dynamically detected name of the source base on the fullname,
|
147
|
+
# in case the fullname is detected in a format of <name-version>, the <name> is returned,
|
148
|
+
# otherwise the full name is returned itself.
|
149
|
+
# A mixin can redefine the method to return the proper value
|
150
|
+
#
|
151
|
+
# source.name #=> "source_name"
|
152
|
+
#
|
153
|
+
def name
|
154
|
+
return @name if @name
|
155
|
+
|
156
|
+
if /^(?<name>.*)-([\d\.]+)$/ =~ fullname
|
157
|
+
name
|
158
|
+
else
|
159
|
+
fullname || rootdir.split("/").last || "root"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# +version+ returns version of the source by default it is the daystamp for today,
|
164
|
+
# A subslass can redefine the method to return the proper value
|
165
|
+
#
|
166
|
+
# source.version #=> "20000101"
|
167
|
+
# source.version #=> "2.1.0"
|
168
|
+
#
|
169
|
+
def version
|
170
|
+
return @version if @version
|
171
|
+
|
172
|
+
if /-(?<version>[\d\.]+)$/ =~ fullname
|
173
|
+
version
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# ruby platform is default for non-gem sources
|
178
|
+
def platform
|
179
|
+
'ruby'
|
180
|
+
end
|
181
|
+
|
182
|
+
def rootdir
|
183
|
+
@rootdir ||= detect_root
|
184
|
+
end
|
185
|
+
|
186
|
+
def source_names
|
187
|
+
@source_names ||= options[:source_names] || source_file && [File.basename(source_file)] || []
|
188
|
+
end
|
189
|
+
|
190
|
+
def dsl
|
191
|
+
@dsl ||= options[:dsl] ||
|
192
|
+
Baltix::DSL.new(source_file,
|
193
|
+
spec: spec,
|
194
|
+
replace_list: replace_list,
|
195
|
+
skip_list: (options[:gem_skip_list] || []) | [name],
|
196
|
+
append_list: options[:gem_append_list])
|
197
|
+
end
|
198
|
+
|
199
|
+
def replace_list
|
200
|
+
@gem_version_replace ||= {}
|
201
|
+
end
|
202
|
+
|
203
|
+
def alias_names
|
204
|
+
@alias_names ||= options[:alias_names] || []
|
205
|
+
end
|
206
|
+
|
207
|
+
# dirs
|
208
|
+
#
|
209
|
+
GROUPS.each do |kind|
|
210
|
+
func = <<-DEF
|
211
|
+
def #{kind}dirs &block
|
212
|
+
@#{kind}dirs ||= dirs(:#{kind}, options[:src#{kind}dirs], &block)
|
213
|
+
end
|
214
|
+
DEF
|
215
|
+
|
216
|
+
eval(func)
|
217
|
+
end
|
218
|
+
|
219
|
+
# files
|
220
|
+
#
|
221
|
+
GROUPS.each do |kind|
|
222
|
+
func = <<-DEF
|
223
|
+
def #{kind}files &block
|
224
|
+
@#{kind}files ||= files(:#{kind}, &block)
|
225
|
+
end
|
226
|
+
DEF
|
227
|
+
|
228
|
+
eval(func)
|
229
|
+
end
|
230
|
+
|
231
|
+
# tree
|
232
|
+
#
|
233
|
+
GROUPS.each do |kind|
|
234
|
+
func = <<-DEF
|
235
|
+
def #{kind}tree &block
|
236
|
+
@#{kind}tree ||= tree(:#{kind}, &block)
|
237
|
+
end
|
238
|
+
DEF
|
239
|
+
|
240
|
+
eval(func)
|
241
|
+
end
|
242
|
+
|
243
|
+
# questionaries
|
244
|
+
|
245
|
+
def valid?
|
246
|
+
false
|
247
|
+
end
|
248
|
+
|
249
|
+
def compilable?
|
250
|
+
extfiles.any?
|
251
|
+
end
|
252
|
+
|
253
|
+
def to_os
|
254
|
+
options.merge(type: type, source_names: source_names)
|
255
|
+
end
|
256
|
+
|
257
|
+
def type
|
258
|
+
self.class.to_s.split('::').last.downcase
|
259
|
+
end
|
260
|
+
|
261
|
+
def required_ruby
|
262
|
+
dsl.required_ruby
|
263
|
+
end
|
264
|
+
|
265
|
+
def required_ruby_version
|
266
|
+
dsl.required_ruby_version
|
267
|
+
end
|
268
|
+
|
269
|
+
def required_rubygems_version
|
270
|
+
dsl.required_rubygems_version
|
271
|
+
end
|
272
|
+
|
273
|
+
def definition
|
274
|
+
dsl.definition
|
275
|
+
end
|
276
|
+
|
277
|
+
def deps groups_in = nil
|
278
|
+
dsl.deps_for(groups_in)
|
279
|
+
end
|
280
|
+
|
281
|
+
def has_name? name
|
282
|
+
self.name == name || alias_names.include?(name)
|
283
|
+
end
|
284
|
+
|
285
|
+
def if_file file
|
286
|
+
File.file?(File.join(rootdir, file)) && file || nil
|
287
|
+
end
|
288
|
+
|
289
|
+
def if_exist file
|
290
|
+
File.exist?(File.join(rootdir, file)) && file || nil
|
291
|
+
end
|
292
|
+
|
293
|
+
def if_dir dir
|
294
|
+
File.directory?(File.join(rootdir, dir)) && dir || nil
|
295
|
+
end
|
296
|
+
|
297
|
+
def default_ridir
|
298
|
+
".ri.#{name}"
|
299
|
+
end
|
300
|
+
|
301
|
+
def trees &block
|
302
|
+
GROUPS.map do |set|
|
303
|
+
yield(set, send("#{set}tree"))
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def compilables
|
308
|
+
# TODO make compilables from ext
|
309
|
+
extfiles
|
310
|
+
end
|
311
|
+
|
312
|
+
def provide
|
313
|
+
Gem::Dependency.new(name, "= #{version || "0"}")
|
314
|
+
end
|
315
|
+
|
316
|
+
# +summaries+ returns an open-struct formatted summaries with a default locale as a key
|
317
|
+
# in the spec defined if any, otherwise returns blank open struct.
|
318
|
+
#
|
319
|
+
# source.summaries # => #<OpenStruct en_US.UTF-8: ...>
|
320
|
+
#
|
321
|
+
def summaries
|
322
|
+
if spec&.summary
|
323
|
+
{ Baltix::I18n.default_locale => spec&.summary }.to_os
|
324
|
+
else
|
325
|
+
{}.to_os
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def dependencies *types
|
330
|
+
if definition
|
331
|
+
definition.dependencies.select {|dep| types.empty? || types.include?(dep.type) }
|
332
|
+
else
|
333
|
+
[]
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def development_dependencies
|
338
|
+
Baltix::DSL.merge_dependencies(*Baltix::DSL.filter_dependencies(:development, definition.dependencies, spec.dependencies))
|
339
|
+
end
|
340
|
+
|
341
|
+
def licenses
|
342
|
+
[]
|
343
|
+
end
|
344
|
+
|
345
|
+
def + other
|
346
|
+
self.replace_list = replace_list.merge(other.replace_list)
|
347
|
+
self.source_names = source_names | other.source_names
|
348
|
+
self.dsl.merge_in(other.dsl)
|
349
|
+
|
350
|
+
self
|
351
|
+
end
|
352
|
+
|
353
|
+
def aliases
|
354
|
+
@aliases ||= []
|
355
|
+
end
|
356
|
+
|
357
|
+
def alias_to *sources
|
358
|
+
@aliases = aliases | sources.flatten
|
359
|
+
end
|
360
|
+
|
361
|
+
# rebases source_file to path base and returns.
|
362
|
+
def source_path_from path
|
363
|
+
file =
|
364
|
+
if source_file.include?(path)
|
365
|
+
source_file[path.size + 1..-1]
|
366
|
+
else
|
367
|
+
source_file
|
368
|
+
end
|
369
|
+
|
370
|
+
File.dirname(file)
|
371
|
+
end
|
372
|
+
|
373
|
+
protected
|
374
|
+
|
375
|
+
def exedir
|
376
|
+
@exedir ||= if_exist('exe')
|
377
|
+
end
|
378
|
+
|
379
|
+
def dirs kind, dirs_in = nil, &block
|
380
|
+
dirlist_am = [
|
381
|
+
dirs_in,
|
382
|
+
options[:"src#{kind}dirs"],
|
383
|
+
self.class.const_get("#{kind.upcase}_DIRS")
|
384
|
+
].compact.first
|
385
|
+
|
386
|
+
[ dirlist_am ].flatten.map do |dir_am|
|
387
|
+
file = dir_am.is_a?(Proc) ? dir_am[self] : dir_am
|
388
|
+
end.flatten.compact.select { |file| if_dir(file) }
|
389
|
+
end
|
390
|
+
|
391
|
+
def tree kind, &block
|
392
|
+
re_in = self.class.const_get("#{kind.upcase}_RE") rescue nil
|
393
|
+
prc = self.class.const_get("#{kind.upcase}_FILTER") rescue nil
|
394
|
+
re = re_in.is_a?(Proc) && re_in[self] || re_in || /.*/
|
395
|
+
|
396
|
+
tree_in = send("#{kind}dirs").map do |dir|
|
397
|
+
[ dir, Dir.chdir(File.join(rootdir, dir)) { Dir.glob('**/**/*') } ]
|
398
|
+
end.to_h
|
399
|
+
|
400
|
+
if block_given?
|
401
|
+
# TODO deep_merge
|
402
|
+
tree_in = tree_in.merge(yield)
|
403
|
+
end
|
404
|
+
|
405
|
+
tree_in.map do |dir, files_in|
|
406
|
+
files = Dir.chdir(File.join(rootdir, dir)) do
|
407
|
+
files_in.select do |file|
|
408
|
+
re =~ file && File.file?(file) && (!prc || prc[self, file, dir])
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
# require 'pry';binding.pry if kind == :exe
|
413
|
+
|
414
|
+
[ dir, files ]
|
415
|
+
end.to_h
|
416
|
+
end
|
417
|
+
|
418
|
+
def detect_root
|
419
|
+
source_file && File.dirname(source_file) || Dir.pwd
|
420
|
+
end
|
421
|
+
|
422
|
+
def files kind, &block
|
423
|
+
send("#{kind}tree", &block).map { |(_, values)| values }.flatten
|
424
|
+
end
|
425
|
+
|
426
|
+
#
|
427
|
+
def initialize options_in = {}
|
428
|
+
parse(options_in)
|
429
|
+
|
430
|
+
@loader ||= self.class.to_s.split('::').last.downcase.to_sym
|
431
|
+
end
|
432
|
+
|
433
|
+
def parse options_in
|
434
|
+
self.class.source_options(options_in).each do |option, value|
|
435
|
+
instance_variable_set(:"@#{option}", value)
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Baltix::Source::Fake < Baltix::Source::Base
|
2
|
+
OPTIONS_IN = {
|
3
|
+
source_file: true,
|
4
|
+
}
|
5
|
+
|
6
|
+
def dsl
|
7
|
+
@dsl ||=
|
8
|
+
Baltix::DSL.new(source_file,
|
9
|
+
replace_list: replace_list,
|
10
|
+
skip_list: (options[:gem_skip_list] || []) | [self.name],
|
11
|
+
append_list: options[:gem_append_list])
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|