autoproj 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +30 -0
- data/.rubocop.yml +79 -91
- data/.rubocop_todo.yml +1473 -0
- data/Gemfile +9 -9
- data/Rakefile +24 -24
- data/autoproj.gemspec +22 -22
- data/bin/alocate +4 -4
- data/bin/alog +5 -7
- data/bin/amake +4 -4
- data/bin/aup +4 -4
- data/bin/autoproj +3 -3
- data/bin/autoproj_bootstrap +185 -182
- data/bin/autoproj_bootstrap.in +7 -8
- data/bin/autoproj_install +184 -181
- data/bin/autoproj_install.in +6 -7
- data/lib/autoproj/aruba_minitest.rb +6 -11
- data/lib/autoproj/autobuild.rb +5 -6
- data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
- data/lib/autoproj/autobuild_extensions/dsl.rb +38 -34
- data/lib/autoproj/autobuild_extensions/git.rb +27 -26
- data/lib/autoproj/autobuild_extensions/package.rb +23 -22
- data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
- data/lib/autoproj/base.rb +1 -1
- data/lib/autoproj/bash_completion.rb +5 -6
- data/lib/autoproj/build_option.rb +22 -24
- data/lib/autoproj/cli/base.rb +26 -26
- data/lib/autoproj/cli/bootstrap.rb +14 -16
- data/lib/autoproj/cli/build.rb +10 -7
- data/lib/autoproj/cli/cache.rb +11 -11
- data/lib/autoproj/cli/clean.rb +10 -10
- data/lib/autoproj/cli/commit.rb +7 -8
- data/lib/autoproj/cli/doc.rb +2 -2
- data/lib/autoproj/cli/envsh.rb +1 -2
- data/lib/autoproj/cli/exec.rb +60 -20
- data/lib/autoproj/cli/inspection_tool.rb +13 -7
- data/lib/autoproj/cli/locate.rb +30 -41
- data/lib/autoproj/cli/log.rb +7 -7
- data/lib/autoproj/cli/main.rb +213 -204
- data/lib/autoproj/cli/main_doc.rb +22 -21
- data/lib/autoproj/cli/main_global.rb +44 -19
- data/lib/autoproj/cli/main_plugin.rb +18 -18
- data/lib/autoproj/cli/main_test.rb +28 -27
- data/lib/autoproj/cli/manifest.rb +7 -7
- data/lib/autoproj/cli/osdeps.rb +12 -11
- data/lib/autoproj/cli/patcher.rb +2 -3
- data/lib/autoproj/cli/query.rb +17 -18
- data/lib/autoproj/cli/reconfigure.rb +1 -2
- data/lib/autoproj/cli/reset.rb +9 -12
- data/lib/autoproj/cli/show.rb +38 -39
- data/lib/autoproj/cli/status.rb +45 -39
- data/lib/autoproj/cli/switch_config.rb +5 -6
- data/lib/autoproj/cli/tag.rb +12 -11
- data/lib/autoproj/cli/test.rb +7 -7
- data/lib/autoproj/cli/update.rb +35 -37
- data/lib/autoproj/cli/utility.rb +11 -10
- data/lib/autoproj/cli/version.rb +42 -40
- data/lib/autoproj/cli/versions.rb +14 -15
- data/lib/autoproj/cli/watch.rb +33 -37
- data/lib/autoproj/cli/which.rb +16 -20
- data/lib/autoproj/cli.rb +4 -2
- data/lib/autoproj/configuration.rb +77 -84
- data/lib/autoproj/environment.rb +28 -13
- data/lib/autoproj/exceptions.rb +9 -3
- data/lib/autoproj/find_workspace.rb +20 -25
- data/lib/autoproj/git_server_configuration.rb +40 -44
- data/lib/autoproj/gitorious.rb +1 -1
- data/lib/autoproj/installation_manifest.rb +64 -29
- data/lib/autoproj/local_package_set.rb +13 -11
- data/lib/autoproj/manifest.rb +132 -130
- data/lib/autoproj/metapackage.rb +2 -6
- data/lib/autoproj/ops/atomic_write.rb +7 -6
- data/lib/autoproj/ops/build.rb +4 -6
- data/lib/autoproj/ops/cache.rb +41 -43
- data/lib/autoproj/ops/cached_env.rb +5 -4
- data/lib/autoproj/ops/configuration.rb +511 -506
- data/lib/autoproj/ops/import.rb +73 -63
- data/lib/autoproj/ops/install.rb +178 -174
- data/lib/autoproj/ops/loader.rb +77 -76
- data/lib/autoproj/ops/main_config_switcher.rb +36 -45
- data/lib/autoproj/ops/phase_reporting.rb +4 -4
- data/lib/autoproj/ops/snapshot.rb +250 -247
- data/lib/autoproj/ops/tools.rb +76 -78
- data/lib/autoproj/ops/watch.rb +6 -6
- data/lib/autoproj/ops/which.rb +17 -14
- data/lib/autoproj/options.rb +13 -2
- data/lib/autoproj/os_package_installer.rb +102 -92
- data/lib/autoproj/os_package_query.rb +7 -13
- data/lib/autoproj/os_package_resolver.rb +189 -140
- data/lib/autoproj/os_repository_installer.rb +4 -4
- data/lib/autoproj/os_repository_resolver.rb +8 -6
- data/lib/autoproj/package_definition.rb +12 -13
- data/lib/autoproj/package_managers/apt_dpkg_manager.rb +10 -10
- data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
- data/lib/autoproj/package_managers/debian_version.rb +25 -21
- data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
- data/lib/autoproj/package_managers/gem_manager.rb +68 -77
- data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
- data/lib/autoproj/package_managers/manager.rb +8 -3
- data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
- data/lib/autoproj/package_managers/pip_manager.rb +20 -22
- data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
- data/lib/autoproj/package_managers/port_manager.rb +2 -3
- data/lib/autoproj/package_managers/shell_script_manager.rb +32 -22
- data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
- data/lib/autoproj/package_managers/yum_manager.rb +12 -15
- data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
- data/lib/autoproj/package_manifest.rb +27 -26
- data/lib/autoproj/package_selection.rb +187 -187
- data/lib/autoproj/package_set.rb +127 -113
- data/lib/autoproj/python.rb +55 -55
- data/lib/autoproj/query_base.rb +20 -14
- data/lib/autoproj/reporter.rb +19 -19
- data/lib/autoproj/repository_managers/apt.rb +101 -67
- data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
- data/lib/autoproj/shell_completion.rb +16 -13
- data/lib/autoproj/source_package_query.rb +29 -36
- data/lib/autoproj/system.rb +32 -21
- data/lib/autoproj/test.rb +127 -104
- data/lib/autoproj/variable_expansion.rb +7 -9
- data/lib/autoproj/vcs_definition.rb +35 -32
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +123 -107
- data/lib/autoproj/zsh_completion.rb +8 -9
- data/lib/autoproj.rb +53 -55
- data/samples/autoproj/init.rb +1 -2
- metadata +53 -51
- data/.travis.yml +0 -24
data/lib/autoproj/package_set.rb
CHANGED
@@ -8,8 +8,11 @@ module Autoproj
|
|
8
8
|
# loaded is called before {PackageSet#load_description_file} is called
|
9
9
|
class NotLoaded < RuntimeError
|
10
10
|
attr_reader :package_set
|
11
|
+
|
11
12
|
def initialize(package_set)
|
12
13
|
@package_set = package_set
|
14
|
+
|
15
|
+
super()
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -85,7 +88,9 @@ module Autoproj
|
|
85
88
|
|
86
89
|
# If true, this package set has been loaded because another set imports
|
87
90
|
# it. If false, it is loaded explicitely by the user
|
88
|
-
def explicit
|
91
|
+
def explicit?
|
92
|
+
!!@explicit
|
93
|
+
end
|
89
94
|
attr_writer :explicit
|
90
95
|
|
91
96
|
# Definition of key => value mappings used to resolve e.g. $KEY values
|
@@ -111,9 +116,12 @@ module Autoproj
|
|
111
116
|
#
|
112
117
|
# @see auto_imports?
|
113
118
|
attr_writer :auto_imports
|
119
|
+
|
114
120
|
# If true (the default), imports listed in this package set will be
|
115
121
|
# automatically loaded by autoproj
|
116
|
-
def auto_imports
|
122
|
+
def auto_imports?
|
123
|
+
!!@auto_imports
|
124
|
+
end
|
117
125
|
|
118
126
|
# The VCS definition entries from the 'imports' section of the YAML file
|
119
127
|
# @return [Array<VCSDefinition>]
|
@@ -147,31 +155,34 @@ module Autoproj
|
|
147
155
|
def initialize(
|
148
156
|
ws, vcs,
|
149
157
|
name: self.class.name_of(ws, vcs),
|
150
|
-
raw_local_dir: self.class.raw_local_dir_of(ws, vcs)
|
158
|
+
raw_local_dir: self.class.raw_local_dir_of(ws, vcs)
|
159
|
+
)
|
151
160
|
|
152
161
|
@ws = ws
|
153
162
|
@vcs = vcs
|
154
|
-
|
163
|
+
unless vcs
|
155
164
|
raise ArgumentError, "cannot create a package set with a nil vcs, create a null VCS using VCSDefinition.none"
|
156
165
|
end
|
166
|
+
|
157
167
|
@name = name
|
158
168
|
@os_repository_resolver = OSRepositoryResolver.new
|
159
169
|
@os_package_resolver = OSPackageResolver.new(
|
160
170
|
operating_system: ws.os_package_resolver.operating_system,
|
161
171
|
package_managers: ws.os_package_resolver.package_managers,
|
162
|
-
os_package_manager: ws.os_package_resolver.os_package_manager
|
172
|
+
os_package_manager: ws.os_package_resolver.os_package_manager
|
173
|
+
)
|
163
174
|
@importer_definitions_cache = Hash.new
|
164
175
|
@all_osdeps = []
|
165
176
|
@all_osrepos = []
|
166
177
|
@constants_definitions = Hash.new
|
167
|
-
@required_autoproj_version =
|
178
|
+
@required_autoproj_version = "0"
|
168
179
|
@version_control = Array.new
|
169
180
|
@overrides = Array.new
|
170
181
|
@raw_local_dir = raw_local_dir
|
171
|
-
@default_importer = VCSDefinition.from_raw({ type:
|
182
|
+
@default_importer = VCSDefinition.from_raw({ type: "none" })
|
172
183
|
|
173
|
-
@imports
|
174
|
-
@imports_vcs
|
184
|
+
@imports = Set.new
|
185
|
+
@imports_vcs = Array.new
|
175
186
|
@imported_from = Array.new
|
176
187
|
@explicit = false
|
177
188
|
@auto_imports = true
|
@@ -182,7 +193,8 @@ module Autoproj
|
|
182
193
|
new_osdeps = OSPackageResolver.load(
|
183
194
|
file,
|
184
195
|
suffixes: ws.osdep_suffixes,
|
185
|
-
**options
|
196
|
+
**options
|
197
|
+
)
|
186
198
|
all_osdeps << new_osdeps
|
187
199
|
os_package_resolver.merge(all_osdeps.last)
|
188
200
|
new_osdeps
|
@@ -208,16 +220,25 @@ module Autoproj
|
|
208
220
|
|
209
221
|
# True if this source has already been checked out on the local autoproj
|
210
222
|
# installation
|
211
|
-
def present
|
223
|
+
def present?
|
224
|
+
File.directory?(raw_local_dir)
|
225
|
+
end
|
226
|
+
|
212
227
|
# True if this is the main package set (i.e. the main autoproj
|
213
228
|
# configuration)
|
214
|
-
def main
|
229
|
+
def main?
|
230
|
+
false
|
231
|
+
end
|
232
|
+
|
215
233
|
# True if this source is local, i.e. is not under a version control
|
216
|
-
def local
|
234
|
+
def local?
|
235
|
+
vcs.local?
|
236
|
+
end
|
237
|
+
|
217
238
|
# True if this source defines nothing
|
218
239
|
def empty?
|
219
240
|
version_control.empty? && overrides.empty?
|
220
|
-
|
241
|
+
!each_package.find { true } &&
|
221
242
|
!File.exist?(File.join(raw_local_dir, "overrides.rb")) &&
|
222
243
|
!File.exist?(File.join(raw_local_dir, "init.rb"))
|
223
244
|
end
|
@@ -254,9 +275,9 @@ module Autoproj
|
|
254
275
|
def self.name_of(ws, vcs, raw_local_dir: raw_local_dir_of(ws, vcs), ignore_load_errors: false)
|
255
276
|
if File.directory?(raw_local_dir)
|
256
277
|
begin
|
257
|
-
return raw_description_file(raw_local_dir, package_set_name: "#{vcs.type}:#{vcs.url}")[
|
278
|
+
return raw_description_file(raw_local_dir, package_set_name: "#{vcs.type}:#{vcs.url}")["name"]
|
258
279
|
rescue ConfigError
|
259
|
-
raise
|
280
|
+
raise unless ignore_load_errors
|
260
281
|
end
|
261
282
|
end
|
262
283
|
vcs.to_s
|
@@ -271,7 +292,7 @@ module Autoproj
|
|
271
292
|
def self.raw_local_dir_of(ws, vcs)
|
272
293
|
if vcs.needs_import?
|
273
294
|
repository_id = vcs.create_autobuild_importer.repository_id
|
274
|
-
path = File.join(ws.remotes_dir, repository_id.gsub(/[^\w]/,
|
295
|
+
path = File.join(ws.remotes_dir, repository_id.gsub(/[^\w]/, "_"))
|
275
296
|
File.expand_path(path)
|
276
297
|
elsif !vcs.none?
|
277
298
|
File.expand_path(vcs.url)
|
@@ -279,10 +300,10 @@ module Autoproj
|
|
279
300
|
end
|
280
301
|
|
281
302
|
def self.default_expansions(ws)
|
282
|
-
ws.config.to_hash
|
283
|
-
|
284
|
-
|
285
|
-
|
303
|
+
ws.config.to_hash
|
304
|
+
.merge(ws.manifest.constant_definitions)
|
305
|
+
.merge("AUTOPROJ_ROOT" => ws.root_dir,
|
306
|
+
"AUTOPROJ_CONFIG" => ws.config_dir)
|
286
307
|
end
|
287
308
|
|
288
309
|
# Resolve the VCS information for a package set
|
@@ -297,7 +318,7 @@ module Autoproj
|
|
297
318
|
options, vcs_spec = Kernel.filter_options spec, auto_imports: true
|
298
319
|
|
299
320
|
vcs_spec = Autoproj.expand(vcs_spec, vars)
|
300
|
-
|
321
|
+
[VCSDefinition.from_raw(vcs_spec, from: from, raw: raw), options]
|
301
322
|
end
|
302
323
|
|
303
324
|
# Returns a string that uniquely represents the version control
|
@@ -328,9 +349,9 @@ module Autoproj
|
|
328
349
|
# For local sources, is simply returns the path to the source directory.
|
329
350
|
def user_local_dir
|
330
351
|
if local?
|
331
|
-
|
352
|
+
vcs.url
|
332
353
|
else
|
333
|
-
File.join(ws.config_dir,
|
354
|
+
File.join(ws.config_dir, "remotes", name)
|
334
355
|
end
|
335
356
|
end
|
336
357
|
|
@@ -352,23 +373,23 @@ module Autoproj
|
|
352
373
|
# Validate and normalizes a raw source file
|
353
374
|
def self.validate_and_normalize_source_file(yaml_path, yaml)
|
354
375
|
yaml = yaml.dup
|
355
|
-
%w
|
376
|
+
%w[imports version_control].each do |entry_name|
|
356
377
|
yaml[entry_name] ||= Array.new
|
357
|
-
|
378
|
+
unless yaml[entry_name].respond_to?(:to_ary)
|
358
379
|
raise ConfigError.new(yaml_path), "expected the '#{entry_name}' entry to be an array"
|
359
380
|
end
|
360
381
|
end
|
361
382
|
|
362
|
-
%w
|
383
|
+
%w[constants].each do |entry_name|
|
363
384
|
yaml[entry_name] ||= Hash.new
|
364
|
-
|
385
|
+
unless yaml[entry_name].respond_to?(:to_h)
|
365
386
|
raise ConfigError.new(yaml_path), "expected the '#{entry_name}' entry to be a map"
|
366
387
|
end
|
367
388
|
end
|
368
389
|
|
369
|
-
if yaml.has_key?(
|
370
|
-
yaml[
|
371
|
-
|
390
|
+
if yaml.has_key?("overrides")
|
391
|
+
yaml["overrides"] ||= Array.new
|
392
|
+
unless yaml["overrides"].respond_to?(:to_ary)
|
372
393
|
raise ConfigError.new(yaml_path), "expected the 'overrides' entry to be an array"
|
373
394
|
end
|
374
395
|
end
|
@@ -384,14 +405,14 @@ module Autoproj
|
|
384
405
|
# @return [Hash] the raw description information
|
385
406
|
def self.raw_description_file(raw_local_dir, package_set_name: nil)
|
386
407
|
master_source_file = File.join(raw_local_dir, PackageSet.master_source_file)
|
387
|
-
|
408
|
+
unless File.exist?(master_source_file)
|
388
409
|
raise ConfigError.new, "package set #{package_set_name} present in #{raw_local_dir} should have a source.yml file, but does not"
|
389
410
|
end
|
390
411
|
|
391
412
|
source_definition = Hash.new
|
392
413
|
PackageSet.source_files.each do |name|
|
393
414
|
source_file = File.join(raw_local_dir, name)
|
394
|
-
next
|
415
|
+
next unless File.file?(source_file)
|
395
416
|
|
396
417
|
newdefs = Autoproj.in_file(source_file, Autoproj::YAML_LOAD_ERROR) do
|
397
418
|
YAML.load(File.read(source_file))
|
@@ -400,11 +421,12 @@ module Autoproj
|
|
400
421
|
source_definition.merge!(newdefs) do |k, old, new|
|
401
422
|
if old.respond_to?(:to_ary)
|
402
423
|
old + new
|
403
|
-
else
|
424
|
+
else
|
425
|
+
new
|
404
426
|
end
|
405
427
|
end
|
406
428
|
end
|
407
|
-
|
429
|
+
unless source_definition["name"]
|
408
430
|
raise ConfigError.new(master_source_file), "#{master_source_file} does not have a 'name' field"
|
409
431
|
end
|
410
432
|
|
@@ -416,7 +438,7 @@ module Autoproj
|
|
416
438
|
# Raises InternalError if the source has not been checked out yet (it
|
417
439
|
# should have), and ConfigError if the source.yml file is not valid.
|
418
440
|
def raw_description_file
|
419
|
-
|
441
|
+
unless present?
|
420
442
|
raise InternalError, "source #{vcs} has not been fetched yet, cannot load description for it"
|
421
443
|
end
|
422
444
|
|
@@ -461,7 +483,7 @@ module Autoproj
|
|
461
483
|
end
|
462
484
|
|
463
485
|
# Add a new entry in the list of version control resolutions
|
464
|
-
def add_overrides_entry(matcher, vcs_definition, file:
|
486
|
+
def add_overrides_entry(matcher, vcs_definition, file: "#add_overrides_entry")
|
465
487
|
if (last_entry = overrides.last) && last_entry[0] == file
|
466
488
|
last_entry[1] << [matcher, vcs_definition]
|
467
489
|
else
|
@@ -471,82 +493,82 @@ module Autoproj
|
|
471
493
|
|
472
494
|
# Path to the source.yml file
|
473
495
|
def source_file
|
474
|
-
if local_dir
|
475
|
-
File.join(local_dir, 'source.yml')
|
476
|
-
end
|
496
|
+
File.join(local_dir, "source.yml") if local_dir
|
477
497
|
end
|
478
498
|
|
479
499
|
# Load the source.yml file and resolves all information it contains.
|
480
500
|
def load_description_file
|
481
501
|
source_definition = raw_description_file
|
482
|
-
name = source_definition[
|
483
|
-
if name !~ /^[\w
|
502
|
+
name = source_definition["name"]
|
503
|
+
if name !~ /^[\w.-]+$/
|
484
504
|
raise ConfigError.new(source_file),
|
485
|
-
|
505
|
+
"in #{source_file}: invalid source name '#{@name}': source names can only contain alphanumeric characters, and .-_"
|
486
506
|
elsif name == "local"
|
487
507
|
raise ConfigError.new(source_file),
|
488
|
-
|
508
|
+
"in #{source_file}: the name 'local' is a reserved name"
|
489
509
|
end
|
490
510
|
|
491
511
|
parse_source_definition(source_definition)
|
492
512
|
end
|
493
513
|
|
494
514
|
def load_overrides(source_definition)
|
495
|
-
if data = source_definition[
|
515
|
+
if (data = source_definition["overrides"])
|
496
516
|
[[source_file, data]]
|
497
517
|
end
|
498
518
|
end
|
499
519
|
|
500
520
|
def parse_source_definition(source_definition)
|
501
|
-
@name = source_definition[
|
521
|
+
@name = source_definition["name"] || name
|
502
522
|
@required_autoproj_version = source_definition.fetch(
|
503
|
-
|
523
|
+
"required_autoproj_version", required_autoproj_version
|
524
|
+
)
|
504
525
|
|
505
526
|
# Compute the definition of constants
|
506
|
-
if new_constants = source_definition[
|
527
|
+
if (new_constants = source_definition["constants"])
|
507
528
|
Autoproj.in_file(source_file) do
|
508
529
|
variables = inject_constants_and_config_for_expansion(Hash.new)
|
509
530
|
@constants_definitions = Autoproj.resolve_constant_definitions(
|
510
|
-
new_constants, variables
|
531
|
+
new_constants, variables
|
532
|
+
)
|
511
533
|
end
|
512
534
|
end
|
513
535
|
|
514
|
-
if new_imports = source_definition[
|
536
|
+
if (new_imports = source_definition["imports"])
|
515
537
|
variables = inject_constants_and_config_for_expansion(Hash.new)
|
516
|
-
@imports_vcs
|
538
|
+
@imports_vcs = Array(new_imports).map do |set_def|
|
517
539
|
if !set_def.kind_of?(Hash) && !set_def.respond_to?(:to_str)
|
518
540
|
raise ConfigError.new(source_file), "in #{source_file}: "\
|
519
|
-
|
520
|
-
|
541
|
+
"wrong format for 'imports' section. Expected an array of "\
|
542
|
+
"maps or strings (e.g. - github: my/url)."
|
521
543
|
end
|
522
544
|
|
523
545
|
Autoproj.in_file(source_file) do
|
524
546
|
PackageSet.resolve_definition(ws, set_def, from: self,
|
525
|
-
|
526
|
-
|
547
|
+
vars: variables,
|
548
|
+
raw: [VCSDefinition::RawEntry.new(self, source_file, set_def)])
|
527
549
|
end
|
528
550
|
end
|
529
551
|
end
|
530
552
|
|
531
|
-
if new_version_control = source_definition[
|
553
|
+
if (new_version_control = source_definition["version_control"])
|
532
554
|
invalidate_importer_definitions_cache
|
533
|
-
@version_control = normalize_vcs_list(
|
534
|
-
|
555
|
+
@version_control = normalize_vcs_list("version_control", source_file,
|
556
|
+
new_version_control)
|
535
557
|
|
536
558
|
Autoproj.in_file(source_file) do
|
537
559
|
default_vcs_spec, raw = version_control_field(
|
538
|
-
|
539
|
-
file: source_file, section:
|
560
|
+
"default", version_control,
|
561
|
+
file: source_file, section: "version_control"
|
540
562
|
)
|
541
563
|
if default_vcs_spec
|
542
564
|
@default_importer = VCSDefinition.from_raw(default_vcs_spec,
|
543
|
-
|
565
|
+
raw: raw, from: self)
|
544
566
|
end
|
545
567
|
end
|
546
568
|
end
|
547
|
-
if new_overrides = load_overrides(source_definition)
|
569
|
+
if (new_overrides = load_overrides(source_definition))
|
548
570
|
@overrides = new_overrides.map do |file, entries|
|
549
|
-
[file, normalize_vcs_list(
|
571
|
+
[file, normalize_vcs_list("overrides", file, entries)]
|
550
572
|
end
|
551
573
|
end
|
552
574
|
end
|
@@ -561,16 +583,14 @@ module Autoproj
|
|
561
583
|
defs = Hash[
|
562
584
|
"AUTOPROJ_ROOT" => ws.root_dir,
|
563
585
|
"AUTOPROJ_CONFIG" => ws.config_dir,
|
564
|
-
"AUTOPROJ_SOURCE_DIR" => local_dir]
|
565
|
-
|
566
|
-
|
567
|
-
|
586
|
+
"AUTOPROJ_SOURCE_DIR" => local_dir]
|
587
|
+
.merge(manifest.constant_definitions)
|
588
|
+
.merge(constants_definitions)
|
589
|
+
.merge(additional_expansions)
|
568
590
|
|
569
591
|
config = ws.config
|
570
592
|
Hash.new do |h, k|
|
571
|
-
if config.has_value_for?(k) || config.declared?(k)
|
572
|
-
config.get(k)
|
573
|
-
end
|
593
|
+
config.get(k) if config.has_value_for?(k) || config.declared?(k)
|
574
594
|
end.merge(defs)
|
575
595
|
end
|
576
596
|
|
@@ -591,7 +611,7 @@ module Autoproj
|
|
591
611
|
#
|
592
612
|
# Converts a number to an ordinal string representation (i.e. 1st, 25th)
|
593
613
|
def number_to_nth(number)
|
594
|
-
Hash[1 =>
|
614
|
+
Hash[1 => "1st", 2 => "2nd", 3 => "3rd"].fetch(number, "#{number}th")
|
595
615
|
end
|
596
616
|
|
597
617
|
# @api private
|
@@ -606,12 +626,23 @@ module Autoproj
|
|
606
626
|
|
607
627
|
list.each_with_index.map do |spec, spec_idx|
|
608
628
|
spec_nth = number_to_nth(spec_idx + 1)
|
609
|
-
|
629
|
+
unless spec.kind_of?(Hash)
|
610
630
|
raise InvalidYAMLFormatting, "wrong format for the #{spec_nth} entry (#{spec.inspect}) of the #{section_name} section of #{file}, expected a package name, followed by a colon, and one importer option per following line"
|
611
631
|
end
|
612
632
|
|
613
633
|
spec = spec.dup
|
614
|
-
if spec.values.size
|
634
|
+
if spec.values.size == 1
|
635
|
+
name, spec = spec.to_a.first
|
636
|
+
if spec.respond_to?(:to_str)
|
637
|
+
if spec == "none"
|
638
|
+
spec = Hash["type" => "none"]
|
639
|
+
else
|
640
|
+
raise ConfigError.new, "invalid VCS specification in the #{section_name} section of #{file}: '#{name}: #{spec}'. One can only use this shorthand to declare the absence of a VCS with the 'none' keyword"
|
641
|
+
end
|
642
|
+
elsif !spec.kind_of?(Hash)
|
643
|
+
raise InvalidYAMLFormatting, "expected '#{name}:' followed by version control options, but got nothing, in the #{spec_nth} entry of the #{section_name} section of #{file}"
|
644
|
+
end
|
645
|
+
else
|
615
646
|
# Maybe the user wrote the spec like
|
616
647
|
# - package_name:
|
617
648
|
# type: git
|
@@ -619,29 +650,16 @@ module Autoproj
|
|
619
650
|
#
|
620
651
|
# In that case, we should have the package name as
|
621
652
|
# "name => nil". Check that.
|
622
|
-
name,
|
653
|
+
name, = spec.find { |n, v| v.nil? }
|
623
654
|
if name
|
624
655
|
spec.delete(name)
|
625
656
|
else
|
626
657
|
raise InvalidYAMLFormatting, "cannot make sense of the #{spec_nth} entry in the #{section_name} section of #{file}: #{spec}"
|
627
658
|
end
|
628
|
-
else
|
629
|
-
name, spec = spec.to_a.first
|
630
|
-
if spec.respond_to?(:to_str)
|
631
|
-
if spec == "none"
|
632
|
-
spec = Hash['type' => "none"]
|
633
|
-
else
|
634
|
-
raise ConfigError.new, "invalid VCS specification in the #{section_name} section of #{file}: '#{name}: #{spec}'. One can only use this shorthand to declare the absence of a VCS with the 'none' keyword"
|
635
|
-
end
|
636
|
-
elsif !spec.kind_of?(Hash)
|
637
|
-
raise InvalidYAMLFormatting, "expected '#{name}:' followed by version control options, but got nothing, in the #{spec_nth} entry of the #{section_name} section of #{file}"
|
638
|
-
end
|
639
659
|
end
|
640
660
|
|
641
661
|
name_match = name
|
642
|
-
if name_match =~ /[^\w\/-]/
|
643
|
-
name_match = Regexp.new("^" + name_match)
|
644
|
-
end
|
662
|
+
name_match = Regexp.new("^#{name_match}") if name_match =~ /[^\w\/-]/
|
645
663
|
|
646
664
|
[name_match, spec]
|
647
665
|
end
|
@@ -656,7 +674,7 @@ module Autoproj
|
|
656
674
|
# The Hash part is nil if there are no matching entries. Hash keys are
|
657
675
|
# normalized to symbols
|
658
676
|
def version_control_field(package_name, entry_list, validate: true,
|
659
|
-
|
677
|
+
file: source_file, section: nil)
|
660
678
|
raw = []
|
661
679
|
vcs_spec = entry_list.inject({}) do |resolved_spec, (name_match, spec)|
|
662
680
|
next(resolved_spec) unless name_match === package_name
|
@@ -666,7 +684,7 @@ module Autoproj
|
|
666
684
|
VCSDefinition.update_raw_vcs_spec(resolved_spec, spec)
|
667
685
|
rescue ArgumentError => e
|
668
686
|
raise ConfigError.new,
|
669
|
-
|
687
|
+
"invalid VCS definition while resolving package "\
|
670
688
|
"'#{package_name}', entry '#{name_match}' of "\
|
671
689
|
"#{section ? "section '#{section}'" : ''}: "\
|
672
690
|
"#{e.message}", e.backtrace
|
@@ -676,8 +694,8 @@ module Autoproj
|
|
676
694
|
return nil, [] if vcs_spec.empty?
|
677
695
|
|
678
696
|
expansions = {
|
679
|
-
|
680
|
-
|
697
|
+
"PACKAGE" => package_name,
|
698
|
+
"PACKAGE_BASENAME" => File.basename(package_name)
|
681
699
|
}
|
682
700
|
|
683
701
|
vcs_spec = expand(vcs_spec, expansions)
|
@@ -686,7 +704,7 @@ module Autoproj
|
|
686
704
|
end
|
687
705
|
|
688
706
|
# Resolve relative paths w.r.t. the workspace root dir
|
689
|
-
if (url = (vcs_spec.delete(
|
707
|
+
if (url = (vcs_spec.delete("url") || vcs_spec.delete(:url)))
|
690
708
|
vcs_spec[:url] = VCSDefinition.to_absolute_url(url, ws.root_dir)
|
691
709
|
end
|
692
710
|
|
@@ -697,7 +715,7 @@ module Autoproj
|
|
697
715
|
VCSDefinition.from_raw(vcs_spec)
|
698
716
|
rescue ArgumentError => e
|
699
717
|
raise ConfigError.new,
|
700
|
-
|
718
|
+
"invalid resulting VCS definition for package "\
|
701
719
|
"'#{package_name}': #{e.message}",
|
702
720
|
e.backtrace
|
703
721
|
end
|
@@ -725,7 +743,7 @@ module Autoproj
|
|
725
743
|
importer_definitions_cache[package_name] ||= Autoproj.in_file source_file do
|
726
744
|
vcs_spec, raw = version_control_field(
|
727
745
|
package_name, version_control,
|
728
|
-
file: source_file, section:
|
746
|
+
file: source_file, section: "version_control"
|
729
747
|
)
|
730
748
|
if vcs_spec
|
731
749
|
VCSDefinition.from_raw(vcs_spec, raw: raw, from: self)
|
@@ -758,19 +776,17 @@ module Autoproj
|
|
758
776
|
Autoproj.in_file file do
|
759
777
|
version_control_field(
|
760
778
|
key, file_overrides,
|
761
|
-
validate: false, file: file, section:
|
779
|
+
validate: false, file: file, section: "overrides"
|
762
780
|
)
|
763
781
|
end
|
764
782
|
|
765
783
|
if new_spec
|
766
784
|
Autoproj.in_file file do
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
"#{key}: #{e.message}"
|
773
|
-
end
|
785
|
+
vcs = vcs.update(new_spec, raw: new_raw_entry, from: self)
|
786
|
+
rescue ConfigError => e
|
787
|
+
raise ConfigError.new,
|
788
|
+
"invalid resulting VCS specification in the overrides "\
|
789
|
+
"section for #{key}: #{e.message}"
|
774
790
|
end
|
775
791
|
end
|
776
792
|
end
|
@@ -780,20 +796,17 @@ module Autoproj
|
|
780
796
|
# Enumerates the Autobuild::Package instances that are defined in this
|
781
797
|
# source
|
782
798
|
def each_package
|
783
|
-
|
784
|
-
return enum_for(:each_package)
|
785
|
-
end
|
799
|
+
return enum_for(:each_package) unless block_given?
|
786
800
|
|
787
801
|
manifest.each_package_definition do |pkg|
|
788
|
-
if pkg.package_set == self
|
789
|
-
yield(pkg.autobuild)
|
790
|
-
end
|
802
|
+
yield(pkg.autobuild) if pkg.package_set == self
|
791
803
|
end
|
792
804
|
end
|
793
805
|
|
794
806
|
# List the autobuild files that are part of this package set
|
795
807
|
def each_autobuild_file
|
796
|
-
return enum_for(__method__)
|
808
|
+
return enum_for(__method__) unless block_given?
|
809
|
+
|
797
810
|
Dir.glob(File.join(local_dir, "*.autobuild")).sort.each do |file|
|
798
811
|
yield(file)
|
799
812
|
end
|
@@ -802,7 +815,8 @@ module Autoproj
|
|
802
815
|
# Yields each osdeps definition files that are present in this package
|
803
816
|
# set
|
804
817
|
def each_osdeps_file
|
805
|
-
return enum_for(__method__)
|
818
|
+
return enum_for(__method__) unless block_given?
|
819
|
+
|
806
820
|
Dir.glob(File.join(local_dir, "*.osdeps")).each do |file|
|
807
821
|
yield(file)
|
808
822
|
end
|
@@ -811,11 +825,11 @@ module Autoproj
|
|
811
825
|
# Yields each osdeps definition files that are present in this package
|
812
826
|
# set
|
813
827
|
def each_osrepos_file
|
814
|
-
return enum_for(__method__)
|
828
|
+
return enum_for(__method__) unless block_given?
|
829
|
+
|
815
830
|
Dir.glob(File.join(local_dir, "*.osrepos")).each do |file|
|
816
831
|
yield(file)
|
817
832
|
end
|
818
833
|
end
|
819
834
|
end
|
820
835
|
end
|
821
|
-
|