autoproj 2.12.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 +6 -7
- data/bin/amake +4 -4
- data/bin/aup +4 -4
- data/bin/autoproj +2 -2
- data/bin/autoproj_bootstrap +186 -183
- data/bin/autoproj_bootstrap.in +7 -8
- data/bin/autoproj_install +185 -182
- 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 +61 -44
- 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 +27 -27
- data/lib/autoproj/cli/bootstrap.rb +14 -16
- data/lib/autoproj/cli/build.rb +18 -10
- data/lib/autoproj/cli/cache.rb +51 -8
- 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 +18 -13
- data/lib/autoproj/cli/locate.rb +30 -41
- data/lib/autoproj/cli/log.rb +7 -7
- data/lib/autoproj/cli/main.rb +217 -205
- 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 +48 -55
- data/lib/autoproj/cli/status.rb +56 -44
- 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 +104 -51
- data/lib/autoproj/cli/utility.rb +14 -12
- 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 +78 -85
- data/lib/autoproj/default.osdeps +29 -3
- data/lib/autoproj/environment.rb +42 -23
- 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 +145 -135
- 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 +64 -53
- data/lib/autoproj/ops/cached_env.rb +7 -6
- data/lib/autoproj/ops/configuration.rb +511 -506
- data/lib/autoproj/ops/import.rb +90 -61
- data/lib/autoproj/ops/install.rb +179 -175
- 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 +46 -31
- data/lib/autoproj/package_managers/bundler_manager.rb +156 -118
- 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 +37 -27
- 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 +66 -36
- 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 +66 -53
- data/lib/autoproj/package_selection.rb +187 -187
- data/lib/autoproj/package_set.rb +128 -114
- data/lib/autoproj/python.rb +285 -0
- 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 +131 -106
- data/lib/autoproj/variable_expansion.rb +10 -10
- data/lib/autoproj/vcs_definition.rb +53 -37
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +162 -117
- data/lib/autoproj/zsh_completion.rb +8 -9
- data/lib/autoproj.rb +53 -53
- data/samples/autoproj/init.rb +1 -2
- metadata +62 -72
- data/.travis.yml +0 -22
data/lib/autoproj/manifest.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "yaml"
|
2
|
+
require "csv"
|
3
|
+
require "utilrb/kernel/options"
|
4
|
+
require "set"
|
5
5
|
|
6
|
-
|
6
|
+
if RbConfig::CONFIG["host_os"] =~ %r{(msdos|mswin|djgpp|mingw|[Ww]indows)}
|
7
|
+
require "win32/dir"
|
8
|
+
end
|
7
9
|
|
8
10
|
module Autoproj
|
9
11
|
# The Manifest class represents the information included in the main
|
@@ -50,12 +52,19 @@ module Autoproj
|
|
50
52
|
|
51
53
|
# Load the manifest data contained in +file+
|
52
54
|
def load(file)
|
53
|
-
|
54
|
-
raise ConfigError.new(File.dirname(file)),
|
55
|
+
unless File.exist?(file)
|
56
|
+
raise ConfigError.new(File.dirname(file)),
|
57
|
+
"expected an autoproj configuration in #{File.dirname(file)}, "\
|
58
|
+
"but #{file} does not exist"
|
55
59
|
end
|
56
60
|
|
57
61
|
data = Autoproj.in_file(file, Autoproj::YAML_LOAD_ERROR) do
|
58
|
-
YAML.
|
62
|
+
YAML.safe_load(File.read(file)) || {}
|
63
|
+
end
|
64
|
+
|
65
|
+
if data["layout"]&.member?(nil)
|
66
|
+
Autoproj.warn "There is an empty entry in your layout in #{file}. All empty entries are ignored."
|
67
|
+
data["layout"] = data["layout"].compact
|
59
68
|
end
|
60
69
|
|
61
70
|
@file = file
|
@@ -67,21 +76,23 @@ module Autoproj
|
|
67
76
|
# Initialize the manifest from a hash, as loaded from a manifest file
|
68
77
|
def initialize_from_hash(data)
|
69
78
|
@data = data
|
70
|
-
@ignored_packages |= (data[
|
71
|
-
@ignored_packages |= (data[
|
79
|
+
@ignored_packages |= (data["ignored_packages"] || Set.new).to_set
|
80
|
+
@ignored_packages |= (data["ignore_packages"] || Set.new).to_set
|
72
81
|
invalidate_ignored_package_names
|
73
|
-
@manifest_exclusions |= (data[
|
82
|
+
@manifest_exclusions |= (data["exclude_packages"] || Set.new).to_set
|
74
83
|
|
75
84
|
normalized_layout = Hash.new
|
76
85
|
compute_normalized_layout(
|
77
86
|
normalized_layout,
|
78
|
-
|
79
|
-
data[
|
87
|
+
"/",
|
88
|
+
data["layout"] || Hash.new
|
89
|
+
)
|
80
90
|
@normalized_layout = normalized_layout
|
81
|
-
@has_layout = !!data[
|
91
|
+
@has_layout = !!data["layout"]
|
82
92
|
|
83
|
-
if data[
|
84
|
-
@constant_definitions =
|
93
|
+
if data["constants"]
|
94
|
+
@constant_definitions =
|
95
|
+
Autoproj.resolve_constant_definitions(data["constants"])
|
85
96
|
end
|
86
97
|
end
|
87
98
|
|
@@ -107,7 +118,7 @@ module Autoproj
|
|
107
118
|
def add_package_to_layout(package)
|
108
119
|
package_name = validate_package_name_argument(package)
|
109
120
|
@has_layout = true
|
110
|
-
normalized_layout[package_name] =
|
121
|
+
normalized_layout[package_name] = "/"
|
111
122
|
end
|
112
123
|
|
113
124
|
# Add a package into the layout
|
@@ -120,7 +131,7 @@ module Autoproj
|
|
120
131
|
def add_metapackage_to_layout(metapackage)
|
121
132
|
validate_metapackage_in_self(metapackage)
|
122
133
|
@has_layout = true
|
123
|
-
normalized_layout[metapackage.name] =
|
134
|
+
normalized_layout[metapackage.name] = "/"
|
124
135
|
end
|
125
136
|
|
126
137
|
# Add a constant definition, used when resolving $CONSTANT in loaded
|
@@ -149,10 +160,12 @@ module Autoproj
|
|
149
160
|
# is not available on the current operating system, or simply return it
|
150
161
|
#
|
151
162
|
# @return [Boolean]
|
152
|
-
def accept_unavailable_osdeps
|
163
|
+
def accept_unavailable_osdeps?
|
164
|
+
!!@accept_unavailable_osdeps
|
165
|
+
end
|
153
166
|
|
154
167
|
# Sets {#accept_unavailable_osdeps?}
|
155
|
-
|
168
|
+
attr_writer :accept_unavailable_osdeps
|
156
169
|
|
157
170
|
attr_reader :constant_definitions
|
158
171
|
|
@@ -232,6 +245,7 @@ module Autoproj
|
|
232
245
|
if require_existing && !has_package?(package)
|
233
246
|
raise PackageNotFound, "no package named #{package} in #{self}"
|
234
247
|
end
|
248
|
+
|
235
249
|
package
|
236
250
|
end
|
237
251
|
end
|
@@ -267,9 +281,7 @@ module Autoproj
|
|
267
281
|
#
|
268
282
|
# Do not use directly, use {#ignored?} instead
|
269
283
|
def cache_ignored_package_names
|
270
|
-
if @ignored_package_names
|
271
|
-
return @ignored_package_names
|
272
|
-
end
|
284
|
+
return @ignored_package_names if @ignored_package_names
|
273
285
|
|
274
286
|
@ignored_package_names = each_package_definition.find_all do |pkg|
|
275
287
|
ignored_packages.any? do |l|
|
@@ -290,7 +302,8 @@ module Autoproj
|
|
290
302
|
#
|
291
303
|
# @yieldparam [Autobuild::Package]
|
292
304
|
def each_ignored_package
|
293
|
-
return enum_for(__method__)
|
305
|
+
return enum_for(__method__) unless block_given?
|
306
|
+
|
294
307
|
cache_ignored_package_names.each do |pkg_name|
|
295
308
|
yield(find_autobuild_package(pkg_name))
|
296
309
|
end
|
@@ -312,7 +325,7 @@ module Autoproj
|
|
312
325
|
|
313
326
|
if !explicitely_selected_in_layout?(package_name) && excluded_in_manifest?(package_name)
|
314
327
|
true
|
315
|
-
elsif automatic_exclusions.any? { |pkg_name
|
328
|
+
elsif automatic_exclusions.any? { |pkg_name,| pkg_name == package_name }
|
316
329
|
true
|
317
330
|
else
|
318
331
|
false
|
@@ -321,7 +334,8 @@ module Autoproj
|
|
321
334
|
|
322
335
|
# Enumerates the package names of all ignored packages
|
323
336
|
def each_excluded_package
|
324
|
-
return enum_for(__method__)
|
337
|
+
return enum_for(__method__) unless block_given?
|
338
|
+
|
325
339
|
each_autobuild_package do |pkg|
|
326
340
|
yield(pkg) if excluded?(pkg.name)
|
327
341
|
end
|
@@ -350,10 +364,14 @@ module Autoproj
|
|
350
364
|
# Exclude +package_name+ from the build. +reason+ is a string describing
|
351
365
|
# why the package is to be excluded.
|
352
366
|
def exclude_package(package_name, reason)
|
353
|
-
package = validate_package_name_argument(
|
354
|
-
|
367
|
+
package = validate_package_name_argument(
|
368
|
+
package_name, require_existing: false
|
369
|
+
)
|
370
|
+
if (meta = find_metapackage(package))
|
355
371
|
meta.each_package do |pkg|
|
356
|
-
automatic_exclusions[pkg.name] =
|
372
|
+
automatic_exclusions[pkg.name] =
|
373
|
+
"#{meta.name} is an excluded metapackage, "\
|
374
|
+
"and it includes #{pkg.name}: #{reason}"
|
357
375
|
end
|
358
376
|
else
|
359
377
|
automatic_exclusions[package] = reason
|
@@ -380,11 +398,11 @@ module Autoproj
|
|
380
398
|
# disabled on this particular operating system.
|
381
399
|
def exclusion_reason(package_name)
|
382
400
|
package_name = validate_package_name_argument(package_name)
|
383
|
-
if message = automatic_exclusions[package_name]
|
401
|
+
if (message = automatic_exclusions[package_name])
|
384
402
|
return message
|
385
403
|
end
|
386
404
|
|
387
|
-
|
405
|
+
unless explicitely_selected_in_layout?(package_name)
|
388
406
|
manifest_exclusions.each do |matcher|
|
389
407
|
if (pkg_set = metapackages[matcher]) && pkg_set.include?(package_name)
|
390
408
|
return "#{pkg_set.name} is a metapackage listed in the exclude_packages section of the manifest, and it includes #{package_name}"
|
@@ -413,12 +431,10 @@ module Autoproj
|
|
413
431
|
|
414
432
|
# Like #each_package_set, but filters out local package sets
|
415
433
|
def each_remote_package_set
|
416
|
-
return enum_for(__method__)
|
434
|
+
return enum_for(__method__) unless block_given?
|
417
435
|
|
418
436
|
each_package_set do |pkg_set|
|
419
|
-
|
420
|
-
yield(pkg_set)
|
421
|
-
end
|
437
|
+
yield(pkg_set) unless pkg_set.local?
|
422
438
|
end
|
423
439
|
end
|
424
440
|
|
@@ -458,9 +474,7 @@ module Autoproj
|
|
458
474
|
def register_package(package, block = nil, package_set = main_package_set, file = nil)
|
459
475
|
invalidate_ignored_package_names
|
460
476
|
pkg = PackageDefinition.new(package, package_set, file)
|
461
|
-
if block
|
462
|
-
pkg.add_setup_block(block)
|
463
|
-
end
|
477
|
+
pkg.add_setup_block(block) if block
|
464
478
|
@packages[package.name] = pkg
|
465
479
|
metapackage pkg.package_set.name, pkg.autobuild
|
466
480
|
metapackage "#{pkg.package_set.name}.all", pkg.autobuild
|
@@ -499,11 +513,11 @@ module Autoproj
|
|
499
513
|
#
|
500
514
|
# Unlike {#find_package_definition}, raise if the package does not exist
|
501
515
|
def package_definition_by_name(name)
|
502
|
-
|
503
|
-
pkg
|
504
|
-
else
|
516
|
+
unless (pkg = find_package_definition(name))
|
505
517
|
raise ArgumentError, "no package defined named '#{name}'"
|
506
518
|
end
|
519
|
+
|
520
|
+
pkg
|
507
521
|
end
|
508
522
|
|
509
523
|
# The autobuild description of a package by its name
|
@@ -511,16 +525,15 @@ module Autoproj
|
|
511
525
|
# @param [String,#name] name the package name
|
512
526
|
# @return [Autobuild::Package,nil]
|
513
527
|
def find_autobuild_package(name)
|
514
|
-
|
515
|
-
pkg.autobuild
|
516
|
-
end
|
528
|
+
find_package_definition(name)&.autobuild
|
517
529
|
end
|
518
530
|
|
519
531
|
# Lists all defined packages
|
520
532
|
#
|
521
533
|
# @yieldparam [PackageDefinition] pkg
|
522
534
|
def each_package_definition(&block)
|
523
|
-
return enum_for(__method__)
|
535
|
+
return enum_for(__method__) unless block_given?
|
536
|
+
|
524
537
|
packages.each_value(&block)
|
525
538
|
end
|
526
539
|
|
@@ -528,7 +541,8 @@ module Autoproj
|
|
528
541
|
#
|
529
542
|
# @yieldparam [Autobuild::Package] pkg
|
530
543
|
def each_autobuild_package
|
531
|
-
return enum_for(__method__)
|
544
|
+
return enum_for(__method__) unless block_given?
|
545
|
+
|
532
546
|
each_package_definition { |pkg| yield(pkg.autobuild) }
|
533
547
|
end
|
534
548
|
|
@@ -546,28 +560,24 @@ module Autoproj
|
|
546
560
|
end
|
547
561
|
package_name = validate_package_name_argument(package, require_existing: require_existing)
|
548
562
|
package_set = _package_set || package_set || package.package_set
|
549
|
-
mainline = if mainline == true
|
550
|
-
package_set
|
551
|
-
else mainline
|
552
|
-
end
|
563
|
+
mainline = package_set if mainline == true
|
553
564
|
|
554
565
|
# package_name is already validated, do not re-validate
|
555
566
|
vcs = package_set.importer_definition_for(package_name, require_existing: false)
|
556
567
|
|
557
568
|
package_sets = each_package_set.to_a.dup
|
558
569
|
index = package_sets.find_index(package_set)
|
559
|
-
|
570
|
+
unless index
|
560
571
|
raise RuntimeError, "found inconsistency: package #{package_name} is not in a package set of #{self}"
|
561
572
|
end
|
562
573
|
|
563
|
-
if package_sets[0, index + 1].include?(mainline)
|
564
|
-
return vcs
|
565
|
-
end
|
574
|
+
return vcs if package_sets[0, index + 1].include?(mainline)
|
566
575
|
|
567
576
|
# Then apply the overrides
|
568
577
|
package_sets[(index + 1)..-1].inject(vcs) do |updated_vcs, pkg_set|
|
569
578
|
updated_vcs = pkg_set.overrides_for(package_name, updated_vcs, require_existing: false)
|
570
579
|
return updated_vcs if pkg_set == mainline
|
580
|
+
|
571
581
|
updated_vcs
|
572
582
|
end
|
573
583
|
end
|
@@ -593,7 +603,8 @@ module Autoproj
|
|
593
603
|
package_mainline =
|
594
604
|
if mainline == true
|
595
605
|
pkg.package_set
|
596
|
-
else
|
606
|
+
else
|
607
|
+
mainline
|
597
608
|
end
|
598
609
|
vcs = importer_definition_for(pkg, mainline: package_mainline)
|
599
610
|
|
@@ -633,11 +644,11 @@ module Autoproj
|
|
633
644
|
# @return [PackageSet] the package set
|
634
645
|
# @raise [ArgumentError] if none exists with that name
|
635
646
|
def package_set(name)
|
636
|
-
|
637
|
-
set
|
638
|
-
else
|
647
|
+
unless (set = find_package_set(name))
|
639
648
|
raise ArgumentError, "no package set called #{name} exists"
|
640
649
|
end
|
650
|
+
|
651
|
+
set
|
641
652
|
end
|
642
653
|
|
643
654
|
# The root package set, which represents the workspace itself
|
@@ -662,25 +673,24 @@ module Autoproj
|
|
662
673
|
# fallback defined with {#add_osdeps_overrides}. If true, it will
|
663
674
|
# return such a package as an osdep.
|
664
675
|
def resolve_package_name(name, include_unavailable: false)
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
676
|
+
pkg_names =
|
677
|
+
if (pkg_set = find_metapackage(name))
|
678
|
+
pkg_set.each_package.map(&:name)
|
679
|
+
else
|
680
|
+
[name.to_str]
|
681
|
+
end
|
670
682
|
|
671
683
|
result = []
|
672
684
|
pkg_names.each do |pkg|
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
else
|
679
|
-
raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
|
680
|
-
end
|
681
|
-
rescue PackageNotFound => e
|
685
|
+
result.concat(resolve_single_package_name(pkg))
|
686
|
+
rescue PackageUnavailable => e
|
687
|
+
if include_unavailable
|
688
|
+
result.concat([[:osdeps, pkg]])
|
689
|
+
else
|
682
690
|
raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
|
683
691
|
end
|
692
|
+
rescue PackageNotFound => e
|
693
|
+
raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
|
684
694
|
end
|
685
695
|
result
|
686
696
|
end
|
@@ -717,11 +727,12 @@ module Autoproj
|
|
717
727
|
# @raise PackageNotFound if the given package name cannot be resolved
|
718
728
|
# into a package
|
719
729
|
def resolve_package_name_as_source_package(name)
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
raise PackageNotFound, "cannot resolve #{name}: it is neither a package nor an osdep"
|
730
|
+
unless (pkg = find_autobuild_package(name))
|
731
|
+
raise PackageNotFound,
|
732
|
+
"cannot resolve #{name}: it is neither a package nor an osdep"
|
724
733
|
end
|
734
|
+
|
735
|
+
[[:package, pkg.name]]
|
725
736
|
end
|
726
737
|
|
727
738
|
# @api private
|
@@ -740,7 +751,7 @@ module Autoproj
|
|
740
751
|
# fallback defined with {#add_osdeps_overrides}.
|
741
752
|
# If true, it will return it as an osdep.
|
742
753
|
def resolve_package_name_as_osdep(name)
|
743
|
-
|
754
|
+
osdeps_availability = os_package_resolver.availability_of(name)
|
744
755
|
if osdeps_availability == OSPackageResolver::NO_PACKAGE
|
745
756
|
raise PackageNotFound, "#{name} is not an osdep"
|
746
757
|
end
|
@@ -752,13 +763,13 @@ module Autoproj
|
|
752
763
|
(osdeps_availability == OSPackageResolver::IGNORE)
|
753
764
|
osdeps_overrides = self.osdeps_overrides[name]
|
754
765
|
if osdeps_overrides && (!osdeps_available || osdeps_overrides[:force])
|
755
|
-
|
766
|
+
osdeps_overrides[:packages].inject([]) do |result, src_pkg_name|
|
756
767
|
result.concat(resolve_package_name_as_source_package(src_pkg_name))
|
757
768
|
end.uniq
|
758
769
|
elsif !osdeps_available && (pkg = find_autobuild_package(name))
|
759
|
-
|
770
|
+
[[:package, pkg.name]]
|
760
771
|
elsif osdeps_available || accept_unavailable_osdeps?
|
761
|
-
|
772
|
+
[[:osdeps, name]]
|
762
773
|
elsif osdeps_availability == OSPackageResolver::WRONG_OS
|
763
774
|
raise PackageUnavailable, "#{name} is an osdep, but it is not available for this operating system (#{os_package_resolver.operating_system})"
|
764
775
|
elsif osdeps_availability == OSPackageResolver::UNKNOWN_OS
|
@@ -794,9 +805,9 @@ module Autoproj
|
|
794
805
|
packages.each do |arg|
|
795
806
|
if !arg.respond_to?(:to_str)
|
796
807
|
meta.add(arg)
|
797
|
-
elsif pkg = find_autobuild_package(arg)
|
808
|
+
elsif (pkg = find_autobuild_package(arg))
|
798
809
|
meta.add(pkg)
|
799
|
-
elsif pkg_set = find_metapackage(arg)
|
810
|
+
elsif (pkg_set = find_metapackage(arg))
|
800
811
|
pkg_set.each_package do |pkg_in_set|
|
801
812
|
meta.add(pkg_in_set)
|
802
813
|
end
|
@@ -807,9 +818,7 @@ module Autoproj
|
|
807
818
|
end
|
808
819
|
end
|
809
820
|
|
810
|
-
if block
|
811
|
-
meta.instance_eval(&block)
|
812
|
-
end
|
821
|
+
meta.instance_eval(&block) if block
|
813
822
|
meta
|
814
823
|
end
|
815
824
|
|
@@ -826,19 +835,23 @@ module Autoproj
|
|
826
835
|
# @return [PackageSelection]
|
827
836
|
def layout_packages(validate = true)
|
828
837
|
result = PackageSelection.new
|
829
|
-
Autoproj.in_file(
|
838
|
+
Autoproj.in_file(file) do
|
830
839
|
normalized_layout.each_key do |pkg_or_set|
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
end
|
835
|
-
|
836
|
-
resolve_package_name(pkg_or_set).each do |pkg_type, pkg_name|
|
837
|
-
result.select(pkg_or_set, pkg_name, osdep: (pkg_type == :osdeps), weak: weak)
|
840
|
+
weak =
|
841
|
+
if (meta = metapackages[pkg_or_set])
|
842
|
+
meta.weak_dependencies?
|
838
843
|
end
|
839
|
-
|
840
|
-
|
844
|
+
|
845
|
+
resolve_package_name(pkg_or_set).each do |pkg_type, pkg_name|
|
846
|
+
result.select(
|
847
|
+
pkg_or_set, pkg_name,
|
848
|
+
osdep: (pkg_type == :osdeps),
|
849
|
+
weak: weak
|
850
|
+
)
|
841
851
|
end
|
852
|
+
rescue PackageNotFound => e
|
853
|
+
raise e, "#{pkg_or_set}, which is selected in the layout, "\
|
854
|
+
"is unknown: #{e.message}", e.backtrace
|
842
855
|
end
|
843
856
|
end
|
844
857
|
|
@@ -929,6 +942,7 @@ module Autoproj
|
|
929
942
|
all_package_names.each do |pkg_name|
|
930
943
|
package_type, package_name = resolve_single_package_name(pkg_name).first
|
931
944
|
next if excluded?(package_name) || ignored?(package_name)
|
945
|
+
|
932
946
|
result.select(package_name, package_name, osdep: (package_type == :osdeps))
|
933
947
|
end
|
934
948
|
result
|
@@ -960,20 +974,18 @@ module Autoproj
|
|
960
974
|
package_name = validate_package_name_argument(package_name)
|
961
975
|
|
962
976
|
matches = [package_name]
|
963
|
-
if source_package = find_package_definition(package_name)
|
977
|
+
if (source_package = find_package_definition(package_name))
|
964
978
|
each_metapackage do |meta|
|
965
|
-
if meta.include?(source_package)
|
966
|
-
matches << meta.name
|
967
|
-
end
|
979
|
+
matches << meta.name if meta.include?(source_package)
|
968
980
|
end
|
969
981
|
end
|
970
982
|
|
971
983
|
matches.each do |name|
|
972
|
-
if place = normalized_layout[name]
|
984
|
+
if (place = normalized_layout[name])
|
973
985
|
return place
|
974
986
|
end
|
975
987
|
end
|
976
|
-
|
988
|
+
"/"
|
977
989
|
end
|
978
990
|
|
979
991
|
class NoPackageXML < ConfigError; end
|
@@ -985,35 +997,38 @@ module Autoproj
|
|
985
997
|
def load_package_manifest(pkg)
|
986
998
|
if pkg.respond_to?(:to_str)
|
987
999
|
pkg_definition = find_package_definition(pkg)
|
988
|
-
|
1000
|
+
unless pkg_definition
|
989
1001
|
raise ArgumentError, "#{pkg} is not a known package in #{self}"
|
990
1002
|
end
|
1003
|
+
|
991
1004
|
pkg = pkg_definition
|
992
1005
|
end
|
993
|
-
package
|
1006
|
+
package = pkg.autobuild
|
1007
|
+
package_set = pkg.package_set
|
994
1008
|
|
995
1009
|
# Look for the package's manifest.xml, but fallback to a manifest in
|
996
1010
|
# the package set if present
|
997
1011
|
if package.use_package_xml? && package.checked_out?
|
998
1012
|
manifest_path = File.join(package.srcdir, "package.xml")
|
999
1013
|
raise NoPackageXML.new(package.srcdir), "#{package.name} from "\
|
1000
|
-
|
1001
|
-
|
1014
|
+
"#{package_set.name} has use_package_xml set, but the package has "\
|
1015
|
+
"no package.xml file" unless File.file?(manifest_path)
|
1002
1016
|
|
1003
1017
|
manifest = PackageManifest.load(package, manifest_path,
|
1004
|
-
|
1018
|
+
ros_manifest: true)
|
1005
1019
|
else
|
1006
1020
|
manifest_paths = [File.join(package.srcdir, "manifest.xml")]
|
1007
1021
|
if package_set.local_dir
|
1008
1022
|
manifest_paths << File.join(
|
1009
|
-
package_set.local_dir, "manifests", package.name
|
1023
|
+
package_set.local_dir, "manifests", "#{package.name}.xml"
|
1024
|
+
)
|
1010
1025
|
end
|
1011
1026
|
manifest_path = manifest_paths.find do |path|
|
1012
1027
|
File.file?(path)
|
1013
1028
|
end
|
1014
1029
|
if manifest_path
|
1015
1030
|
manifest = PackageManifest.load(package, manifest_path,
|
1016
|
-
|
1031
|
+
ros_manifest: false)
|
1017
1032
|
end
|
1018
1033
|
end
|
1019
1034
|
|
@@ -1064,9 +1079,7 @@ module Autoproj
|
|
1064
1079
|
# The :force option allows to force the usage of the source package(s),
|
1065
1080
|
# regardless of the availability of the osdeps package.
|
1066
1081
|
def add_osdeps_overrides(osdeps_name, package: osdeps_name, packages: [], force: false)
|
1067
|
-
if package
|
1068
|
-
packages << package
|
1069
|
-
end
|
1082
|
+
packages << package if package
|
1070
1083
|
packages.each { |pkg_name| resolve_package_name(pkg_name) }
|
1071
1084
|
@osdeps_overrides[osdeps_name.to_s] = Hash[packages: packages, force: force]
|
1072
1085
|
end
|
@@ -1083,7 +1096,8 @@ module Autoproj
|
|
1083
1096
|
#
|
1084
1097
|
# Helper for {#expand_package_selection}
|
1085
1098
|
def update_selection(selection, user_selection_string, name, weak)
|
1086
|
-
source_packages
|
1099
|
+
source_packages = Array.new
|
1100
|
+
osdeps = Array.new
|
1087
1101
|
resolve_package_name(name).each do |type, resolved_name|
|
1088
1102
|
if type == :package
|
1089
1103
|
source_packages << resolved_name
|
@@ -1091,10 +1105,10 @@ module Autoproj
|
|
1091
1105
|
osdeps << resolved_name
|
1092
1106
|
end
|
1093
1107
|
end
|
1094
|
-
|
1108
|
+
unless source_packages.empty?
|
1095
1109
|
selection.select(user_selection_string, source_packages, osdep: false, weak: weak)
|
1096
1110
|
end
|
1097
|
-
|
1111
|
+
unless osdeps.empty?
|
1098
1112
|
selection.select(user_selection_string, osdeps, osdep: true, weak: weak)
|
1099
1113
|
end
|
1100
1114
|
end
|
@@ -1110,7 +1124,7 @@ module Autoproj
|
|
1110
1124
|
result = PackageSelection.new
|
1111
1125
|
|
1112
1126
|
all_selected_packages = self.all_selected_packages.to_set
|
1113
|
-
all_source_package_names =
|
1127
|
+
all_source_package_names = all_package_names
|
1114
1128
|
all_osdeps_package_names = os_package_resolver.all_package_names
|
1115
1129
|
selection.each do |sel|
|
1116
1130
|
match_pkg_name = Regexp.new(Regexp.quote(sel))
|
@@ -1142,25 +1156,21 @@ module Autoproj
|
|
1142
1156
|
all_matches.partition { |_, exact_match| exact_match }
|
1143
1157
|
selected_partial_matches, not_selected_partial_matches =
|
1144
1158
|
partial_matches.partition { |pkg_name, _| all_selected_packages.include?(pkg_name) }
|
1145
|
-
if result.has_match_for?(sel)
|
1146
|
-
not_selected_partial_matches.clear
|
1147
|
-
end
|
1159
|
+
not_selected_partial_matches.clear if result.has_match_for?(sel)
|
1148
1160
|
|
1149
|
-
matches =
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1161
|
+
matches =
|
1162
|
+
[exact_matches, selected_partial_matches, not_selected_partial_matches]
|
1163
|
+
.find { |m| !m.empty? }
|
1164
|
+
|
1165
|
+
matches&.each do |pkg_name, _|
|
1166
|
+
update_selection(result, sel, pkg_name, true)
|
1155
1167
|
end
|
1156
1168
|
end
|
1157
1169
|
|
1158
|
-
if filter
|
1159
|
-
result.filter_excluded_and_ignored_packages(self)
|
1160
|
-
end
|
1170
|
+
result.filter_excluded_and_ignored_packages(self) if filter
|
1161
1171
|
|
1162
1172
|
nonresolved = selection - result.matches.keys
|
1163
|
-
|
1173
|
+
[result, nonresolved]
|
1164
1174
|
end
|
1165
1175
|
|
1166
1176
|
attr_reader :moved_packages
|
@@ -1203,9 +1213,7 @@ module Autoproj
|
|
1203
1213
|
# Declare that we should reuse the autoproj installation present at the
|
1204
1214
|
# given path
|
1205
1215
|
def reuse(workspace_root)
|
1206
|
-
if reused_installations.any? { |mnf| mnf.path == workspace_root }
|
1207
|
-
return
|
1208
|
-
end
|
1216
|
+
return if reused_installations.any? { |mnf| mnf.path == workspace_root }
|
1209
1217
|
|
1210
1218
|
manifest = InstallationManifest.from_workspace_root(workspace_root)
|
1211
1219
|
manifest.load
|
@@ -1218,14 +1226,16 @@ module Autoproj
|
|
1218
1226
|
|
1219
1227
|
def self.manifest
|
1220
1228
|
Autoproj.warn_deprecated(
|
1221
|
-
__method__, "use workspace.manifest instead"
|
1229
|
+
__method__, "use workspace.manifest instead"
|
1230
|
+
)
|
1222
1231
|
|
1223
1232
|
workspace.manifest
|
1224
1233
|
end
|
1225
1234
|
|
1226
1235
|
def self.osdeps
|
1227
1236
|
Autoproj.warn_deprecated(
|
1228
|
-
__method__, "use workspace.os_package_resolver or workspace.os_package_installer instead"
|
1237
|
+
__method__, "use workspace.os_package_resolver or workspace.os_package_installer instead"
|
1238
|
+
)
|
1229
1239
|
|
1230
1240
|
workspace.os_package_resolver
|
1231
1241
|
end
|
@@ -1234,7 +1244,7 @@ module Autoproj
|
|
1234
1244
|
workspace.config
|
1235
1245
|
end
|
1236
1246
|
|
1237
|
-
def self.add_osdeps_overrides(*args, &block)
|
1238
|
-
manifest.add_osdeps_overrides(*args, &block)
|
1247
|
+
def self.add_osdeps_overrides(*args, **kw, &block)
|
1248
|
+
manifest.add_osdeps_overrides(*args, **kw, &block)
|
1239
1249
|
end
|
1240
1250
|
end
|
data/lib/autoproj/metapackage.rb
CHANGED
@@ -43,9 +43,7 @@ module Autoproj
|
|
43
43
|
|
44
44
|
# Remove a package from this metapackage
|
45
45
|
def remove(pkg)
|
46
|
-
if pkg.respond_to?(:name)
|
47
|
-
pkg = pkg.name
|
48
|
-
end
|
46
|
+
pkg = pkg.name if pkg.respond_to?(:name)
|
49
47
|
packages_by_name.delete(pkg)
|
50
48
|
end
|
51
49
|
|
@@ -60,9 +58,7 @@ module Autoproj
|
|
60
58
|
#
|
61
59
|
# @param [String,#name] pkg the package or package name
|
62
60
|
def include?(pkg)
|
63
|
-
|
64
|
-
pkg = pkg.name
|
65
|
-
end
|
61
|
+
pkg = pkg.name unless pkg.respond_to?(:to_str)
|
66
62
|
packages_by_name.has_key?(pkg)
|
67
63
|
end
|
68
64
|
|