autoproj 2.0.0.b6 → 2.0.0.b7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ac674274886714c8971929bc69953eb9a8554de
4
- data.tar.gz: 1722b19143830e552aad26239225e742dd6bda78
3
+ metadata.gz: e73644d1f3143dffe36b4af50d2f9dbdc348e8a3
4
+ data.tar.gz: 0ec902c6207a631ff578403a74e39eb6b72413ce
5
5
  SHA512:
6
- metadata.gz: 13148336716af711440e24212d70f83330ec82336ddb77cad4c32cb9d487a27f1180b523628a0dfd5812b45221bb1a805a679a55bcf0360cda969c2036f6d9a4
7
- data.tar.gz: 6a487132bf1e90c569cb534e01706627c942d1bdf58b689786fc440c836fd2a3ecdf76d2c9cc85d58ee8e02dd8e7ac1c6b0718629d9090037f0e243437465fe2
6
+ metadata.gz: 4374b8c9855e3a85af8e1d0eb36d233e56d592ff046adc9eeb6405d2b229f0aa60221bdbc5e5f70a6e73ff67c0ec1c2064d3931dda661e9e5f32817f888bff76
7
+ data.tar.gz: d99c1417e26934cc5ebd0d2c55c1102a99e89ba10800aa593dbc21cbbc49deeb54ca0a9bcf3f714c62fe80e62b7b3ff342b3bda6ca31ad1691f687be718726d3
data/bin/autoproj CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  require 'autoproj'
4
4
  require 'autoproj/autobuild'
5
+ require 'autoproj/cli'
5
6
  require 'autoproj/cli/main'
6
7
  Autoproj::CLI.basic_setup
8
+
9
+ Autoproj::CLI.load_plugins
7
10
  Autoproj::CLI::Main.start(ARGV)
8
11
 
@@ -385,6 +385,15 @@ module Autoproj
385
385
  set('import_log_enabled', !!value)
386
386
  end
387
387
 
388
+ def parallel_build_level
389
+ get('parallel_build_level', nil) || Autobuild.parallel_build_level
390
+ end
391
+
392
+ def parallel_build_level=(level)
393
+ set('parallel_build_level', level)
394
+ Autobuild.parallel_build_level = level
395
+ end
396
+
388
397
  def parallel_import_level
389
398
  get('parallel_import_level', 10)
390
399
  end
@@ -1253,11 +1262,21 @@ fi
1253
1262
  end
1254
1263
 
1255
1264
  ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
1265
+ ruby_bindir = RbConfig::CONFIG['bindir']
1266
+
1267
+ candidates = ['gem']
1256
1268
  if ruby_bin =~ /^ruby(.+)$/
1257
- Autobuild.programs['gem'] = "gem#{$1}"
1258
- else
1259
- Autobuild.programs['gem'] = "gem"
1269
+ candidates << "gem#{$1}"
1260
1270
  end
1271
+
1272
+ candidates.each do |gem_name|
1273
+ if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
1274
+ Autobuild.programs['gem'] = gem_full_path
1275
+ return
1276
+ end
1277
+ end
1278
+
1279
+ raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(", ")} in #{ruby_bindir})"
1261
1280
  end
1262
1281
 
1263
1282
  def build_gem_cmdlines(gems)
@@ -538,8 +538,88 @@ def user_config(key)
538
538
  end
539
539
 
540
540
  class Autobuild::Git
541
- # get version information from the importer
542
- def snapshot(package, target_dir = nil)
541
+ # Get version information
542
+ #
543
+ # @option options [Boolean] local (true) whether the snapshot should access
544
+ # the remote repository to determine if the local commit is there, and
545
+ # determine what would be the best remote branch, or stick to information
546
+ # that is present locally
547
+ # @option options [Boolean] exact_state (true) whether the snapshot should
548
+ # point to a specific commit (either with a tag or with a commit ID), or
549
+ # only override the branch
550
+ # @return [Hash] the snapshot information, in a format that can be used by
551
+ # {#relocate}
552
+ def snapshot(package, target_dir = nil, options = Hash.new)
553
+ options = Kernel.validate_options options,
554
+ local: true,
555
+ exact_state: true
556
+
557
+ if options[:local]
558
+ snapshot_local(package, exact_state: options[:exact_state])
559
+ else
560
+ snapshot_against_remote(package, exact_state: options[:exact_state])
561
+ end
562
+ end
563
+
564
+ def normalize_branch_name(name)
565
+ if name =~ /^refs\/heads\//
566
+ return name
567
+ else
568
+ "refs/heads/#{name}"
569
+ end
570
+ end
571
+
572
+ # Returns true if the given snapshot information is different from the
573
+ # configured importer state
574
+ #
575
+ # It tests only against the parameters returned by {#snapshot}
576
+ def snapshot_overrides?(snapshot)
577
+ # We have to normalize the branch and tag names
578
+ if snapshot_local = (snapshot['local_branch'] || snapshot['branch'])
579
+ snapshot_local = normalize_branch_name(snapshot_local)
580
+ local_branch = normalize_branch_name(self.local_branch)
581
+ return true if snapshot_local != local_branch
582
+ end
583
+ if snapshot_remote = (snapshot['remote_branch'] || snapshot['branch'])
584
+ snapshot_remote = normalize_branch_name(snapshot_remote)
585
+ remote_branch = normalize_branch_name(self.remote_branch)
586
+ return true if snapshot_remote != remote_branch
587
+ end
588
+ if snapshot_id = snapshot['commit']
589
+ return true if self.commit != snapshot_id
590
+ end
591
+ false
592
+ end
593
+
594
+ # @api private
595
+ def snapshot_against_remote(package, options = Hash.new)
596
+ info = Hash['tag' => nil, 'commit' => nil]
597
+ remote_revname = describe_commit_on_remote(package, 'HEAD', tags: options[:exact_state])
598
+
599
+ case remote_revname
600
+ when /^refs\/heads\/(.*)/
601
+ remote_branch = $1
602
+ if local_branch == remote_branch
603
+ info['branch'] = local_branch
604
+ else
605
+ info['local_branch'] = local_branch
606
+ info['remote_branch'] = remote_branch
607
+ end
608
+ when /^refs\/tags\/(.*)/
609
+ info['tag'] = $1
610
+ else
611
+ info['local_branch'] = local_branch
612
+ info['remote_branch'] = remote_revname
613
+ end
614
+
615
+ if options[:exact_state] && !info['tag']
616
+ info['commit'] = rev_parse(package, 'HEAD')
617
+ end
618
+ info
619
+ end
620
+
621
+ # @api private
622
+ def snapshot_local(package, options = Hash.new)
543
623
  info = Hash.new
544
624
  if local_branch != remote_branch
545
625
  info['local_branch'] = local_branch
@@ -547,26 +627,29 @@ class Autobuild::Git
547
627
  else
548
628
  info['branch'] = branch
549
629
  end
550
-
551
- begin
552
- tag = run_git_bare(package, 'describe', '--tags', '--exact-match', 'HEAD').first.strip
553
- info.merge('tag' => tag.encode('UTF-8'), 'commit' => nil)
554
- rescue Autobuild::SubcommandFailed
555
- head_commit = rev_parse(package, 'HEAD')
556
- info.merge('tag' => nil, 'commit' => head_commit.encode('UTF-8'))
630
+
631
+ if options[:exact_state]
632
+ has_tag, described = describe_rev(package, 'HEAD')
633
+ if has_tag
634
+ info.merge('tag' => described, 'commit' => nil)
635
+ else
636
+ info.merge('tag' => nil, 'commit' => described)
637
+ end
638
+ else
639
+ info
557
640
  end
558
641
  end
559
642
  end
560
643
 
561
644
  class Autobuild::SVN
562
- def snapshot(package, target_dir = nil)
645
+ def snapshot(package, target_dir = nil, options = Hash.new)
563
646
  version = svn_revision(package)
564
647
  Hash['revision' => version]
565
648
  end
566
649
  end
567
650
 
568
651
  class Autobuild::ArchiveImporter
569
- def snapshot(package, target_dir = nil)
652
+ def snapshot(package, target_dir = nil, options = Hash.new)
570
653
  result = Hash[
571
654
  'mode' => mode,
572
655
  'no_subdirectory' => !has_subdirectory?,
data/lib/autoproj/cli.rb CHANGED
@@ -3,6 +3,12 @@ module Autoproj
3
3
  module CLI
4
4
  class InvalidArguments < Autobuild::Exception
5
5
  end
6
+
7
+ def self.load_plugins
8
+ Gem.find_latest_files('autoproj-*', true).each do |path|
9
+ require path
10
+ end
11
+ end
6
12
  end
7
13
  end
8
14
 
@@ -20,13 +20,16 @@ module Autoproj
20
20
  def run(selected_packages, options)
21
21
  build_options, options = filter_options options,
22
22
  force: false,
23
- rebuild: false
23
+ rebuild: false,
24
+ parallel: nil
24
25
 
25
26
  Autobuild.ignore_errors = options[:keep_going]
26
27
 
27
28
  command_line_selection, source_packages, osdep_packages =
28
29
  super(selected_packages, options.merge(checkout_only: true))
29
30
 
31
+ parallel = build_options[:parallel] || ws.config.parallel_build_level
32
+
30
33
  return if source_packages.empty?
31
34
 
32
35
  # Disable all packages that are not selected
@@ -70,7 +73,7 @@ module Autoproj
70
73
  end
71
74
 
72
75
  Autobuild.do_build = true
73
- ops.build_packages(source_packages)
76
+ ops.build_packages(source_packages, parallel: parallel)
74
77
  Autobuild.apply(source_packages, "autoproj-build", ['install'])
75
78
  end
76
79
  end
@@ -58,7 +58,7 @@ module Autoproj
58
58
  if name == selection || pkg.srcdir == selection
59
59
  puts result_value(pkg, options)
60
60
  return
61
- elsif name =~ selection_rx
61
+ elsif name =~ selection_rx || selection.start_with?(pkg.srcdir)
62
62
  candidates << pkg
63
63
  end
64
64
  end
@@ -104,7 +104,7 @@ module Autoproj
104
104
  if candidates.empty?
105
105
  raise ArgumentError, "cannot find #{selection} in the current autoproj installation"
106
106
  elsif candidates.size > 1
107
- raise ArgumentError, "multiple packages match #{selection} in the current autoproj installation: #{candidates.join(", ")}"
107
+ raise ArgumentError, "multiple packages match #{selection} in the current autoproj installation: #{candidates.map(&:name).sort.join(", ")}"
108
108
  else
109
109
  puts result_value(candidates.first, options)
110
110
  end
@@ -58,6 +58,8 @@ module Autoproj
58
58
  desc: 'only use locally available information (mainly for distributed version control systems such as git)'
59
59
  option :mainline, type: :string,
60
60
  desc: "compare to the given baseline. if 'true', the comparison will ignore any override, otherwise it will take into account overrides only up to the given package set"
61
+ option :snapshot, type: :boolean, default: false,
62
+ desc: "use the VCS information as 'versions --no-local' would detect it instead of the one in the configuration"
61
63
  def status(*packages)
62
64
  run_autoproj_cli(:status, :Status, Hash[], *packages)
63
65
  end
@@ -197,6 +199,11 @@ are given, the packages will not be versioned. In other words,
197
199
  option :replace, type: :boolean,
198
200
  default: false,
199
201
  desc: 'in combination with --save, controls whether an existing file should be updated or replaced'
202
+ option :deps, type: :boolean,
203
+ default: false,
204
+ desc: 'whether both packages and their dependencies should be versioned, or only the selected packages (the latter is the default)'
205
+ option :local, type: :boolean, default: false,
206
+ desc: 'whether we should access the remote server to verify that the snapshotted state is present'
200
207
  option :save, type: :string,
201
208
  desc: 'save to the given file instead of displaying it on the standard output'
202
209
  def versions(*packages)
@@ -3,21 +3,10 @@ require 'autoproj/cli/inspection_tool'
3
3
  module Autoproj
4
4
  module CLI
5
5
  class OSDeps < InspectionTool
6
- def validate_options(package_names, options = Hash.new)
7
- package_names, options = super
8
-
9
- initialize_and_load
10
- if package_names.empty?
11
- package_names = ws.manifest.default_packages(false)
12
- end
13
-
14
- return package_names, options
15
- end
16
-
17
6
  def run(user_selection, options = Hash.new)
7
+ initialize_and_load
18
8
  _, osdep_packages, resolved_selection, _ =
19
9
  finalize_setup(user_selection,
20
- recursive: false,
21
10
  ignore_non_imported_packages: true)
22
11
 
23
12
  ws.osdeps.install(
@@ -28,32 +28,59 @@ module Autoproj
28
28
  end
29
29
 
30
30
  if options[:config]
31
- pkg_sets = ws.manifest.each_package_set.map(&:create_autobuild_package)
31
+ pkg_sets = ws.manifest.each_package_set.to_a
32
32
  if !pkg_sets.empty?
33
33
  Autoproj.message("autoproj: displaying status of configuration", :bold)
34
- display_status(pkg_sets, only_local: options[:only_local])
34
+ display_status(pkg_sets, snapshot: options[:snapshot], only_local: options[:only_local])
35
35
  STDERR.puts
36
36
  end
37
37
  end
38
38
 
39
39
  Autoproj.message("autoproj: displaying status of packages", :bold)
40
40
  packages = packages.sort.map do |pkg_name|
41
- ws.manifest.find_autobuild_package(pkg_name)
41
+ ws.manifest.find_package(pkg_name)
42
+ end
43
+ display_status(packages, snapshot: options[:snapshot], only_local: options[:only_local])
44
+ end
45
+
46
+ def snapshot_overrides_vcs?(importer, vcs, snapshot)
47
+ if importer.respond_to?(:snapshot_overrides?)
48
+ importer.snapshot_overrides?(snapshot)
49
+ else
50
+ vcs = vcs.to_hash
51
+ snapshot.any? { |k, v| vcs[k] != v }
42
52
  end
43
- display_status(packages, only_local: options[:only_local])
44
53
  end
45
54
 
46
55
  PackageStatus = Struct.new :msg, :sync, :uncommitted, :local, :remote
47
- def status_of_package(pkg, options = Hash.new)
56
+ def status_of_package(package_description, options = Hash.new)
57
+ pkg = package_description.autobuild
58
+ importer = pkg.importer
48
59
  package_status = PackageStatus.new(Array.new, false, false, false, false)
49
- if !pkg.importer
60
+ if !importer
50
61
  package_status.msg << Autoproj.color(" is a local-only package (no VCS)", :bold, :red)
51
- elsif !pkg.importer.respond_to?(:status)
52
- package_status.msg << Autoproj.color(" the #{pkg.importer.class.name.gsub(/.*::/, '')} importer does not support status display", :bold, :red)
62
+ elsif !importer.respond_to?(:status)
63
+ package_status.msg << Autoproj.color(" the #{importer.class.name.gsub(/.*::/, '')} importer does not support status display", :bold, :red)
53
64
  elsif !File.directory?(pkg.srcdir)
54
65
  package_status.msg << Autoproj.color(" is not imported yet", :magenta)
55
66
  else
56
- begin status = pkg.importer.status(pkg, options[:only_local])
67
+ if importer.respond_to?(:snapshot)
68
+ snapshot =
69
+ begin importer.snapshot(pkg, nil, exact_state: false, local: options[:only_local])
70
+ rescue Autobuild::PackageException
71
+ Hash.new
72
+ end
73
+ if snapshot_overrides_vcs?(importer, package_description.vcs, snapshot)
74
+ non_nil_values = snapshot.delete_if { |k, v| !v }
75
+ package_status.msg << Autoproj.color(" found configuration that contains all local changes: #{non_nil_values.sort_by(&:first).map { |k, v| "#{k}: #{v}" }.join(", ")}", :light_green)
76
+ package_status.msg << Autoproj.color(" consider adding this to your overrides, or use autoproj versions to do it for you", :light_green)
77
+ if options[:snapshot]
78
+ importer.relocate(importer.repository, snapshot)
79
+ end
80
+ end
81
+ end
82
+
83
+ begin status = importer.status(pkg, options[:only_local])
57
84
  rescue Interrupt
58
85
  raise
59
86
  rescue Exception => e
@@ -61,6 +88,10 @@ module Autoproj
61
88
  return package_status
62
89
  end
63
90
 
91
+ status.unexpected_working_copy_state.each do |msg|
92
+ package_status.msg << Autoproj.color(" #{msg}", :red, :bold)
93
+ end
94
+
64
95
  if status.uncommitted_code
65
96
  package_status.msg << Autoproj.color(" contains uncommitted modifications", :red)
66
97
  package_status.uncommitted = true
@@ -103,26 +134,27 @@ module Autoproj
103
134
  result = StatusResult.new
104
135
 
105
136
  executor = Concurrent::FixedThreadPool.new(ws.config.parallel_import_level, max_length: 0)
106
- interactive, noninteractive = packages.partition { |pkg| pkg.importer && pkg.importer.interactive? }
137
+ interactive, noninteractive = packages.partition do |pkg|
138
+ pkg.autobuild.importer && pkg.autobuild.importer.interactive?
139
+ end
107
140
  noninteractive = noninteractive.map do |pkg|
108
- [pkg, Concurrent::Future.execute(executor: executor) { status_of_package(pkg, only_local: options[:only_local]) }]
141
+ [pkg, Concurrent::Future.execute(executor: executor) { status_of_package(pkg, snapshot: options[:snapshot], only_local: options[:only_local]) }]
109
142
  end
110
143
 
111
144
  sync_packages = ""
112
145
  (noninteractive + interactive).each do |pkg, future|
113
146
  if future
114
- if error = future.reason
115
- raise error
147
+ if !(status = future.value)
148
+ raise future.reason
116
149
  end
117
- status = future.value
118
- else status = status_of_package(pkg, only_local: options[:only_local])
150
+ else status = status_of_package(pkg, snapshot: options[:snapshot], only_local: options[:only_local])
119
151
  end
120
152
 
121
153
  result.uncommitted ||= status.uncommitted
122
154
  result.local ||= status.local
123
155
  result.remote ||= status.remote
124
156
 
125
- pkg_name = pkg.autoproj_name
157
+ pkg_name = pkg.name
126
158
  if status.sync && status.msg.empty?
127
159
  if sync_packages.size > 80
128
160
  Autoproj.message "#{sync_packages},"
@@ -161,6 +193,7 @@ module Autoproj
161
193
 
162
194
  rescue Interrupt
163
195
  Autoproj.warn "Interrupted, waiting for pending jobs to finish"
196
+ raise
164
197
  rescue Exception => e
165
198
  Autoproj.error "internal error: #{e}, waiting for pending jobs to finish"
166
199
  raise
@@ -29,21 +29,20 @@ module Autoproj
29
29
 
30
30
  def run(user_selection, options)
31
31
  initialize_and_load
32
- user_selection, config_selected =
33
- normalize_command_line_package_selection(user_selection)
34
- packages, * =
32
+ packages, *, config_selected =
35
33
  finalize_setup(user_selection,
34
+ recursive: options[:deps],
36
35
  ignore_non_imported_packages: true)
37
36
 
38
37
 
39
38
  ops = Ops::Snapshot.new(ws.manifest, ignore_errors: options[:keep_going])
40
39
 
41
40
  versions = Array.new
42
- if config_selected || (options[:config] != false) || user_selection.empty?
43
- versions += ops.snapshot_package_sets
41
+ if (config_selected && options[:config] != false) || user_selection.empty?
42
+ versions += ops.snapshot_package_sets(nil, local: options[:local])
44
43
  end
45
44
  if (!config_selected && !options[:config]) || !user_selection.empty?
46
- versions += ops.snapshot_packages(packages)
45
+ versions += ops.snapshot_packages(packages, nil, local: options[:local])
47
46
  end
48
47
 
49
48
  if output_file = options[:save]
@@ -189,6 +189,15 @@ module Autoproj
189
189
  set('import_log_enabled', !!value)
190
190
  end
191
191
 
192
+ def parallel_build_level
193
+ get('parallel_build_level', nil) || Autobuild.parallel_build_level
194
+ end
195
+
196
+ def parallel_build_level=(level)
197
+ set('parallel_build_level', level)
198
+ Autobuild.parallel_build_level = level
199
+ end
200
+
192
201
  def parallel_import_level
193
202
  get('parallel_import_level', 10)
194
203
  end
@@ -82,10 +82,10 @@ module Autoproj
82
82
  # @param [Array<String>] all_enabled_packages the list of package
83
83
  # names of the packages that should be rebuilt
84
84
  # @return [void]
85
- def build_packages(all_enabled_packages)
85
+ def build_packages(all_enabled_packages, options = Hash.new)
86
86
  Autobuild.do_rebuild = false
87
87
  Autobuild.do_forced_build = false
88
- Autobuild.apply(all_enabled_packages, "autoproj-build", ['build'])
88
+ Autobuild.apply(all_enabled_packages, "autoproj-build", ['build'], options)
89
89
  end
90
90
  end
91
91
  end
@@ -304,46 +304,52 @@ module Autoproj
304
304
  end
305
305
  end
306
306
 
307
- def sort_package_sets_by_import_order(package_sets, root_pkg_set)
308
- # We do not consider the 'standalone' package sets while sorting.
309
- # They are taken care of later, as we need to maintain the order the
310
- # user defined in the package_sets section of the manifest
311
- queue = package_sets.flat_map do |pkg_set|
312
- if (!pkg_set.imports.empty? || !pkg_set.explicit?) && !(pkg_set == root_pkg_set)
313
- [pkg_set] + pkg_set.imports.to_a
314
- else []
315
- end
316
- end.to_set.to_a
307
+ def inspect; to_s end
317
308
 
318
- sorted = Array.new
309
+ def sort_package_sets_by_import_order(package_sets, root_pkg_set)
310
+ # The sorting is done in two steps:
311
+ # - first, we build a topological order of the package sets
312
+ # - then, we insert the auto-imported packages, following this
313
+ # topological order, in the user-provided order. Each package is
314
+ # considered in turn, and added at the earliest place that fits
315
+ # the dependencies
316
+ topological = Array.new
317
+ queue = package_sets.to_a
319
318
  while !queue.empty?
320
- pkg_set = queue.shift
321
- if pkg_set.imports.any? { |imported_set| !sorted.include?(imported_set) }
322
- queue.push(pkg_set)
323
- else
324
- sorted << pkg_set
319
+ last_size = queue.size
320
+ pending = queue.dup
321
+ queue = Array.new
322
+ while !pending.empty?
323
+ pkg_set = pending.shift
324
+ if not_processed_yet = pkg_set.imports.find { |imported_set| !topological.include?(imported_set) }
325
+ queue.push(pkg_set)
326
+ else
327
+ topological << pkg_set
328
+ end
329
+ end
330
+ if queue.size == last_size
331
+ raise ArgumentError, "cannot resolve the dependencies between package sets. There seem to be a cycle amongst #{queue.map(&:name).sort.join(", ")}"
325
332
  end
326
333
  end
327
334
 
328
- # We now need to re-add the standalone package sets. Their order is
329
- # determined by the order in the package_set section of the manifest
330
- #
331
- # Concretely, we add them in order, just after the entry above them
332
- previous = nil
333
- root_pkg_set.imports.each do |explicit_pkg_set|
334
- if !sorted.include?(explicit_pkg_set)
335
- if !previous
336
- sorted.unshift explicit_pkg_set
337
- else
338
- i = sorted.index(previous)
339
- sorted.insert(i + 1, explicit_pkg_set)
335
+ result = root_pkg_set.imports.to_a.dup
336
+ to_insert = topological.dup.
337
+ find_all { |pkg_set| !result.include?(pkg_set) }
338
+ while !to_insert.empty?
339
+ pkg_set = to_insert.shift
340
+ dependencies = pkg_set.imports.dup
341
+ if dependencies.empty?
342
+ result.unshift(pkg_set)
343
+ else
344
+ i = result.find_index do |p|
345
+ dependencies.delete(p)
346
+ dependencies.empty?
340
347
  end
348
+ result.insert(i + 1, pkg_set)
341
349
  end
342
- previous = pkg_set
343
350
  end
344
-
345
- sorted << root_pkg_set
346
- sorted
351
+ result << root_pkg_set
352
+ result
347
353
  end
348
354
 
349
355
  def load_package_sets(options = Hash.new)
@@ -243,7 +243,8 @@ module Autoproj
243
243
  manifest = ws.manifest
244
244
 
245
245
  all = Set.new
246
- package_queue = manifest.all_layout_packages(false).each_source_package_name.to_a
246
+ package_queue = manifest.all_layout_packages(false).each_source_package_name.to_a +
247
+ processed_packages.map(&:name).to_a
247
248
  while !package_queue.empty?
248
249
  pkg_name = package_queue.shift
249
250
  next if all.include?(pkg_name)
@@ -252,7 +253,7 @@ module Autoproj
252
253
  next if manifest.ignored?(pkg_name) || manifest.excluded?(pkg_name)
253
254
 
254
255
  pkg = manifest.find_autobuild_package(pkg_name)
255
- if !processed_packages.include?(pkg)
256
+ if !processed_packages.include?(pkg) && File.directory?(pkg.srcdir)
256
257
  manifest.load_package_manifest(pkg.name)
257
258
  Autoproj.each_post_import_block(pkg) do |block|
258
259
  block.call(pkg)
@@ -89,22 +89,34 @@ module Autoproj
89
89
  @ignore_errors = options[:ignore_errors]
90
90
  end
91
91
 
92
- def snapshot_package_sets(target_dir = nil)
92
+ def snapshot_package_sets(target_dir = nil, options = Hash.new)
93
+ options = Kernel.validate_options options,
94
+ local: true
95
+
93
96
  result = Array.new
94
97
  manifest.each_package_set do |pkg_set|
95
98
  next if pkg_set.local?
96
99
 
97
- if vcs_info = pkg_set.snapshot(target_dir)
100
+ vcs_info =
101
+ begin pkg_set.snapshot(target_dir, local: options[:local])
102
+ rescue Exception => e
103
+ error_or_warn(pkg_set, e)
104
+ next
105
+ end
106
+
107
+ if vcs_info
98
108
  result << Hash["pkg_set:#{pkg_set.repository_id}", vcs_info]
99
109
  else
100
- error_or_warn(pkg_set, "cannot snapshot #{package_name}: importer snapshot failed")
110
+ error_or_warn(pkg_set, "cannot snapshot package set #{pkg_set.name}: importer snapshot failed")
101
111
  end
102
112
  end
103
113
  result
104
114
  end
105
115
 
106
116
  def error_or_warn(package, error)
107
- if ignore_errors?
117
+ if error.kind_of?(Interrupt)
118
+ raise
119
+ elsif ignore_errors?
108
120
  if !error.respond_to?(:to_str)
109
121
  error = error.message
110
122
  end
@@ -116,7 +128,10 @@ module Autoproj
116
128
  end
117
129
  end
118
130
 
119
- def snapshot_packages(packages, target_dir = nil)
131
+ def snapshot_packages(packages, target_dir = nil, options = Hash.new)
132
+ options = Kernel.validate_options options,
133
+ local: true
134
+
120
135
  result = Array.new
121
136
  packages.each do |package_name|
122
137
  package = manifest.packages[package_name]
@@ -133,9 +148,10 @@ module Autoproj
133
148
  end
134
149
 
135
150
  vcs_info =
136
- begin importer.snapshot(package.autobuild, target_dir)
151
+ begin importer.snapshot(package.autobuild, target_dir, local: options[:local])
137
152
  rescue Exception => e
138
- error_or_warn(package, "cannot snapshot #{package_name}: #{e.message}")
153
+ error_or_warn(package, e)
154
+ next
139
155
  end
140
156
 
141
157
  if vcs_info
@@ -647,11 +647,21 @@ fi
647
647
  end
648
648
 
649
649
  ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
650
+ ruby_bindir = RbConfig::CONFIG['bindir']
651
+
652
+ candidates = ['gem']
650
653
  if ruby_bin =~ /^ruby(.+)$/
651
- Autobuild.programs['gem'] = "gem#{$1}"
652
- else
653
- Autobuild.programs['gem'] = "gem"
654
+ candidates << "gem#{$1}"
655
+ end
656
+
657
+ candidates.each do |gem_name|
658
+ if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
659
+ Autobuild.programs['gem'] = gem_full_path
660
+ return
661
+ end
654
662
  end
663
+
664
+ raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(", ")} in #{ruby_bindir})"
655
665
  end
656
666
 
657
667
  def build_gem_cmdlines(gems)
@@ -131,17 +131,22 @@ module Autoproj
131
131
  !File.exists?(File.join(raw_local_dir, "init.rb"))
132
132
  end
133
133
 
134
+ # Defined for coherence with the API on {PackageDefinition}
135
+ def autobuild
136
+ create_autobuild_package
137
+ end
138
+
134
139
  def create_autobuild_package
135
140
  Ops::Tools.create_autobuild_package(vcs, name, raw_local_dir)
136
141
  end
137
142
 
138
- def snapshot(target_dir)
143
+ def snapshot(target_dir, options = Hash.new)
139
144
  if local?
140
145
  Hash.new
141
146
  else
142
147
  package = create_autobuild_package
143
148
  if package.importer.respond_to?(:snapshot)
144
- package.importer.snapshot(package, target_dir)
149
+ package.importer.snapshot(package, target_dir, options)
145
150
  end
146
151
  end
147
152
  end
@@ -2,7 +2,6 @@ require 'autobuild/reporting'
2
2
  module Autoproj
3
3
  class << self
4
4
  attr_accessor :verbose
5
- attr_reader :console
6
5
  def silent?
7
6
  Autobuild.silent?
8
7
  end
@@ -11,8 +10,6 @@ module Autoproj
11
10
  end
12
11
  end
13
12
  @verbose = false
14
- @console = HighLine.new
15
-
16
13
 
17
14
  def self.silent(&block)
18
15
  Autobuild.silent(&block)
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "2.0.0.b6"
2
+ VERSION = "2.0.0.b7"
3
3
  end
@@ -140,7 +140,12 @@ module Autoproj
140
140
  @config = Configuration.new(config_path)
141
141
  if File.file?(config_path)
142
142
  config.load(reconfigure: reconfigure)
143
- manifest.vcs = VCSDefinition.from_raw(config.get('manifest_source', nil))
143
+ if raw_vcs = config.get('manifest_source', nil)
144
+ manifest.vcs = VCSDefinition.from_raw(raw_vcs)
145
+ else
146
+ manifest.vcs = VCSDefinition.from_raw(
147
+ type: 'local', url: config_dir)
148
+ end
144
149
  end
145
150
  end
146
151
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.b6
4
+ version: 2.0.0.b7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autobuild