autoproj 1.13.7 → 2.0.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gemtest +0 -0
  3. data/Manifest.txt +27 -21
  4. data/Rakefile +4 -6
  5. data/bin/alocate +5 -1
  6. data/bin/amake +3 -53
  7. data/bin/aup +3 -50
  8. data/bin/autoproj +3 -264
  9. data/bin/autoproj_bootstrap +294 -349
  10. data/bin/autoproj_bootstrap.in +27 -3
  11. data/lib/autoproj.rb +23 -1
  12. data/lib/autoproj/autobuild.rb +51 -89
  13. data/lib/autoproj/base.rb +0 -9
  14. data/lib/autoproj/build_option.rb +1 -3
  15. data/lib/autoproj/cli.rb +1 -0
  16. data/lib/autoproj/cli/base.rb +155 -0
  17. data/lib/autoproj/cli/bootstrap.rb +119 -0
  18. data/lib/autoproj/cli/build.rb +72 -0
  19. data/lib/autoproj/cli/cache.rb +31 -0
  20. data/lib/autoproj/cli/clean.rb +37 -0
  21. data/lib/autoproj/cli/commit.rb +41 -0
  22. data/lib/autoproj/cli/doc.rb +22 -0
  23. data/lib/autoproj/cli/envsh.rb +22 -0
  24. data/lib/autoproj/cli/inspection_tool.rb +73 -0
  25. data/lib/autoproj/cli/locate.rb +96 -0
  26. data/lib/autoproj/cli/log.rb +26 -0
  27. data/lib/autoproj/cli/main.rb +249 -0
  28. data/lib/autoproj/cli/main_test.rb +57 -0
  29. data/lib/autoproj/cli/osdeps.rb +30 -0
  30. data/lib/autoproj/cli/query.rb +43 -0
  31. data/lib/autoproj/cli/reconfigure.rb +19 -0
  32. data/lib/autoproj/cli/reset.rb +7 -32
  33. data/lib/autoproj/cli/show.rb +219 -0
  34. data/lib/autoproj/cli/snapshot.rb +1 -1
  35. data/lib/autoproj/cli/status.rb +149 -0
  36. data/lib/autoproj/cli/switch_config.rb +28 -0
  37. data/lib/autoproj/cli/tag.rb +9 -35
  38. data/lib/autoproj/cli/test.rb +34 -55
  39. data/lib/autoproj/cli/update.rb +158 -0
  40. data/lib/autoproj/cli/versions.rb +32 -69
  41. data/lib/autoproj/configuration.rb +95 -34
  42. data/lib/autoproj/default.osdeps +25 -35
  43. data/lib/autoproj/environment.rb +85 -63
  44. data/lib/autoproj/exceptions.rb +50 -0
  45. data/lib/autoproj/gitorious.rb +11 -9
  46. data/lib/autoproj/manifest.rb +199 -231
  47. data/lib/autoproj/metapackage.rb +0 -8
  48. data/lib/autoproj/ops/build.rb +1 -17
  49. data/lib/autoproj/ops/configuration.rb +92 -90
  50. data/lib/autoproj/ops/import.rb +222 -0
  51. data/lib/autoproj/ops/loader.rb +18 -8
  52. data/lib/autoproj/ops/main_config_switcher.rb +45 -73
  53. data/lib/autoproj/ops/snapshot.rb +5 -10
  54. data/lib/autoproj/ops/tools.rb +10 -44
  55. data/lib/autoproj/options.rb +35 -6
  56. data/lib/autoproj/osdeps.rb +97 -68
  57. data/lib/autoproj/package_selection.rb +39 -20
  58. data/lib/autoproj/package_set.rb +26 -24
  59. data/lib/autoproj/reporter.rb +91 -0
  60. data/lib/autoproj/system.rb +50 -149
  61. data/lib/autoproj/variable_expansion.rb +32 -6
  62. data/lib/autoproj/vcs_definition.rb +57 -17
  63. data/lib/autoproj/version.rb +1 -1
  64. data/lib/autoproj/workspace.rb +550 -0
  65. data/test/ops/test_snapshot.rb +26 -0
  66. data/test/test_package.rb +30 -0
  67. data/test/test_vcs_definition.rb +46 -0
  68. metadata +55 -50
  69. data/bin/autolocate +0 -3
  70. data/bin/autoproj-bootstrap +0 -68
  71. data/bin/autoproj-cache +0 -18
  72. data/bin/autoproj-clean +0 -13
  73. data/bin/autoproj-commit +0 -10
  74. data/bin/autoproj-create-set +0 -118
  75. data/bin/autoproj-doc +0 -28
  76. data/bin/autoproj-envsh +0 -14
  77. data/bin/autoproj-list +0 -69
  78. data/bin/autoproj-locate +0 -85
  79. data/bin/autoproj-log +0 -5
  80. data/bin/autoproj-query +0 -82
  81. data/bin/autoproj-reset +0 -13
  82. data/bin/autoproj-show +0 -192
  83. data/bin/autoproj-snapshot +0 -27
  84. data/bin/autoproj-switch-config +0 -24
  85. data/bin/autoproj-tag +0 -13
  86. data/bin/autoproj-test +0 -31
  87. data/bin/autoproj-versions +0 -20
  88. data/bin/autoproj_stress_test +0 -40
  89. data/lib/autoproj/cmdline.rb +0 -1649
@@ -0,0 +1,50 @@
1
+ module Autoproj
2
+ class ConfigError < RuntimeError
3
+ attr_accessor :file
4
+ def initialize(file = nil)
5
+ super
6
+ @file = file
7
+ end
8
+ end
9
+ class InternalError < RuntimeError; end
10
+
11
+ # Exception raised when trying to resolve a package name and it failed
12
+ class PackageNotFound < ConfigError
13
+ end
14
+
15
+ class InputError < RuntimeError; end
16
+
17
+ # Exception raised when a caller requires to use an excluded package
18
+ class ExcludedPackage < ConfigError
19
+ attr_reader :name
20
+ def initialize(name)
21
+ @name = name
22
+ end
23
+ end
24
+
25
+ # Exception raised when an unknown package is encountered
26
+ class UnknownPackage < ConfigError
27
+ attr_reader :name
28
+ def initialize(name)
29
+ @name = name
30
+ end
31
+ end
32
+
33
+ class MissingOSDep < ConfigError; end
34
+
35
+ # Exception raised by
36
+ # PackageSelection#filter_excluded_and_ignored_packages when a given
37
+ # selection is completely excluded
38
+ class ExcludedSelection < ConfigError
39
+ attr_reader :selection
40
+ def initialize(selection)
41
+ @selection = selection
42
+ end
43
+ end
44
+
45
+ class UserError < RuntimeError; end
46
+
47
+ class WorkspaceAlreadyCreated < RuntimeError; end
48
+ end
49
+
50
+
@@ -26,8 +26,10 @@ module Autoproj
26
26
  :ssh_url => "git@#{base_url}:",
27
27
  :fallback_to_http => true,
28
28
  :default => 'http,ssh',
29
- :disabled_methods => []
30
-
29
+ :disabled_methods => [],
30
+ config: Autoproj.config
31
+
32
+ config = options.delete(:config)
31
33
  disabled_methods = Array(options[:disabled_methods])
32
34
 
33
35
  access_methods = Hash[
@@ -58,17 +60,17 @@ module Autoproj
58
60
  value
59
61
  end
60
62
 
61
- configuration_option name, 'string',
63
+ config.declare name, 'string',
62
64
  :default => options[:default],
63
65
  :doc => gitorious_long_doc, &validator
64
66
 
65
- access_mode = Autoproj.config.get(name)
67
+ access_mode = config.get(name)
66
68
  begin
67
69
  validator[access_mode]
68
70
  rescue Autoproj::InputError => e
69
71
  Autoproj.warn e.message
70
- Autoproj.config.reset(name)
71
- access_mode = Autoproj.config.get(name)
72
+ config.reset(name)
73
+ access_mode = config.get(name)
72
74
  end
73
75
  access_mode = access_methods[access_mode] || access_mode
74
76
  pull, push = access_mode.split(',')
@@ -77,7 +79,7 @@ module Autoproj
77
79
  elsif method == "http" then options[:http_url]
78
80
  elsif method == "ssh" then options[:ssh_url]
79
81
  end
80
- Autoproj.change_option("#{name}#{var_suffix}", url)
82
+ config.set("#{name}#{var_suffix}", url)
81
83
  end
82
84
 
83
85
  Autoproj.add_source_handler name.downcase do |url, vcs_options|
@@ -87,8 +89,8 @@ module Autoproj
87
89
  if url !~ /^\//
88
90
  url = "/#{url}"
89
91
  end
90
- pull_base_url = Autoproj.user_config("#{name}_ROOT")
91
- push_base_url = Autoproj.user_config("#{name}_PUSH_ROOT")
92
+ pull_base_url = config.get("#{name}_ROOT")
93
+ push_base_url = config.get("#{name}_PUSH_ROOT")
92
94
  Hash[type: 'git',
93
95
  url: "#{pull_base_url}#{url}",
94
96
  push_to: "#{push_base_url}#{url}",
@@ -7,31 +7,9 @@ require 'rexml/document'
7
7
  require 'win32/dir' if RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
8
8
 
9
9
  module Autoproj
10
- @build_system_dependencies = Set.new
11
-
12
- # Declare OS packages that are required to import and build the packages
13
- #
14
- # It is used by autoproj itself to install the importers and/or the build
15
- # systems for the packages.
16
- def self.add_build_system_dependency(*names)
17
- @build_system_dependencies |= names.to_set
18
- end
19
-
20
- class << self
21
- # Returns the set of OS packages that are needed to build and/or import
22
- # the packages
23
- #
24
- # See Autoproj.add_build_system_dependency
25
- attr_reader :build_system_dependencies
26
- end
27
-
28
10
  # The Manifest class represents the information included in the main
29
11
  # manifest file, and allows to manipulate it
30
12
  class Manifest
31
- # The set of packages that are selected by the user, either through the
32
- # manifest file or through the command line, as a set of package names
33
- attr_accessor :explicit_selection
34
-
35
13
  # Set the package sets that are available on this manifest
36
14
  #
37
15
  # This is set externally at loading time. {load_and_update_package_sets}
@@ -40,12 +18,6 @@ module Autoproj
40
18
  # @return [Array<PackageSet>]
41
19
  attr_writer :package_sets
42
20
 
43
- # Returns true if +pkg_name+ has been explicitely selected, either by
44
- # the command line or through the layout
45
- def explicitly_selected_package?(pkg_name)
46
- explicit_selection && explicit_selection.include?(pkg_name)
47
- end
48
-
49
21
  # Loads the manifest file located at +file+ and returns the Manifest
50
22
  # instance that represents it
51
23
  def self.load(file)
@@ -138,10 +110,7 @@ module Autoproj
138
110
  @manifest_exclusions = Set.new
139
111
 
140
112
  @constant_definitions = Hash.new
141
- if Autoproj.has_config_key?('manifest_source')
142
- @vcs = VCSDefinition.from_raw(Autoproj.user_config('manifest_source'))
143
- end
144
- @package_sets << LocalPackageSet.new(self, vcs)
113
+ @package_sets << LocalPackageSet.new(self)
145
114
  end
146
115
 
147
116
 
@@ -167,16 +136,17 @@ module Autoproj
167
136
  end
168
137
  end
169
138
 
139
+ # Enumerates the package names of all ignored packages
140
+ def each_excluded_package
141
+ each_autobuild_package do |pkg|
142
+ yield(pkg) if excluded?(pkg.name)
143
+ end
144
+ end
145
+
170
146
  # Enumerates the package names of all ignored packages
171
147
  def each_ignored_package
172
- ignored_packages.each do |l|
173
- if pkg_set = metapackages[l]
174
- pkg_set.each_package do |pkg|
175
- yield(pkg.name)
176
- end
177
- else
178
- yield(l)
179
- end
148
+ each_autobuild_package do |pkg|
149
+ yield(pkg) if ignored?(pkg.name)
180
150
  end
181
151
  end
182
152
 
@@ -346,7 +316,9 @@ module Autoproj
346
316
 
347
317
  # Load the package set information
348
318
  def load_and_update_package_sets
349
- Ops::Configuration.new(self, Ops.loader).load_and_update_package_sets
319
+ Autoproj.warn_deprecated __method__,
320
+ "use Ops::Configuration instead"
321
+ Ops::Configuration.new(Autoproj.workspace).load_and_update_package_sets
350
322
  end
351
323
 
352
324
  # Returns a package set that is used by autoproj for its own purposes
@@ -403,22 +375,26 @@ module Autoproj
403
375
  end
404
376
  end
405
377
 
406
- def find_package_definition(name)
407
- packages[name]
408
- end
409
-
410
378
  def find_package(name)
411
- packages[name]
379
+ if name.respond_to?(:name)
380
+ name = name.name
381
+ end
382
+
383
+ packages[name.to_str]
412
384
  end
413
385
 
414
386
  def find_autobuild_package(name)
415
- if pkg = packages[name]
387
+ if name.respond_to?(:name)
388
+ name = name.name
389
+ end
390
+
391
+ if pkg = packages[name.to_str]
416
392
  pkg.autobuild
417
393
  end
418
394
  end
419
395
 
420
396
  def package(name)
421
- packages[name]
397
+ find_package(name)
422
398
  end
423
399
 
424
400
  # @deprecated use {each_autobuild_package} instead
@@ -449,16 +425,19 @@ module Autoproj
449
425
  # @deprecated use Ops::Tools.create_autobuild_package or include
450
426
  # Ops::Tools into your class to get it as instance method
451
427
  def self.create_autobuild_package(vcs, text_name, into)
428
+ Autoproj.warn_deprecated __method__, "use Ops::Tools.create_autobuild_package instead"
452
429
  Ops::Tools.create_autobuild_package(vcs, text_name, into)
453
430
  end
454
431
 
455
432
  # @deprecated use Ops::Configuration#update_main_configuration
456
433
  def update_yourself(only_local = false)
457
- Ops::Configuration.new(self, Ops.loader).update_main_configuration(only_local)
434
+ Autoproj.warn_deprecated __method__, "use Ops::Configuration instead"
435
+ Ops::Configuration.new(Autoproj.workspace).update_main_configuration(only_local)
458
436
  end
459
437
 
460
438
  # @deprecated use Ops::Configuration.update_remote_package_set
461
439
  def update_remote_set(vcs, only_local = false)
440
+ Autoproj.warn_deprecated __method__, "use Ops::Configuration instead"
462
441
  Ops::Configuration.update_remote_package_set(vcs, only_local)
463
442
  end
464
443
 
@@ -469,21 +448,34 @@ module Autoproj
469
448
  # given package, defaults to the package's definition source (as
470
449
  # returned by {definition_package_set}) if not given
471
450
  # @return [VCSDefinition] the VCS definition object
472
- def importer_definition_for(package_name, package_source = definition_package_set(package_name))
473
- vcs = package_source.importer_definition_for(package_name)
451
+ def importer_definition_for(package_name, package_set = definition_package_set(package_name),
452
+ options = Hash.new)
453
+ options = validate_options options, mainline: nil
454
+ mainline =
455
+ if options[:mainline] == true
456
+ package_set
457
+ else
458
+ options[:mainline]
459
+ end
460
+
461
+ vcs = package_set.importer_definition_for(package_name)
474
462
  return if !vcs
475
463
 
476
464
  # Get the sets that come *after* the one that defines the package to
477
465
  # apply the overrides
478
466
  package_sets = each_package_set.to_a.dup
479
- while !package_sets.empty? && package_sets.first != package_source
480
- package_sets.shift
467
+ while !package_sets.empty? && package_sets.first != package_set
468
+ set = package_sets.shift
469
+ return vcs if set == mainline
481
470
  end
482
- package_sets.shift
471
+ set = package_sets.shift
472
+ return vcs if set == mainline
483
473
 
484
474
  # Then apply the overrides
485
475
  package_sets.inject(vcs) do |updated_vcs, pkg_set|
486
- pkg_set.overrides_for(package_name, updated_vcs)
476
+ updated_vcs = pkg_set.overrides_for(package_name, updated_vcs)
477
+ return updated_vcs if pkg_set == mainline
478
+ updated_vcs
487
479
  end
488
480
  end
489
481
 
@@ -503,13 +495,13 @@ module Autoproj
503
495
  # * S1 must have a VCS line for P
504
496
  # * S0 can have a VCS line for P, which would override the one defined
505
497
  # by S1
506
- def load_importers
498
+ def load_importers(options = Hash.new)
507
499
  packages.each_value do |pkg|
508
- vcs = importer_definition_for(pkg.autobuild.name, pkg.package_set) ||
500
+ vcs = importer_definition_for(pkg.autobuild.name, pkg.package_set, options) ||
509
501
  pkg.package_set.default_importer
510
502
 
503
+
511
504
  if vcs
512
- Autoproj.add_build_system_dependency vcs.type
513
505
  pkg.vcs = vcs
514
506
  pkg.autobuild.importer = vcs.create_autobuild_importer
515
507
  else
@@ -535,7 +527,7 @@ module Autoproj
535
527
  # Returns the PackageSet object for the given package set, or raises
536
528
  # ArgumentError if none exists with that name
537
529
  def package_set(name)
538
- set = each_package_set(false).find { |set| set.name == name }
530
+ set = each_package_set.find { |set| set.name == name }
539
531
  if !set
540
532
  raise ArgumentError, "no package set called #{name} exists"
541
533
  end
@@ -546,14 +538,6 @@ module Autoproj
546
538
  each_package_set.find(&:main?)
547
539
  end
548
540
 
549
- # Exception raised when a caller requires to use an excluded package
550
- class ExcludedPackage < ConfigError
551
- attr_reader :name
552
- def initialize(name)
553
- @name = name
554
- end
555
- end
556
-
557
541
  # Resolves the given +name+, where +name+ can either be the name of a
558
542
  # source or the name of a package.
559
543
  #
@@ -562,18 +546,20 @@ module Autoproj
562
546
  # [type, package_name]
563
547
  #
564
548
  # where +type+ can either be :package or :osdeps (as symbols)
565
- #
566
- # The returned array can be empty if +name+ is an ignored package
567
- def resolve_package_name(name, options = Hash.new)
549
+ def resolve_package_name(name)
568
550
  if pkg_set = find_metapackage(name)
569
551
  pkg_names = pkg_set.each_package.map(&:name)
570
552
  else
571
- pkg_names = [name]
553
+ pkg_names = [name.to_str]
572
554
  end
573
555
 
574
556
  result = []
575
557
  pkg_names.each do |pkg|
576
- result.concat(resolve_single_package_name(pkg, options))
558
+ begin
559
+ result.concat(resolve_single_package_name(pkg))
560
+ rescue PackageNotFound
561
+ raise PackageNotFound, "cannot resolve #{pkg}: it is not a package, not a metapackage and not an osdep"
562
+ end
577
563
  end
578
564
  result
579
565
  end
@@ -591,7 +577,7 @@ module Autoproj
591
577
  next if result.include?(pkg_name)
592
578
  result << pkg_name
593
579
 
594
- pkg = Autobuild::Package[pkg_name]
580
+ pkg = find_autobuild_package(pkg_name)
595
581
  pkg.dependencies.each do |dep_name|
596
582
  queue << dep_name
597
583
  end
@@ -604,83 +590,62 @@ module Autoproj
604
590
  #
605
591
  # This is a helper method for #resolve_package_name. Do not use
606
592
  # directly
607
- def resolve_single_package_name(name, options = Hash.new) # :nodoc:
608
- options = Kernel.validate_options options, :filter => true
609
-
610
- explicit_selection = explicitly_selected_package?(name)
611
- osdeps_availability = osdeps.availability_of(name)
612
- available_as_source = Autobuild::Package[name]
613
-
614
- osdeps_overrides = Autoproj.manifest.osdeps_overrides[name]
615
- if osdeps_overrides
616
- source_packages = osdeps_overrides[:packages].dup
617
- force_source_usage = osdeps_overrides[:force]
618
- begin
619
- source_packages = source_packages.inject([]) do |result, src_pkg_name|
620
- result.concat(resolve_package_name(src_pkg_name))
621
- end.uniq
622
- available_as_source = true
623
- rescue ExcludedPackage
624
- force_source_usage = false
625
- available_as_source = false
626
- end
627
-
628
- if source_packages.empty?
629
- source_packages << [:package, name]
630
- end
593
+ #
594
+ # @return [nil,Array] either nil if there is no such osdep, or a list of
595
+ # (type, package_name) pairs where type is either :package or :osdep and
596
+ # package_name the corresponding package name
597
+ def resolve_single_package_name(name)
598
+ resolve_package_name_as_osdep(name)
599
+ rescue PackageNotFound => osdep_error
600
+ begin
601
+ resolve_package_name_as_source_package(name)
602
+ rescue PackageNotFound
603
+ raise PackageNotFound, "#{osdep_error} and it cannot be resolved as a source package"
631
604
  end
605
+ end
632
606
 
633
- if force_source_usage
634
- return source_packages
635
- elsif !explicit_selection
636
- if osdeps_availability == Autoproj::OSDependencies::AVAILABLE
637
- return [[:osdeps, name]]
638
- elsif osdeps_availability == Autoproj::OSDependencies::IGNORE
639
- return []
640
- end
641
-
642
- if osdeps_availability == Autoproj::OSDependencies::UNKNOWN_OS
643
- # If we can't handle that OS, but other OSes have a
644
- # definition for it, we assume that it can be installed as
645
- # an external package. However, if it is also available as a
646
- # source package, prompt the user
647
- if !available_as_source || explicit_osdeps_selection(name)
648
- return [[:osdeps, name]]
649
- end
650
- end
651
-
652
- # No source, no osdeps.
653
- # If the package is ignored by the manifest, just return empty.
654
- # Otherwise, generate a proper error message
655
- # Call osdeps again, but this time to get
656
- # a proper error message.
657
- if !available_as_source
658
- if ignored?(name)
659
- return []
660
- end
661
- begin
662
- osdeps.resolve_os_dependencies([name].to_set)
663
- rescue Autoproj::ConfigError => e
664
- if osdeps_availability != Autoproj::OSDependencies::NO_PACKAGE && !osdeps.os_package_handler.enabled?
665
- if !@ignored_os_dependencies.include?(name)
666
- Autoproj.warn "some package depends on the #{name} osdep: #{e.message}"
667
- Autoproj.warn "this osdeps dependency is simply ignored as you asked autoproj to not install osdeps packages"
668
- @ignored_os_dependencies << name
669
- end
670
- # We are not asked to install OS packages, just ignore
671
- return []
672
- end
673
- raise
674
- end
675
- # Should never reach further than that
676
- end
677
- elsif !available_as_source
678
- raise ConfigError, "cannot resolve #{name}: it is not a package, not a metapackage and not an osdeps"
679
- end
680
- if source_packages
681
- return source_packages
607
+ def resolve_package_name_as_source_package(name)
608
+ if pkg = find_autobuild_package(name)
609
+ return [[:package, pkg.name]]
682
610
  else
683
- return [[:package, name]]
611
+ raise PackageNotFound, "cannot resolve #{name}: it is neither a package nor an osdep"
612
+ end
613
+ end
614
+
615
+ # @api private
616
+ #
617
+ # Resolve a potential osdep name, either as the osdep itself, or as
618
+ # source packages that are used as osdep override
619
+ #
620
+ # @return [nil,Array] either nil if there is no such osdep, or a list of
621
+ # (type, package_name) pairs where type is either :package or :osdep and
622
+ # package_name the corresponding package name
623
+ def resolve_package_name_as_osdep(name)
624
+ osdeps_availability = osdeps.availability_of(name)
625
+ if osdeps_availability == Autoproj::OSDependencies::NO_PACKAGE
626
+ raise PackageNotFound, "cannot resolve #{name}: it is not an osdep"
627
+ end
628
+
629
+ # There is an osdep definition for this package, check the
630
+ # overrides
631
+ osdeps_available =
632
+ (osdeps_availability == OSDependencies::AVAILABLE) ||
633
+ (osdeps_availability == OSDependencies::IGNORE)
634
+ osdeps_overrides = self.osdeps_overrides[name]
635
+ if osdeps_overrides && (!osdeps_available || osdeps_overrides[:force])
636
+ source_packages = osdeps_overrides[:packages].inject([]) do |result, src_pkg_name|
637
+ result.concat(resolve_package_name_as_source_package(src_pkg_name))
638
+ end.uniq
639
+ elsif !osdeps_available && (pkg = find_autobuild_package(name))
640
+ return [[:package, pkg.name]]
641
+ elsif osdeps_available
642
+ return [[:osdeps, name]]
643
+ elsif osdeps_availability == OSDependencies::WRONG_OS
644
+ raise PackageNotFound, "#{name} is an osdep, but it is not available for this operating system"
645
+ elsif osdeps_availability == OSDependencies::UNKNOWN_OS
646
+ raise PackageNotFound, "#{name} is an osdep, but the local operating system is unavailable"
647
+ elsif osdeps_availability == OSDependencies::NONEXISTENT
648
+ raise PackageNotFound, "#{name} is an osdep, but it is explicitely marked as 'nonexistent' for this operating system"
684
649
  end
685
650
  end
686
651
 
@@ -688,7 +653,7 @@ module Autoproj
688
653
  # the first case, we return all packages defined by that source. In the
689
654
  # latter case, we return the singleton array [name]
690
655
  def resolve_package_set(name)
691
- if Autobuild::Package[name]
656
+ if find_autobuild_package(name)
692
657
  [name]
693
658
  else
694
659
  pkg_set = find_metapackage(name)
@@ -721,7 +686,7 @@ module Autoproj
721
686
  packages.each do |pkg_name|
722
687
  package_names = resolve_package_set(pkg_name)
723
688
  package_names.each do |pkg_name|
724
- meta.add(Autobuild::Package[pkg_name])
689
+ meta.add(find_autobuild_package(pkg_name))
725
690
  end
726
691
  end
727
692
 
@@ -752,7 +717,7 @@ module Autoproj
752
717
  end
753
718
 
754
719
 
755
- result.select(pkg_or_set, resolve_package_set(pkg_or_set), weak)
720
+ result.select(pkg_or_set, resolve_package_set(pkg_or_set), weak: weak)
756
721
  rescue UnknownPackage => e
757
722
  raise e, "#{e.name}, which is selected in the layout, is unknown: #{e.message}", e.backtrace
758
723
  end
@@ -787,7 +752,7 @@ module Autoproj
787
752
 
788
753
  # Returns all defined package names, minus the excluded and ignored ones
789
754
  def all_package_names
790
- Autobuild::Package.each.map { |name, _| name }.to_set
755
+ each_autobuild_package.map(&:name)
791
756
  end
792
757
 
793
758
  # Returns all the packages that can be built in this installation
@@ -808,7 +773,7 @@ module Autoproj
808
773
  # If it is false, the method will simply return false on non-defined
809
774
  # packages
810
775
  def package_enabled?(name, validate = true)
811
- if !Autobuild::Package[name] && !osdeps.has?(name)
776
+ if !find_autobuild_package(name) && !osdeps.has?(name)
812
777
  if validate
813
778
  raise ArgumentError, "package #{name} does not exist"
814
779
  end
@@ -835,9 +800,9 @@ module Autoproj
835
800
  # Returns the set of packages that are selected by the layout
836
801
  def all_selected_packages(validate = true)
837
802
  result = Set.new
838
- root = default_packages(validate).packages.to_set
803
+ root = default_packages(validate).source_packages.to_set
839
804
  root.each do |pkg_name|
840
- Autobuild::Package[pkg_name].all_dependencies(result)
805
+ find_autobuild_package(pkg_name).all_dependencies(result)
841
806
  end
842
807
  result | root
843
808
  end
@@ -971,7 +936,7 @@ module Autoproj
971
936
  required_os_packages = Set.new
972
937
  package_os_deps = Hash.new { |h, k| h[k] = Array.new }
973
938
  packages.each do |pkg_name|
974
- pkg = Autobuild::Package[pkg_name]
939
+ pkg = find_autobuild_package(pkg_name)
975
940
  if !pkg
976
941
  raise InternalError, "internal error: #{pkg_name} is not a package"
977
942
  end
@@ -1013,11 +978,11 @@ module Autoproj
1013
978
  end
1014
979
 
1015
980
  # Installs the OS dependencies that are required by the given packages
1016
- def install_os_dependencies(packages)
981
+ def install_os_dependencies(packages, options = Hash.new)
1017
982
  required_os_packages, package_os_deps = list_os_dependencies(packages)
1018
983
  required_os_packages =
1019
984
  filter_os_dependencies(required_os_packages, package_os_deps)
1020
- osdeps.install(required_os_packages)
985
+ osdeps.install(required_os_packages, options)
1021
986
  end
1022
987
 
1023
988
  # The set of overrides added with #add_osdeps_overrides
@@ -1038,10 +1003,12 @@ module Autoproj
1038
1003
  # The :force option allows to force the usage of the source package(s),
1039
1004
  # regardless of the availability of the osdeps package.
1040
1005
  def add_osdeps_overrides(osdeps_name, options)
1041
- options = Kernel.validate_options options, :package => nil, :packages => [], :force => false
1006
+ options = Kernel.validate_options options, package: osdeps_name, packages: [], force: false
1042
1007
  if pkg = options.delete(:package)
1043
1008
  options[:packages] << pkg
1044
1009
  end
1010
+ packages = options[:packages]
1011
+ packages.each { |pkg_name| resolve_package_name(pkg_name) }
1045
1012
  @osdeps_overrides[osdeps_name.to_s] = options
1046
1013
  end
1047
1014
 
@@ -1051,95 +1018,99 @@ module Autoproj
1051
1018
  @osdeps_overrides.delete(osdeps_name.to_s)
1052
1019
  end
1053
1020
 
1054
- # Exception raised when an unknown package is encountered
1055
- class UnknownPackage < ConfigError
1056
- attr_reader :name
1057
- def initialize(name)
1058
- @name = name
1021
+ PackageSelection = Autoproj::PackageSelection
1022
+
1023
+ # @api private
1024
+ #
1025
+ # Helper for {#expand_package_selection}
1026
+ def update_selection(selection, user_selection_string, name, weak)
1027
+ source_packages, osdeps = Array.new, Array.new
1028
+ resolve_package_name(name).each do |type, resolved_name|
1029
+ if type == :package
1030
+ source_packages << resolved_name
1031
+ else
1032
+ osdeps << resolved_name
1033
+ end
1034
+ end
1035
+ if !source_packages.empty?
1036
+ selection.select(user_selection_string, source_packages, osdep: false, weak: weak)
1037
+ end
1038
+ if !osdeps.empty?
1039
+ selection.select(user_selection_string, osdeps, osdep: true, weak: weak)
1059
1040
  end
1060
1041
  end
1061
1042
 
1062
- PackageSelection = Autoproj::PackageSelection
1063
-
1064
- # Package selection can be done in three ways:
1065
- # * as a subdirectory in the layout
1066
- # * as a on-disk directory
1067
- # * as a package name
1043
+ # Normalizes package selection strings into a PackageSelection object
1068
1044
  #
1069
- # This method converts the first two directories into the third one
1045
+ # @param [Array<String>] selection the package selection strings. For
1046
+ # source packages, it can either be the package name, a package set
1047
+ # name, or a prefix of the package's source directory. For osdeps, it
1048
+ # has to be the plain package name
1049
+ # @return [PackageSelection, Array<String>]
1070
1050
  def expand_package_selection(selection, options = Hash.new)
1071
1051
  options = Kernel.validate_options options, filter: true
1072
-
1073
1052
  result = PackageSelection.new
1074
1053
 
1075
- # All the packages that are available on this installation
1076
- all_layout_packages = self.all_selected_packages
1077
-
1078
1054
  # First, remove packages that are directly referenced by name or by
1079
- # package set names
1055
+ # package set names. When it comes to packages (NOT package sets),
1056
+ # we prefer the ones selected in the layout
1057
+ all_selected_packages = self.all_selected_packages
1058
+ candidates = all_selected_packages.to_a +
1059
+ each_metapackage.map { |metapkg| [metapkg.name, metapkg.weak_dependencies?] }
1080
1060
  selection.each do |sel|
1081
1061
  match_pkg_name = Regexp.new(Regexp.quote(sel))
1082
-
1083
- packages = all_layout_packages.
1084
- find_all { |pkg_name| pkg_name =~ match_pkg_name }.
1085
- to_set
1086
- if !packages.empty?
1087
- result.select(sel, packages, true)
1088
- end
1089
-
1090
- each_metapackage do |pkg|
1091
- if pkg.name =~ match_pkg_name
1092
- packages = resolve_package_set(pkg.name).to_set
1093
- packages = (packages & all_layout_packages)
1094
- result.select(sel, packages, pkg.weak_dependencies?)
1095
- end
1062
+ candidates.each do |name, weak|
1063
+ next if name !~ match_pkg_name
1064
+ update_selection(result, sel, name, true)
1096
1065
  end
1097
1066
  end
1098
1067
 
1099
- pending_selections = Hash.new
1100
-
1101
- # Finally, check for package source directories
1102
- all_packages = self.all_package_names
1103
- all_osdeps_packages = osdeps.all_package_names
1068
+ pending_selections = Hash.new { |h, k| h[k] = Array.new }
1104
1069
 
1070
+ # Finally, check for partial matches
1071
+ all_source_package_names = self.all_package_names
1072
+ all_osdeps_package_names = osdeps.all_package_names
1105
1073
  selection.each do |sel|
1106
1074
  match_pkg_name = Regexp.new(Regexp.quote(sel))
1107
- matching_packages = all_packages.map do |pkg_name|
1108
- pkg = Autobuild::Package[pkg_name]
1075
+ all_matches = Array.new
1076
+ all_source_package_names.each do |pkg_name|
1077
+ pkg = find_autobuild_package(pkg_name)
1109
1078
  if pkg_name =~ match_pkg_name ||
1110
1079
  "#{sel}/" =~ Regexp.new("^#{Regexp.quote(pkg.srcdir)}/") ||
1111
1080
  pkg.srcdir =~ Regexp.new("^#{Regexp.quote(sel)}")
1112
- [pkg_name, (pkg_name == sel || pkg.srcdir == sel)]
1081
+ all_matches << [pkg_name, (pkg_name == sel || pkg.srcdir == sel)]
1113
1082
  end
1114
- end.compact
1115
- matching_osdeps_packages = all_osdeps_packages.find_all do |pkg_name|
1083
+ end
1084
+ all_osdeps_package_names.each do |pkg_name|
1116
1085
  if pkg_name =~ match_pkg_name
1117
- [pkg_name, pkg_name == sel]
1086
+ all_matches << [pkg_name, pkg_name == sel]
1118
1087
  end
1119
- end.compact
1088
+ end
1120
1089
 
1121
- (matching_packages + matching_osdeps_packages).to_set.each do |pkg_name, exact_match|
1122
- # Check-out packages that are not in the manifest only
1090
+ all_matches.each do |pkg_name, exact_match|
1091
+ # Select packages that are not in the manifest only
1123
1092
  # if they are explicitely selected. However, we do store
1124
1093
  # them as "possible resolutions" for the user selection,
1125
1094
  # and add them if -- at the end of the method -- nothing
1126
1095
  # has been found for this particular selection
1127
- if !all_layout_packages.include?(pkg_name) && !exact_match
1128
- pending_selections[sel] = pkg_name
1129
- next
1096
+ if !all_selected_packages.include?(pkg_name) && !exact_match
1097
+ pending_selections[sel] << pkg_name
1098
+ else
1099
+ update_selection(result, sel, pkg_name, true)
1130
1100
  end
1131
-
1132
- result.select(sel, pkg_name, true)
1133
1101
  end
1134
1102
  end
1135
1103
 
1136
1104
  if options[:filter]
1137
1105
  result.filter_excluded_and_ignored_packages(self)
1138
1106
  end
1107
+
1139
1108
  nonresolved = selection - result.matches.keys
1140
1109
  nonresolved.delete_if do |sel|
1141
- if pkg_name = pending_selections[sel]
1142
- result.select(sel, pkg_name, true)
1110
+ if pending = pending_selections.fetch(sel, nil)
1111
+ pending.each do |name|
1112
+ update_selection(result, sel, name, true)
1113
+ end
1143
1114
  true
1144
1115
  end
1145
1116
  end
@@ -1218,34 +1189,31 @@ module Autoproj
1218
1189
  end
1219
1190
  end
1220
1191
 
1221
- class << self
1222
- # The singleton manifest object that represents the current build
1223
- # configuration
1224
- #
1225
- # @return [Manifest]
1226
- attr_accessor :manifest
1192
+ def self.manifest
1193
+ Autoproj.warn_deprecated(
1194
+ __method__, "use workspace.manifest instead")
1227
1195
 
1228
- # The known osdeps definitions
1229
- #
1230
- # @return [OSDependencies]
1231
- # @see load_osdeps_from_package_sets
1232
- def osdeps
1233
- manifest.osdeps
1234
- end
1196
+ workspace.manifest
1197
+ end
1235
1198
 
1236
- def osdeps=(osdeps)
1237
- raise ArgumentError, "cannot set the osdeps object explicitely anymore. Use osdeps.clear and osdeps.merge"
1238
- end
1199
+ def self.osdeps
1200
+ Autoproj.warn_deprecated(
1201
+ __method__, "use workspace.osdeps instead")
1202
+
1203
+ workspace.osdeps
1204
+ end
1205
+
1206
+ def self.config
1207
+ Autoproj.warn_deprecated(
1208
+ __method__, "use workspace.config instead")
1239
1209
 
1240
- # The configuration file
1241
- # @return [Configuration]
1242
- attr_accessor :config
1210
+ workspace.config
1243
1211
  end
1244
1212
 
1245
1213
  # Load the osdeps files contained in {manifest} into {osdeps}
1246
1214
  def self.load_osdeps_from_package_sets
1247
- manifest.load_osdeps_from_package_sets(osdeps)
1248
- osdeps
1215
+ workspace.load_osdeps_from_package_sets(osdeps)
1216
+ workspace.osdeps
1249
1217
  end
1250
1218
 
1251
1219
  def self.add_osdeps_overrides(*args, &block)