autoproj 1.6.1 → 1.6.2.rc2

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.
@@ -30,54 +30,6 @@ module Autoproj
30
30
  end
31
31
 
32
32
  module CmdLine
33
- def self.handle_automatic_osdeps
34
- if !Autoproj.has_config_key?('automatic_osdeps') && ENV['AUTOPROJ_AUTOMATIC_OSDEPS']
35
- mode = ENV['AUTOPROJ_AUTOMATIC_OSDEPS']
36
- mode =
37
- if mode == 'true' then Autoproj::OSDependencies::AUTOMATIC
38
- elsif mode == 'false' then Autoproj::OSDependencies::MANUAL
39
- elsif mode == 'wait' then Autoproj::OSDependencies::WAIT
40
- else Autoproj::OSDependencies::ASK
41
- end
42
-
43
- Autoproj.change_option('automatic_osdeps', mode, true)
44
- end
45
-
46
- short_doc = "Should autoproj handle the OS package installation automatically (yes, no, wait or ask) ?"
47
- long_doc =<<-EOT
48
- * if you say "yes", the OS dependencies will be handled by autoproj.
49
- * if you say "no", the list of OS dependencies that need to be installed will be
50
- listed, and autoproj will go on, assuming that you have installed them yourself.
51
- * if you say "ask", you will be prompted each time a package needs to be installed.
52
- * if you say "wait", autoproj will simply wait for you to press ENTER to continue
53
- after it prompted you for the dependencies.
54
-
55
- This value can be changed anytime by calling an autoproj operation
56
- with the --reconfigure option (e.g. autoproj update --reconfigure).
57
- Moreover, the "autoproj osdeps" call will always allow you to install
58
- OS dependencies through autoproj.
59
- EOT
60
- long_doc = long_doc.strip
61
-
62
- Autoproj.configuration_option 'automatic_osdeps', 'string',
63
- :default => 'yes',
64
- :doc => [short_doc, long_doc] do |value|
65
- begin
66
- Autoproj::BuildOption.validate_boolean(value, Hash.new)
67
- rescue Autoproj::InputError
68
- if value.to_s == "ask"
69
- :ask
70
- elsif value.to_s == "wait"
71
- :wait
72
- else
73
- raise Autoproj::InputError, "invalid value. Please answer 'yes', 'no', 'wait' or 'ask' -- without the quotes"
74
- end
75
- end
76
- end
77
-
78
- Autoproj.user_config('automatic_osdeps')
79
- end
80
-
81
33
  def self.initialize
82
34
  Autobuild::Reporting << Autoproj::Reporter.new
83
35
  if mail_config[:to]
@@ -106,8 +58,6 @@ OS dependencies through autoproj.
106
58
  Autobuild.srcdir = Autoproj.root_dir
107
59
  Autobuild.logdir = File.join(Autobuild.prefix, 'log')
108
60
 
109
- handle_automatic_osdeps
110
-
111
61
  ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
112
62
  if ruby != 'ruby'
113
63
  bindir = File.join(Autoproj.build_dir, 'bin')
@@ -141,24 +91,44 @@ OS dependencies through autoproj.
141
91
  if Autobuild.do_update.nil?
142
92
  Autobuild.do_update = manifest.auto_update?
143
93
  end
144
- if Autoproj::CmdLine.update_os_dependencies.nil?
145
- Autoproj::CmdLine.update_os_dependencies = manifest.auto_update?
146
- end
147
94
 
148
95
  # Initialize the Autoproj.osdeps object by loading the default. The
149
96
  # rest is loaded later
150
97
  Autoproj.osdeps = Autoproj::OSDependencies.load_default
98
+ Autoproj.osdeps.silent = !osdeps?
99
+ Autoproj.osdeps.filter_uptodate_packages = osdeps_filter_uptodate?
100
+ if Autoproj::CmdLine.osdeps_forced_mode
101
+ Autoproj.osdeps.osdeps_mode = Autoproj::CmdLine.osdeps_forced_mode
102
+ end
103
+ if @update_os_dependencies || Autoproj::CmdLine.osdeps?
104
+ Autoproj.reset_option('operating_system')
105
+ end
106
+ # Do that AFTER we have properly setup Autoproj.osdeps as to avoid
107
+ # unnecessarily redetecting the operating system
108
+ Autoproj::OSDependencies.define_osdeps_mode_option
109
+ Autoproj.osdeps.osdeps_mode
151
110
  end
152
111
 
153
112
  def self.update_myself
154
113
  return if !Autoproj::CmdLine.update_os_dependencies?
155
114
 
115
+ # This is a guard to avoid infinite recursion in case the user is
116
+ # running autoproj osdeps --force
117
+ if ENV['AUTOPROJ_RESTARTING'] == '1'
118
+ return
119
+ end
120
+
156
121
  # First things first, see if we need to update ourselves
157
122
  if Autoproj.osdeps.install(%w{autobuild autoproj})
123
+ puts
124
+ Autoproj.progress 'autoproj and/or autobuild has been updated, restarting autoproj'
125
+ puts
126
+
158
127
  # We updated autobuild or autoproj themselves ... Restart !
159
128
  #
160
129
  # ...But first save the configuration (!)
161
130
  Autoproj.save_config
131
+ ENV['AUTOPROJ_RESTARTING'] = '1'
162
132
  require 'rbconfig'
163
133
  ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
164
134
  exec(ruby, $0, *ARGV)
@@ -217,13 +187,18 @@ OS dependencies through autoproj.
217
187
 
218
188
  # Update the remote sources if there are any
219
189
  if manifest.has_remote_sources?
220
- Autoproj.progress("autoproj: updating remote definitions of package sets", :bold)
190
+ if manifest.should_update_remote_sources
191
+ Autoproj.progress("autoproj: updating remote definitions of package sets", :bold)
192
+ end
193
+
221
194
  # If we need to install some packages to import our remote sources, do it
222
195
  if update_os_dependencies?
223
196
  Autoproj.osdeps.install(source_os_dependencies)
224
197
  end
225
198
 
226
- manifest.update_remote_sources
199
+ if manifest.should_update_remote_sources
200
+ manifest.update_remote_sources
201
+ end
227
202
  Autoproj.progress
228
203
  end
229
204
  end
@@ -389,7 +364,9 @@ OS dependencies through autoproj.
389
364
  delete_if { |pkg_name, pkg| Autoproj.manifest.excluded?(pkg_name) || Autoproj.manifest.ignored?(pkg_name) }
390
365
 
391
366
  packages.each do |_, pkg|
392
- pkg.import
367
+ pkg.isolate_errors do
368
+ pkg.import
369
+ end
393
370
  end
394
371
 
395
372
  ensure
@@ -498,10 +475,19 @@ OS dependencies through autoproj.
498
475
  def self.manifest; Autoproj.manifest end
499
476
  def self.bootstrap?; !!@bootstrap end
500
477
  def self.only_status?; !!@only_status end
478
+ def self.only_local?; !!@only_local end
501
479
  def self.check?; !!@check end
502
480
  def self.manifest_update?; !!@manifest_update end
503
481
  def self.only_config?; !!@only_config end
504
- def self.update_os_dependencies?; !!@update_os_dependencies end
482
+ def self.update_os_dependencies?
483
+ # Check if the mode disables osdeps anyway ...
484
+ if !@update_os_dependencies.nil? && !@update_os_dependencies
485
+ return false
486
+ end
487
+
488
+ # Now look for what the user wants
489
+ Autoproj.osdeps.osdeps_mode != 'none' || !Autoproj.osdeps.silent?
490
+ end
505
491
  class << self
506
492
  attr_accessor :update_os_dependencies
507
493
  attr_accessor :snapshot_dir
@@ -515,14 +501,29 @@ OS dependencies through autoproj.
515
501
  def self.build?; @mode =~ /build/ end
516
502
  def self.doc?; @mode == "doc" end
517
503
  def self.snapshot?; @mode == "snapshot" end
504
+
505
+ def self.osdeps?; @mode == "osdeps" end
506
+ def self.show_osdeps?; @mode == "osdeps" && @show_osdeps end
507
+ def self.revshow_osdeps?; @mode == "osdeps" && @revshow_osdeps end
508
+ def self.osdeps_forced_mode; @osdeps_forced_mode end
509
+ def self.osdeps_filter_uptodate?
510
+ if @mode == "osdeps"
511
+ @osdeps_filter_uptodate
512
+ else true
513
+ end
514
+ end
518
515
  def self.list_newest?; @list_newest end
519
516
  def self.parse_arguments(args)
520
517
  @only_status = false
518
+ @only_local = false
519
+ @show_osdeps = false
520
+ @revshow_osdeps = false
521
+ @osdeps_filter_uptodate = true
522
+ @osdeps_forced_mode = nil
521
523
  @check = false
522
524
  @manifest_update = false
523
525
  @display_configuration = false
524
- @update_os_dependencies = true
525
- update_os_dependencies = nil
526
+ @update_os_dependencies = nil
526
527
  @force_re_build_with_depends = false
527
528
  force_re_build_with_depends = nil
528
529
  @only_config = false
@@ -586,7 +587,10 @@ where 'mode' is one of:
586
587
  opts.on("--[no-]update", "[do not] update already checked-out packages (build modes only)") do |value|
587
588
  do_update = value
588
589
  end
589
- opts.on("--os", "displays the operating system as detected by autoproj") do
590
+ opts.on("--keep-going", "-k", "continue building even though one package has an error") do
591
+ Autobuild.ignore_errors = true
592
+ end
593
+ opts.on("--os-version", "displays the operating system as detected by autoproj") do
590
594
  os = OSDependencies.operating_system
591
595
  if !os
592
596
  puts "no information about that OS"
@@ -600,15 +604,49 @@ where 'mode' is one of:
600
604
  exit 0
601
605
  end
602
606
 
603
- opts.on("--[no-]osdeps", "[do not] install prepackaged dependencies (build and update modes only)") do |value|
604
- update_os_dependencies = value
605
- end
606
607
  opts.on("--with-depends", "apply rebuild and force-build to both packages selected on the command line and their dependencies") do
607
608
  force_re_build_with_depends = true
608
609
  end
609
610
  opts.on("--list-newest", "for each source directory, list what is the newest file used by autoproj for dependency tracking") do
610
611
  Autoproj::CmdLine.list_newest = true
611
612
  end
613
+ opts.on("--rshow", "in the osdeps mode, shows information for each OS package") do
614
+ @revshow_osdeps = true
615
+ end
616
+ opts.on("--show", "in the osdeps mode, show a per-package listing of the OS dependencies instead of installing them") do
617
+ @show_osdeps = true
618
+ end
619
+ opts.on("--no-osdeps", "disable osdeps handling in build and update modes") do |value|
620
+ @osdeps_forced_mode = 'none'
621
+ end
622
+ opts.on("--all", "in osdeps mode, install both OS packages and RubyGem packages, regardless of the otherwise selected mode") do
623
+ @osdeps_forced_mode = 'all'
624
+ end
625
+ opts.on("--os", "in osdeps mode, install OS packages and display information about the RubyGem packages, regardless of the otherwise selected mode") do
626
+ if @osdeps_forced_mode == 'ruby'
627
+ # Make --ruby --os behave like --all
628
+ @osdeps_forced_mode = 'all'
629
+ else
630
+ @osdeps_forced_mode = 'os'
631
+ end
632
+ end
633
+ opts.on('--force', 'in osdeps mode, do not filter out installed and uptodate packages') do
634
+ @osdeps_filter_uptodate = false
635
+ end
636
+ opts.on("--ruby", "in osdeps mode, install only RubyGem packages and display information about the OS packages, regardless of the otherwise selected mode") do
637
+ if @osdeps_forced_mode == 'os'
638
+ # Make --ruby --os behave like --all
639
+ @osdeps_forced_mode = 'all'
640
+ else
641
+ @osdeps_forced_mode = 'ruby'
642
+ end
643
+ end
644
+ opts.on("--none", "in osdeps mode, do not install any package but display information about them, regardless of the otherwise selected mode") do
645
+ @osdeps_forced_mode = 'none'
646
+ end
647
+ opts.on("--local", "for status, do not access the network") do
648
+ @only_local = true
649
+ end
612
650
 
613
651
  opts.on("--verbose", "verbose output") do
614
652
  Autoproj.verbose = true
@@ -663,7 +701,6 @@ where 'mode' is one of:
663
701
 
664
702
  selection = args.dup
665
703
  @partial_build = !selection.empty?
666
- @update_os_dependencies = update_os_dependencies if !update_os_dependencies.nil?
667
704
  @force_re_build_with_depends = force_re_build_with_depends if !force_re_build_with_depends.nil?
668
705
  Autobuild.do_update = do_update if !do_update.nil?
669
706
  selection
@@ -717,7 +754,6 @@ where 'mode' is one of:
717
754
  @update_os_dependencies = true
718
755
  when "update"
719
756
  Autobuild.do_update = true
720
- @update_os_dependencies = true
721
757
  Autobuild.do_build = false
722
758
  when "check"
723
759
  Autobuild.do_update = false
@@ -733,7 +769,6 @@ where 'mode' is one of:
733
769
  Autobuild.do_update = false
734
770
  @update_os_dependencies = true
735
771
  Autobuild.do_build = false
736
- Autoproj::OSDependencies.force_osdeps = true
737
772
  when "status"
738
773
  @only_status = true
739
774
  Autobuild.do_update = false
@@ -745,7 +780,7 @@ where 'mode' is one of:
745
780
  when "update-config"
746
781
  @only_config = true
747
782
  Autobuild.do_update = true
748
- @update_os_dependencies = false
783
+ @update_os_dependencies = true
749
784
  Autobuild.do_build = false
750
785
  when "list-config"
751
786
  @only_config = true
@@ -780,7 +815,7 @@ where 'mode' is one of:
780
815
  elsif !File.directory?(pkg.srcdir)
781
816
  lines << Autoproj.color(" is not imported yet", :magenta)
782
817
  else
783
- status = pkg.importer.status(pkg)
818
+ status = pkg.importer.status(pkg,@only_local)
784
819
  if status.uncommitted_code
785
820
  lines << Autoproj.color(" contains uncommitted modifications", :red)
786
821
  end
@@ -924,8 +959,9 @@ where 'mode' is one of:
924
959
  vcs = Autoproj.normalize_vcs_definition(vcs_def)
925
960
 
926
961
  # Install the OS dependencies required for this VCS
927
- handle_automatic_osdeps
962
+ Autoproj::OSDependencies.define_osdeps_mode_option
928
963
  osdeps = Autoproj::OSDependencies.load_default
964
+ osdeps.osdeps_mode
929
965
  osdeps.install([vcs.type])
930
966
 
931
967
  # Now check out the actual configuration
@@ -968,7 +1004,29 @@ manifest_source:
968
1004
  if File.exists?(File.join("autoproj", "manifest"))
969
1005
  raise ConfigError, "this installation is already bootstrapped. Remove the autoproj directory if it is not the case"
970
1006
  end
971
- Autobuild.logdir = File.join('build', 'log')
1007
+
1008
+ require 'set'
1009
+ curdir_entries = Dir.entries('.').to_set - [".", "..", "autoproj_bootstrap", ".gems", 'env.sh'].to_set
1010
+ if !curdir_entries.empty? && ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] != '1'
1011
+ while true
1012
+ print "The current directory is not empty, continue bootstrapping anyway ? [yes] "
1013
+ STDOUT.flush
1014
+ answer = STDIN.readline.chomp
1015
+ if answer == "no"
1016
+ exit
1017
+ elsif answer == "" || answer == "yes"
1018
+ # Set this environment variable since we might restart
1019
+ # autoproj later on.
1020
+ ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] = '1'
1021
+ break
1022
+ else
1023
+ STDOUT.puts "invalid answer. Please answer 'yes' or 'no'"
1024
+ STDOUT.flush
1025
+ end
1026
+ end
1027
+ end
1028
+
1029
+ Autobuild.logdir = File.join(Autoproj.prefix, 'log')
972
1030
 
973
1031
  # Check if GEM_HOME is set. If it is the case, assume that we are
974
1032
  # bootstrapping from another installation directory and start by
@@ -1155,6 +1213,111 @@ export PATH=$GEM_HOME/bin:$PATH
1155
1213
  io.write YAML.dump(overrides)
1156
1214
  end
1157
1215
  end
1216
+
1217
+ # Displays the reverse OS dependencies (i.e. for each osdeps package,
1218
+ # who depends on it and where it is defined)
1219
+ def self.revshow_osdeps(packages)
1220
+ _, ospkg_to_pkg = Autoproj.manifest.list_os_dependencies(packages)
1221
+
1222
+ # A mapping from a package name to
1223
+ # [is_os_pkg, is_gem_pkg, definitions, used_by]
1224
+ #
1225
+ # where
1226
+ #
1227
+ # +used_by+ is the set of autobuild package names that use this
1228
+ # osdeps package
1229
+ #
1230
+ # +definitions+ is a osdep_name => definition_file mapping
1231
+ mapping = Hash.new { |h, k| h[k] = [false, false, Hash.new, Set.new] }
1232
+
1233
+ ospkg_to_pkg.each do |pkg_osdep, pkgs|
1234
+ osdeps, gems = Autoproj.osdeps.
1235
+ partition_packages([pkg_osdep], ospkg_to_pkg)
1236
+
1237
+ gems.each do |gem_name|
1238
+ mapping[gem_name][1] = true
1239
+ mapping[gem_name][2][pkg_osdep] = Autoproj.osdeps.source_of(pkg_osdep)
1240
+ mapping[gem_name][3] |= pkgs
1241
+ end
1242
+
1243
+ if Autoproj::OSDependencies.supported_operating_system?
1244
+ osdeps = Autoproj.osdeps.
1245
+ resolve_os_dependencies(osdeps)
1246
+ end
1247
+ osdeps.each do |ospkg_name|
1248
+ mapping[ospkg_name][0] = true
1249
+ mapping[ospkg_name][2][pkg_osdep] = Autoproj.osdeps.source_of(pkg_osdep)
1250
+ mapping[ospkg_name][3] |= pkgs
1251
+ end
1252
+ end
1253
+
1254
+ mapping = mapping.sort_by(&:first)
1255
+ mapping.each do |pkg_name, (is_os_pkg, is_gem_pkg, definitions, used_by)|
1256
+ kind = if is_os_pkg && is_gem_pkg
1257
+ "both a RubyGem and OS package"
1258
+ elsif is_os_pkg
1259
+ "an OS package"
1260
+ else
1261
+ "a RubyGem package"
1262
+ end
1263
+
1264
+ puts "#{pkg_name} is #{kind}"
1265
+ definitions.to_a.
1266
+ sort_by(&:first).
1267
+ each do |osdep_name, file_name|
1268
+ puts " defined as #{osdep_name} in #{file_name}"
1269
+ end
1270
+
1271
+ puts " depended-upon by #{used_by.sort.join(", ")}"
1272
+ end
1273
+ end
1274
+
1275
+ # Displays the OS dependencies required by the given packages
1276
+ def self.show_osdeps(packages)
1277
+ _, ospkg_to_pkg = Autoproj.manifest.list_os_dependencies(packages)
1278
+
1279
+ # ospkg_to_pkg is the reverse mapping to what we want. Invert it
1280
+ mapping = Hash.new { |h, k| h[k] = Set.new }
1281
+ ospkg_to_pkg.each do |ospkg, pkgs|
1282
+ pkgs.each do |pkg_name|
1283
+ mapping[pkg_name] << ospkg
1284
+ end
1285
+ end
1286
+
1287
+ # Now sort it by package name (better for display)
1288
+ package_osdeps = mapping.to_a.
1289
+ sort_by { |name, _| name }
1290
+
1291
+ package_osdeps.each do |pkg_name, pkg_osdeps|
1292
+ if pkg_osdeps.empty?
1293
+ puts " #{pkg_name}: no OS dependencies"
1294
+ next
1295
+ end
1296
+
1297
+ osdeps, gems = Autoproj.osdeps.
1298
+ partition_packages(pkg_osdeps, ospkg_to_pkg)
1299
+
1300
+ puts " #{pkg_name}:"
1301
+ if !gems.empty?
1302
+ puts " RubyGem packages: #{gems.to_a.sort.join(", ")}"
1303
+ end
1304
+
1305
+ # If we are on a supported OS, convert the osdeps name to plain
1306
+ # package name
1307
+ if Autoproj::OSDependencies.supported_operating_system?
1308
+ pkg_osdeps = Autoproj.osdeps.
1309
+ resolve_os_dependencies(osdeps)
1310
+
1311
+ if !pkg_osdeps.empty?
1312
+ puts " OS packages: #{pkg_osdeps.to_a.sort.join(", ")}"
1313
+ end
1314
+ else
1315
+ if !os_packages.empty?
1316
+ puts " OS dependencies: #{os_packages.to_a.sort.join(", ")}"
1317
+ end
1318
+ end
1319
+ end
1320
+ end
1158
1321
  end
1159
1322
  end
1160
1323
 
@@ -616,6 +616,15 @@ module Autoproj
616
616
  # The path to the manifest file that has been loaded
617
617
  attr_reader :file
618
618
 
619
+ # True if osdeps should be handled in update and build, or left to the
620
+ # osdeps command
621
+ def auto_osdeps?
622
+ if data.has_key?('auto_osdeps')
623
+ !!data['auto_osdeps']
624
+ else true
625
+ end
626
+ end
627
+
619
628
  # True if autoproj should run an update automatically when the user
620
629
  # uses" build"
621
630
  def auto_update?
@@ -721,7 +730,7 @@ module Autoproj
721
730
  end
722
731
 
723
732
  if source_name && !done_something
724
- raise ConfigError, "source '#{source_name}' does not exist"
733
+ raise ConfigError, "in #{file}: source '#{source_name}' does not exist"
725
734
  end
726
735
  end
727
736
 
@@ -743,6 +752,16 @@ module Autoproj
743
752
  each_remote_source(false).any? { true }
744
753
  end
745
754
 
755
+ # True if calling update_remote_sources will actually do anything
756
+ def should_update_remote_sources
757
+ each_remote_source(false) do |source|
758
+ if !File.directory?(source.local_dir)
759
+ return true
760
+ end
761
+ end
762
+ false
763
+ end
764
+
746
765
  # Like #each_source, but filters out local package sets
747
766
  def each_remote_source(load_description = true)
748
767
  if !block_given?
@@ -1023,7 +1042,7 @@ module Autoproj
1023
1042
  else
1024
1043
  source = each_source.find { |source| source.name == name }
1025
1044
  if !source
1026
- raise ConfigError, "#{name} is neither a package nor a source"
1045
+ raise ConfigError, "in #{file}: #{name} is neither a package nor a source"
1027
1046
  end
1028
1047
  packages.values.
1029
1048
  find_all { |pkg| pkg.package_set.name == source.name }.
@@ -1104,6 +1123,13 @@ module Autoproj
1104
1123
  Autobuild::Package.each.map { |name, _| name }.to_set
1105
1124
  end
1106
1125
 
1126
+ # Returns all the packages that can be built in this installation
1127
+ def all_packages
1128
+ packages.values.
1129
+ map { |pkg| pkg.autobuild.name }.
1130
+ find_all { |pkg_name| !Autoproj.osdeps || !Autoproj.osdeps.has?(pkg_name) }
1131
+ end
1132
+
1107
1133
  # Returns the set of packages that should be built if the user does not
1108
1134
  # specify any on the command line
1109
1135
  def default_packages
@@ -1111,9 +1137,7 @@ module Autoproj
1111
1137
  layout_packages(layout, true)
1112
1138
  else
1113
1139
  # No layout, all packages are selected
1114
- packages.values.
1115
- map { |pkg| pkg.autobuild.name }.
1116
- find_all { |pkg_name| !Autoproj.osdeps || !Autoproj.osdeps.has?(pkg_name) }
1140
+ all_packages
1117
1141
  end
1118
1142
 
1119
1143
  names.delete_if { |pkg_name| excluded?(pkg_name) || ignored?(pkg_name) }
@@ -1156,7 +1180,7 @@ module Autoproj
1156
1180
  begin
1157
1181
  package.depends_on name
1158
1182
  rescue Autobuild::ConfigException => e
1159
- raise ConfigError, "manifest #{manifest_path} of #{package.name} from #{source.name} lists '#{name}' as dependency, which is listed in the layout but has no autobuild definition", e.backtrace
1183
+ raise ConfigError, "manifest #{manifest_path} of #{package.name} from #{source.name} lists '#{name}' as dependency, which is listed in the layout of #{file} but has no autobuild definition", e.backtrace
1160
1184
  rescue ConfigError => e
1161
1185
  raise ConfigError, "manifest #{manifest_path} of #{package.name} from #{source.name} lists '#{name}' as dependency, but it is neither a normal package nor an osdeps package. osdeps reports: #{e.message}", e.backtrace
1162
1186
  end
@@ -1170,7 +1194,15 @@ module Autoproj
1170
1194
  selected_packages.each(&:load_package_manifest)
1171
1195
  end
1172
1196
 
1173
- def install_os_dependencies(packages)
1197
+ # call-seq:
1198
+ # list_os_dependencies(packages) => required_packages, ospkg_to_pkg
1199
+ #
1200
+ # Returns the set of dependencies required by the listed packages.
1201
+ #
1202
+ # +required_packages+ is the set of osdeps names that are required for
1203
+ # +packages+ and +ospkg_to_pkg+ a mapping from the osdeps name to the
1204
+ # set of packages that require this OS package.
1205
+ def list_os_dependencies(packages)
1174
1206
  required_os_packages = Set.new
1175
1207
  package_os_deps = Hash.new { |h, k| h[k] = Array.new }
1176
1208
  packages.each do |pkg_name|
@@ -1185,6 +1217,12 @@ module Autoproj
1185
1217
  end
1186
1218
  end
1187
1219
 
1220
+ return required_os_packages, package_os_deps
1221
+ end
1222
+
1223
+ # Installs the OS dependencies that are required by the given packages
1224
+ def install_os_dependencies(packages)
1225
+ required_os_packages, package_os_deps = list_os_dependencies(packages)
1188
1226
  Autoproj.osdeps.install(required_os_packages, package_os_deps)
1189
1227
  end
1190
1228
 
@@ -1218,7 +1256,7 @@ module Autoproj
1218
1256
  expanded_packages |= (packages & all_layout_packages)
1219
1257
  end
1220
1258
 
1221
- !packages.empty? && !sources.empty?
1259
+ !packages.empty? || !sources.empty?
1222
1260
  end
1223
1261
 
1224
1262
  if selected_packages.empty?
@@ -1237,21 +1275,17 @@ module Autoproj
1237
1275
  # Finally, check for package source directories
1238
1276
  all_packages = self.all_package_names
1239
1277
  selected_packages.delete_if do |sel|
1240
- match = Regexp.new("^#{Regexp.quote(sel)}")
1278
+ match_dir = Regexp.new("^#{Regexp.quote(sel)}")
1279
+ match_pkg_name = Regexp.new(Regexp.quote(sel))
1241
1280
  all_packages.each do |pkg_name|
1242
1281
  pkg = Autobuild::Package[pkg_name]
1243
- if pkg.srcdir =~ match
1282
+ if pkg_name =~ match_pkg_name || pkg.srcdir =~ match_dir
1244
1283
  expanded_packages << pkg_name
1245
1284
  end
1246
1285
  end
1247
1286
  end
1248
1287
 
1249
- # Some packages might be there even though they are not listed in
1250
- # the layout (either un-defined or depended-upon by other packages).
1251
- # Check for those by looking for root_dir/package_name
1252
-
1253
- # Finally, remove packages that are explicitely excluded and/or
1254
- # ignored
1288
+ # Remove packages that are explicitely excluded and/or ignored
1255
1289
  expanded_packages.delete_if { |pkg_name| excluded?(pkg_name) || ignored?(pkg_name) }
1256
1290
  expanded_packages.to_set
1257
1291
  end