autoproj 1.13.7 → 2.0.0.b1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -32,10 +32,6 @@ module Autoproj
32
32
  @silent = true
33
33
  end
34
34
 
35
- def parse_package_entry(entry)
36
- entry
37
- end
38
-
39
35
  # The primary name for this package manager
40
36
  def name
41
37
  names.first
@@ -45,7 +41,7 @@ module Autoproj
45
41
  # order to have a properly functioning package manager
46
42
  #
47
43
  # This is e.g. needed for python pip or rubygems
48
- def self.initialize_environment
44
+ def self.initialize_environment(_env = nil, _manifest = nil, _root_dir = Autoproj.root_dir)
49
45
  end
50
46
  end
51
47
 
@@ -310,7 +306,7 @@ fi
310
306
  false)
311
307
  end
312
308
 
313
- def filter_uptodate_packages(packages)
309
+ def filter_uptodate_packages(packages, options = Hash.new)
314
310
  # TODO there might be duplicates in packages which should be fixed
315
311
  # somewhere else
316
312
  packages = packages.uniq
@@ -377,7 +373,7 @@ fi
377
373
  "zypper -n install '%s'")
378
374
  end
379
375
 
380
- def filter_uptodate_packages(packages)
376
+ def filter_uptodate_packages(packages, options = Hash.new)
381
377
  result = `LANG=C rpm -q --whatprovides '#{packages.join("' '")}'`
382
378
  has_all_pkgs = $?.success?
383
379
 
@@ -416,7 +412,7 @@ fi
416
412
  "yum install -y '%s'")
417
413
  end
418
414
 
419
- def filter_uptodate_packages(packages)
415
+ def filter_uptodate_packages(packages, options = Hash.new)
420
416
  result = `LANG=C rpm -q --queryformat "%{NAME}\n" '#{packages.join("' '")}'`
421
417
 
422
418
  installed_packages = []
@@ -519,7 +515,7 @@ fi
519
515
  end
520
516
  end
521
517
 
522
- def filter_uptodate_packages(packages)
518
+ def filter_uptodate_packages(packages, options = Hash.new)
523
519
  packages.find_all do |package_name|
524
520
  !installed?(package_name)
525
521
  end
@@ -529,43 +525,65 @@ fi
529
525
  # Package manager interface for the RubyGems system
530
526
  class GemManager < Manager
531
527
  class << self
532
- attr_accessor :with_prerelease
528
+ attr_writer :with_prerelease
533
529
  attr_accessor :with_doc
534
530
  end
535
531
  @with_prerelease = false
536
532
  @with_doc = false
537
533
 
534
+ def self.with_prerelease(*value)
535
+ if value.empty?
536
+ @with_prerelease
537
+ else
538
+ begin
539
+ saved_flag = @with_prerelease
540
+ @with_prerelease = value.first
541
+ yield
542
+ ensure
543
+ @with_prerelease = saved_flag
544
+ end
545
+ end
546
+ end
547
+
538
548
  # Filters all paths that come from other autoproj installations out
539
549
  # of GEM_PATH
540
- def self.initialize_environment
541
- Autobuild::ORIGINAL_ENV['GEM_PATH'] =
542
- (ENV['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p|
550
+ def self.initialize_environment(env = Autobuild.env, manifest = Autoproj.manifest, root_dir = Autoproj.root_dir)
551
+ env.original_env['GEM_PATH'] =
552
+ (env['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p|
543
553
  !Autoproj.in_autoproj_installation?(p)
544
554
  end.join(File::PATH_SEPARATOR)
545
- Autobuild.env_inherit 'GEM_PATH'
546
- Autobuild.env_init_from_env 'GEM_PATH'
555
+ env.inherit 'GEM_PATH'
556
+ env.init_from_env 'GEM_PATH'
547
557
 
548
- orig_gem_path = Autobuild::ORIGINAL_ENV['GEM_PATH'].split(File::PATH_SEPARATOR)
549
- Autobuild::SYSTEM_ENV['GEM_PATH'] = Gem.default_path
550
- Autobuild::ORIGINAL_ENV['GEM_PATH'] = orig_gem_path.join(File::PATH_SEPARATOR)
558
+ orig_gem_path = env.original_env['GEM_PATH'].split(File::PATH_SEPARATOR)
559
+ env.system_env['GEM_PATH'] = Gem.default_path
560
+ env.original_env['GEM_PATH'] = orig_gem_path.join(File::PATH_SEPARATOR)
551
561
 
552
- Autoproj.manifest.each_reused_autoproj_installation do |p|
562
+ manifest.each_reused_autoproj_installation do |p|
553
563
  p_gems = File.join(p, '.gems')
554
564
  if File.directory?(p_gems)
555
- Autobuild.env_push_path 'GEM_PATH', p_gems
556
- Autobuild.env_push_path 'PATH', File.join(p_gems, 'bin')
565
+ env.push_path 'GEM_PATH', p_gems
566
+ env.push_path 'PATH', File.join(p_gems, 'bin')
557
567
  end
558
568
  end
559
- Autobuild.env_push_path 'GEM_PATH', gem_home
560
- Autobuild.env_set 'GEM_HOME', gem_home
561
- Autobuild.env_push_path 'PATH', "#{gem_home}/bin"
569
+
570
+ @gem_home = (ENV['AUTOPROJ_GEM_HOME'] || File.join(root_dir, ".gems"))
571
+ env.push_path 'GEM_PATH', gem_home
572
+ env.set 'GEM_HOME', gem_home
573
+ env.push_path 'PATH', "#{gem_home}/bin"
562
574
 
563
575
  # Now, reset the directories in our own RubyGems instance
564
- Gem.paths = ENV
576
+ Gem.paths = env.resolved_env
565
577
 
566
578
  use_cache_dir
567
579
  end
568
580
 
581
+ # Override the gem home detected by {initialize_environment}, or set
582
+ # it in cases where calling {initialize_environment} is not possible
583
+ def self.gem_home=(gem_home)
584
+ @gem_home = gem_home
585
+ end
586
+
569
587
  # A global cache directory that should be used to avoid
570
588
  # re-downloading gems
571
589
  def self.cache_dir
@@ -591,7 +609,7 @@ fi
591
609
 
592
610
  # Return the directory in which RubyGems package should be installed
593
611
  def self.gem_home
594
- ENV['AUTOPROJ_GEM_HOME'] || File.join(Autoproj.root_dir, ".gems")
612
+ @gem_home
595
613
  end
596
614
 
597
615
  # Returns the set of default options that are added to gem
@@ -685,7 +703,9 @@ fi
685
703
  Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(" ") }.sort.join(", ")}"
686
704
 
687
705
  cmdlines.each do |c|
688
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c
706
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', *c,
707
+ env: Hash['GEM_HOME' => Gem.paths.home,
708
+ 'GEM_PATH' => Gem.paths.path.join(":")]
689
709
  end
690
710
  gems.each do |name, v|
691
711
  installed_gems << name
@@ -696,7 +716,10 @@ fi
696
716
 
697
717
  # Returns the set of RubyGem packages in +packages+ that are not already
698
718
  # installed, or that can be upgraded
699
- def filter_uptodate_packages(gems)
719
+ def filter_uptodate_packages(gems, options = Hash.new)
720
+ options = validate_options options,
721
+ install_only: !Autobuild.do_update
722
+
700
723
  # Don't install gems that are already there ...
701
724
  gems = gems.dup
702
725
  gems.delete_if do |name, version|
@@ -714,7 +737,7 @@ fi
714
737
  Gem.source_index.find_name(name, version_requirements)
715
738
  end
716
739
 
717
- if !installed.empty? && Autobuild.do_update
740
+ if !installed.empty? && !options[:install_only]
718
741
  # Look if we can update the package ...
719
742
  dep = Gem::Dependency.new(name, version_requirements)
720
743
  available =
@@ -803,14 +826,14 @@ fi
803
826
 
804
827
  attr_reader :installed_gems
805
828
 
806
- def self.initialize_environment
807
- Autoproj.env_set 'PYTHONUSERBASE', pip_home
829
+ def self.initialize_environment(env = Autobuild.env, _manifest = nil, root_dir = Autoproj.root_dir)
830
+ env.set 'PYTHONUSERBASE', pip_home(env, root_dir)
808
831
  end
809
832
 
810
833
  # Return the directory where python packages are installed to.
811
834
  # The actual path is pip_home/lib/pythonx.y/site-packages.
812
- def self.pip_home
813
- ENV['AUTOPROJ_PYTHONUSERBASE'] || File.join(Autoproj.root_dir,".pip")
835
+ def self.pip_home(env = Autobuild.env, root_dir = Autobuild.root_dir)
836
+ env['AUTOPROJ_PYTHONUSERBASE'] || File.join(root_dir,".pip")
814
837
  end
815
838
 
816
839
 
@@ -1256,12 +1279,8 @@ fi
1256
1279
  # Validate the options. We check on the availability of
1257
1280
  # validate_options as to not break autoproj_bootstrap (in which
1258
1281
  # validate_options is not available)
1259
- options =
1260
- if Kernel.respond_to?(:validate_options)
1261
- Kernel.validate_options options, :force => false
1262
- else
1263
- options.dup
1264
- end
1282
+ options = validate_options options, force: false, config: Autoproj.config
1283
+ config = options.fetch(:config)
1265
1284
 
1266
1285
  if user_os = ENV['AUTOPROJ_OS']
1267
1286
  @operating_system =
@@ -1278,8 +1297,8 @@ fi
1278
1297
  @operating_system = nil
1279
1298
  elsif !@operating_system.nil? # @operating_system can be set to false to simulate an unknown OS
1280
1299
  return @operating_system
1281
- elsif Autoproj.has_config_key?('operating_system')
1282
- os = Autoproj.user_config('operating_system')
1300
+ elsif config.has_value_for?('operating_system')
1301
+ os = config.get('operating_system')
1283
1302
  if os.respond_to?(:to_ary)
1284
1303
  if os[0].respond_to?(:to_ary) && os[0].all? { |s| s.respond_to?(:to_str) } &&
1285
1304
  os[1].respond_to?(:to_ary) && os[1].all? { |s| s.respond_to?(:to_str) }
@@ -1318,7 +1337,7 @@ fi
1318
1337
  names, versions = normalize_os_representation(names, versions)
1319
1338
 
1320
1339
  @operating_system = [names, versions]
1321
- Autoproj.change_option('operating_system', @operating_system, true)
1340
+ config.set('operating_system', @operating_system, true)
1322
1341
  Autobuild.progress :operating_system_autodetection, "operating system: #{(names - ['default']).join(",")} - #{(versions - ['default']).join(",")}"
1323
1342
  @operating_system
1324
1343
  ensure
@@ -1445,15 +1464,11 @@ fi
1445
1464
  end
1446
1465
 
1447
1466
  result.map do |handler, status, entries|
1448
- entries = entries.map do |e|
1449
- if e.respond_to?(:to_str)
1450
- handler.parse_package_entry(e)
1451
- else
1452
- e
1453
- end
1467
+ if handler.respond_to?(:parse_package_entry)
1468
+ [handler, status, entries.map { |s| handler.parse_package_entry(s) }]
1469
+ else
1470
+ [handler, status, entries]
1454
1471
  end
1455
-
1456
- [handler, status, entries]
1457
1472
  end
1458
1473
  end
1459
1474
 
@@ -1603,8 +1618,6 @@ fi
1603
1618
  return found, result
1604
1619
  end
1605
1620
 
1606
- class MissingOSDep < ConfigError; end
1607
-
1608
1621
  # Resolves the given OS dependencies into the actual packages that need
1609
1622
  # to be installed on this particular OS.
1610
1623
  #
@@ -1722,7 +1735,7 @@ fi
1722
1735
  HANDLE_OS = 'os'
1723
1736
  HANDLE_NONE = 'none'
1724
1737
 
1725
- def self.osdeps_mode_option_unsupported_os
1738
+ def self.osdeps_mode_option_unsupported_os(config = Autoproj.config)
1726
1739
  long_doc =<<-EOT
1727
1740
  The software packages that autoproj will have to build may require other
1728
1741
  prepackaged softwares (a.k.a. OS dependencies) to be installed (RubyGems
@@ -1753,13 +1766,13 @@ So, what do you want ? (all, none or a comma-separated list of: gem pip)
1753
1766
  EOT
1754
1767
  message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, none or a comma-separated list of: gem pip) ?", long_doc.strip ]
1755
1768
 
1756
- Autoproj.configuration_option 'osdeps_mode', 'string',
1769
+ config.declare 'osdeps_mode', 'string',
1757
1770
  :default => 'ruby',
1758
1771
  :doc => message,
1759
1772
  :lowercase => true
1760
1773
  end
1761
1774
 
1762
- def self.osdeps_mode_option_supported_os
1775
+ def self.osdeps_mode_option_supported_os(config = Autoproj.config)
1763
1776
  long_doc =<<-EOT
1764
1777
  The software packages that autoproj will have to build may require other
1765
1778
  prepackaged softwares (a.k.a. OS dependencies) to be installed (RubyGems
@@ -1794,17 +1807,17 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1794
1807
  EOT
1795
1808
  message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, none or a comma-separated list of: os gem pip) ?", long_doc.strip ]
1796
1809
 
1797
- Autoproj.configuration_option 'osdeps_mode', 'string',
1810
+ config.declare 'osdeps_mode', 'string',
1798
1811
  :default => 'all',
1799
1812
  :doc => message,
1800
1813
  :lowercase => true
1801
1814
  end
1802
1815
 
1803
- def self.define_osdeps_mode_option
1816
+ def self.define_osdeps_mode_option(config = Autoproj.config)
1804
1817
  if supported_operating_system?
1805
- osdeps_mode_option_supported_os
1818
+ osdeps_mode_option_supported_os(config)
1806
1819
  else
1807
- osdeps_mode_option_unsupported_os
1820
+ osdeps_mode_option_unsupported_os(config)
1808
1821
  end
1809
1822
  end
1810
1823
 
@@ -1856,10 +1869,10 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1856
1869
  @osdeps_mode = OSDependencies.osdeps_mode
1857
1870
  end
1858
1871
 
1859
- def self.osdeps_mode
1872
+ def self.osdeps_mode(config = Autoproj.config)
1860
1873
  while true
1861
1874
  mode =
1862
- if !Autoproj.has_config_key?('osdeps_mode') &&
1875
+ if !config.has_value_for?('osdeps_mode') &&
1863
1876
  mode_name = ENV['AUTOPROJ_OSDEPS_MODE']
1864
1877
  begin OSDependencies.osdeps_mode_string_to_value(mode_name)
1865
1878
  rescue ArgumentError
@@ -1867,7 +1880,7 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1867
1880
  nil
1868
1881
  end
1869
1882
  else
1870
- mode_name = Autoproj.user_config('osdeps_mode')
1883
+ mode_name = config.get('osdeps_mode')
1871
1884
  begin OSDependencies.osdeps_mode_string_to_value(mode_name)
1872
1885
  rescue ArgumentError
1873
1886
  Autoproj.warn "invalid osdeps mode stored in configuration file"
@@ -1877,12 +1890,12 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1877
1890
 
1878
1891
  if mode
1879
1892
  @osdeps_mode = mode
1880
- Autoproj.change_option('osdeps_mode', mode_name, true)
1893
+ config.set('osdeps_mode', mode_name, true)
1881
1894
  return mode
1882
1895
  end
1883
1896
 
1884
1897
  # Invalid configuration values. Retry
1885
- Autoproj.reset_option('osdeps_mode')
1898
+ config.reset('osdeps_mode')
1886
1899
  ENV['AUTOPROJ_OSDEPS_MODE'] = nil
1887
1900
  end
1888
1901
  end
@@ -1904,7 +1917,8 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1904
1917
  def setup_package_handlers(options = Hash.new)
1905
1918
  options =
1906
1919
  if Kernel.respond_to?(:validate_options)
1907
- Kernel.validate_options options, :osdeps_mode => osdeps_mode
1920
+ Kernel.validate_options options,
1921
+ osdeps_mode: osdeps_mode
1908
1922
  else
1909
1923
  options = options.dup
1910
1924
  options[:osdeps_mode] ||= osdeps_mode
@@ -1947,7 +1961,7 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1947
1961
  # This is usually called as a rebuild step to make sure that all these
1948
1962
  # packages are updated to whatever required the rebuild
1949
1963
  def pristine(packages, options = Hash.new)
1950
- setup_package_handlers(options)
1964
+ install(packages, options.merge(install_only: true))
1951
1965
  packages = resolve_os_dependencies(packages)
1952
1966
 
1953
1967
  _, other_packages =
@@ -1965,12 +1979,16 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1965
1979
  packages = packages.to_set - installed_packages
1966
1980
  return false if packages.empty?
1967
1981
 
1982
+ filter_options, options =
1983
+ filter_options options, install_only: !Autobuild.do_update
1968
1984
  setup_package_handlers(options)
1969
1985
 
1970
1986
  packages = resolve_os_dependencies(packages)
1987
+
1988
+ needs_filter = (filter_uptodate_packages? || filter_options[:install_only])
1971
1989
  packages = packages.map do |handler, list|
1972
- if filter_uptodate_packages? && handler.respond_to?(:filter_uptodate_packages)
1973
- list = handler.filter_uptodate_packages(list)
1990
+ if needs_filter && handler.respond_to?(:filter_uptodate_packages)
1991
+ list = handler.filter_uptodate_packages(list, filter_options)
1974
1992
  end
1975
1993
 
1976
1994
  if !list.empty?
@@ -1990,6 +2008,17 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1990
2008
  end
1991
2009
  true
1992
2010
  end
2011
+
2012
+ def reinstall(options = Hash.new)
2013
+ # We also reinstall the osdeps that provide the
2014
+ # functionality
2015
+ managers = setup_package_handlers(options)
2016
+ managers.each do |mng|
2017
+ if mng.enabled? && mng.respond_to?(:reinstall)
2018
+ mng.reinstall
2019
+ end
2020
+ end
2021
+ end
1993
2022
  end
1994
2023
  end
1995
2024
 
@@ -1,14 +1,4 @@
1
1
  module Autoproj
2
- # Exception raised by
3
- # PackageSelection#filter_excluded_and_ignored_packages when a given
4
- # selection is completely excluded
5
- class ExcludedSelection < ConfigError
6
- attr_reader :selection
7
- def initialize(selection)
8
- @selection = selection
9
- end
10
- end
11
-
12
2
  # Class holding information about which packages have been selected, and
13
3
  # why. It is used to decide whether some non-availability of packages
14
4
  # are errors or simply warnings (i.e. if the user really wants a given
@@ -37,6 +27,10 @@ module Autoproj
37
27
  # contains the set of package ignores that have been ignored because
38
28
  # the corresponding metapackage has a weak dependency policy
39
29
  attr_reader :ignores
30
+ # The set of source packages that have been selected
31
+ attr_reader :source_packages
32
+ # The set of osdeps that have been selected
33
+ attr_reader :osdeps
40
34
 
41
35
  def initialize
42
36
  @selection = Hash.new { |h, k| h[k] = Set.new }
@@ -44,11 +38,8 @@ module Autoproj
44
38
  @weak_dependencies = Hash.new
45
39
  @ignores = Hash.new { |h, k| h[k] = Set.new }
46
40
  @exclusions = Hash.new { |h, k| h[k] = Set.new }
47
- end
48
-
49
- # The set of packages that have been selected
50
- def packages
51
- selection.keys
41
+ @source_packages = Set.new
42
+ @osdeps = Set.new
52
43
  end
53
44
 
54
45
  def include?(pkg_name)
@@ -60,16 +51,44 @@ module Autoproj
60
51
  end
61
52
 
62
53
  def each(&block)
63
- selection.each_key(&block)
54
+ Autoproj.warn_deprecated "PackageSelection#each", "use PackageSelection#each_source_package_name instead", 0
55
+ each_source_package_name(&block)
56
+ end
57
+
58
+ def each_source_package_name(&block)
59
+ source_packages.each(&block)
64
60
  end
65
61
 
66
- def select(sel, packages, weak = false)
67
- packages = Array(packages)
68
- matches[sel] |= packages.to_set.dup
62
+ def each_osdep_package_name(&block)
63
+ osdeps.each(&block)
64
+ end
65
+
66
+ def packages
67
+ Autoproj.warn_deprecated "PackageSelection#packages", "use PackageSelection#source_packages instead", 0
68
+ source_packages
69
+ end
70
+
71
+ def select(sel, packages, options = Hash.new)
72
+ if !options.kind_of?(Hash)
73
+ Autoproj.warn_deprecated "calling PackageSelection#select with a boolean as third argument", "use e.g. weak: true instead", 0
74
+ options = Hash[weak: options]
75
+ end
76
+ options = Kernel.validate_options options,
77
+ weak: false,
78
+ osdep: false
79
+
80
+ packages = Array(packages).to_set
81
+ matches[sel].merge(packages)
69
82
  packages.each do |pkg_name|
70
83
  selection[pkg_name] << sel
71
84
  end
72
- weak_dependencies[sel] = weak
85
+ if options[:osdep]
86
+ osdeps.merge(packages)
87
+ else
88
+ source_packages.merge(packages)
89
+ end
90
+
91
+ weak_dependencies[sel] = options[:weak]
73
92
  end
74
93
 
75
94
  def initialize_copy(old)