autoproj 2.10.1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -8
  3. data/.travis.yml +5 -3
  4. data/autoproj.gemspec +7 -6
  5. data/bin/alog +1 -0
  6. data/bin/autoproj +1 -1
  7. data/bin/autoproj_bootstrap +149 -86
  8. data/bin/autoproj_bootstrap.in +9 -7
  9. data/bin/autoproj_install +148 -82
  10. data/bin/autoproj_install.in +8 -3
  11. data/lib/autoproj.rb +3 -0
  12. data/lib/autoproj/aruba_minitest.rb +15 -0
  13. data/lib/autoproj/autobuild_extensions/dsl.rb +61 -27
  14. data/lib/autoproj/base.rb +35 -6
  15. data/lib/autoproj/cli/base.rb +1 -1
  16. data/lib/autoproj/cli/build.rb +9 -3
  17. data/lib/autoproj/cli/cache.rb +79 -7
  18. data/lib/autoproj/cli/doc.rb +4 -18
  19. data/lib/autoproj/cli/inspection_tool.rb +5 -6
  20. data/lib/autoproj/cli/main.rb +41 -18
  21. data/lib/autoproj/cli/main_doc.rb +86 -0
  22. data/lib/autoproj/cli/main_plugin.rb +3 -0
  23. data/lib/autoproj/cli/main_test.rb +15 -0
  24. data/lib/autoproj/cli/show.rb +12 -18
  25. data/lib/autoproj/cli/status.rb +15 -9
  26. data/lib/autoproj/cli/test.rb +13 -84
  27. data/lib/autoproj/cli/update.rb +77 -19
  28. data/lib/autoproj/cli/utility.rb +136 -0
  29. data/lib/autoproj/configuration.rb +28 -4
  30. data/lib/autoproj/default.osdeps +18 -0
  31. data/lib/autoproj/installation_manifest.rb +7 -5
  32. data/lib/autoproj/manifest.rb +15 -21
  33. data/lib/autoproj/ops/build.rb +23 -27
  34. data/lib/autoproj/ops/cache.rb +151 -33
  35. data/lib/autoproj/ops/cached_env.rb +2 -2
  36. data/lib/autoproj/ops/import.rb +146 -80
  37. data/lib/autoproj/ops/install.rb +140 -79
  38. data/lib/autoproj/ops/phase_reporting.rb +49 -0
  39. data/lib/autoproj/ops/snapshot.rb +2 -1
  40. data/lib/autoproj/ops/tools.rb +2 -2
  41. data/lib/autoproj/os_package_installer.rb +19 -11
  42. data/lib/autoproj/package_definition.rb +29 -10
  43. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +49 -28
  44. data/lib/autoproj/package_managers/bundler_manager.rb +257 -87
  45. data/lib/autoproj/package_managers/homebrew_manager.rb +2 -2
  46. data/lib/autoproj/package_managers/shell_script_manager.rb +44 -24
  47. data/lib/autoproj/package_manifest.rb +49 -34
  48. data/lib/autoproj/package_set.rb +48 -29
  49. data/lib/autoproj/repository_managers/apt.rb +0 -1
  50. data/lib/autoproj/test.rb +29 -10
  51. data/lib/autoproj/variable_expansion.rb +3 -1
  52. data/lib/autoproj/vcs_definition.rb +30 -15
  53. data/lib/autoproj/version.rb +1 -1
  54. data/lib/autoproj/workspace.rb +55 -13
  55. metadata +32 -28
@@ -15,7 +15,7 @@ def filter_uptodate_packages(packages)
15
15
  # somewhere else
16
16
  packages = packages.uniq
17
17
  command_line = "brew info --json=v1 #{packages.join(' ')}"
18
- result = Bundler.with_clean_env do
18
+ result = Autoproj.bundler_with_unbundled_env do
19
19
  (Autobuild::Subprocess.run 'autoproj', 'osdeps', command_line).first
20
20
  end
21
21
 
@@ -30,7 +30,7 @@ def filter_uptodate_packages(packages)
30
30
  end
31
31
  return packages
32
32
  end
33
-
33
+
34
34
  # fall back if something else went wrong
35
35
  if packages.size != result.size
36
36
  Autoproj.warn "brew info returns less or more packages when requested. Falling back to install all packages"
@@ -7,8 +7,10 @@ def self.execute(command_line, with_locking, with_root, env: Autobuild.env)
7
7
  if with_locking
8
8
  File.open('/tmp/autoproj_osdeps_lock', 'w') do |lock_io|
9
9
  begin
10
- while !lock_io.flock(File::LOCK_EX | File::LOCK_NB)
11
- Autoproj.message " waiting for other autoproj instances to finish their osdeps installation"
10
+ until lock_io.flock(File::LOCK_EX | File::LOCK_NB)
11
+ Autoproj.message " waiting for other autoproj "\
12
+ "instances to finish their osdeps "\
13
+ "installation"
12
14
  sleep 5
13
15
  end
14
16
  return execute(command_line, false, with_root, env: env)
@@ -17,7 +19,7 @@ def self.execute(command_line, with_locking, with_root, env: Autobuild.env)
17
19
  end
18
20
  end
19
21
  end
20
-
22
+
21
23
  if with_root
22
24
  sudo = Autobuild.tool_in_path('sudo', env: env)
23
25
  command_line = [sudo, *command_line]
@@ -34,10 +36,12 @@ def self.execute(command_line, with_locking, with_root, env: Autobuild.env)
34
36
  # This declares if this package manager cannot be used concurrently.
35
37
  # If it is the case, autoproj will ensure that there is no two
36
38
  # autoproj instances running this package manager at the same time
37
- #
39
+ #
38
40
  # @return [Boolean]
39
41
  # @see needs_locking=
40
- def needs_locking?; !!@needs_locking end
42
+ def needs_locking?
43
+ @needs_locking
44
+ end
41
45
 
42
46
  # Overrides the {#needs_root?} flag
43
47
  attr_writer :needs_root
@@ -45,10 +49,12 @@ def needs_locking?; !!@needs_locking end
45
49
  #
46
50
  # This declares if the command line(s) for this package manager
47
51
  # should be started as root. Root access is provided using sudo
48
- #
52
+ #
49
53
  # @return [Boolean]
50
54
  # @see needs_root=
51
- def needs_root?; !!@needs_root end
55
+ def needs_root?
56
+ @needs_root
57
+ end
52
58
 
53
59
  # Command line used by autoproj to install packages
54
60
  #
@@ -83,10 +89,13 @@ def needs_root?; !!@needs_root end
83
89
  # itself, see {#auto_install_cmd}.
84
90
  # @param [Boolean] needs_root if the command lines should be started
85
91
  # as root or not. See {#needs_root?}
86
- def initialize(ws, needs_locking, user_install_cmd, auto_install_cmd,needs_root=true)
92
+ def initialize(ws, needs_locking, user_install_cmd,
93
+ auto_install_cmd, needs_root = true)
87
94
  super(ws)
88
- @needs_locking, @user_install_cmd, @auto_install_cmd,@needs_root =
89
- needs_locking, user_install_cmd, auto_install_cmd, needs_root
95
+ @needs_locking = needs_locking
96
+ @user_install_cmd = user_install_cmd
97
+ @auto_install_cmd = auto_install_cmd
98
+ @needs_root = needs_root
90
99
  end
91
100
 
92
101
  # Generate the shell script that would allow the user to install
@@ -98,7 +107,8 @@ def initialize(ws, needs_locking, user_install_cmd, auto_install_cmd,needs_root=
98
107
  # command-line pattern that should be used to generate the script.
99
108
  # If given, it overrides the default value stored in
100
109
  # {#user_install_cmd]
101
- def generate_user_os_script(os_packages, user_install_cmd: self.user_install_cmd)
110
+ def generate_user_os_script(os_packages,
111
+ user_install_cmd: self.user_install_cmd)
102
112
  if user_install_cmd
103
113
  user_install_cmd.join(" ") + " " + os_packages.join("' '")
104
114
  else generate_auto_os_script(os_packages)
@@ -114,7 +124,8 @@ def generate_user_os_script(os_packages, user_install_cmd: self.user_install_cmd
114
124
  # command-line pattern that should be used to generate the script.
115
125
  # If given, it overrides the default value stored in
116
126
  # {#auto_install_cmd]
117
- def generate_auto_os_script(os_packages, auto_install_cmd: self.auto_install_cmd)
127
+ def generate_auto_os_script(os_packages,
128
+ auto_install_cmd: self.auto_install_cmd)
118
129
  auto_install_cmd.join(" ") + " " + os_packages.join("' '")
119
130
  end
120
131
 
@@ -139,9 +150,9 @@ def osdeps_interaction(os_packages, shell_script)
139
150
  # anyway, do so now
140
151
  puts <<-EOMSG
141
152
 
142
- #{Autoproj.color("The build process and/or the packages require some other software to be installed", :bold)}
143
- #{Autoproj.color("and you required autoproj to not install them itself", :bold)}
144
- #{Autoproj.color("\nIf these packages are already installed, simply ignore this message\n", :red) if !respond_to?(:filter_uptodate_packages)}
153
+ #{Autoproj.color('The build process and/or the packages require some other software to be installed', :bold)}
154
+ #{Autoproj.color('and you required autoproj to not install them itself', :bold)}
155
+ #{Autoproj.color('\nIf these packages are already installed, simply ignore this message\n', :red) unless respond_to?(:filter_uptodate_packages)}
145
156
  The following packages are available as OS dependencies, i.e. as prebuilt
146
157
  packages provided by your distribution / operating system. You will have to
147
158
  install them manually if they are not already installed
@@ -152,8 +163,8 @@ def osdeps_interaction(os_packages, shell_script)
152
163
 
153
164
  #{shell_script.split("\n").join("\n| ")}
154
165
 
155
- EOMSG
156
- print " #{Autoproj.color("Press ENTER to continue ", :bold)}"
166
+ EOMSG
167
+ print " #{Autoproj.color('Press ENTER to continue ', :bold)}"
157
168
  STDOUT.flush
158
169
  STDIN.readline
159
170
  puts
@@ -172,23 +183,33 @@ def osdeps_interaction(os_packages, shell_script)
172
183
  # packages. See the option in {#generate_auto_os_script}
173
184
  # @return [Boolean] true if packages got installed, false otherwise
174
185
  def install(packages, filter_uptodate_packages: false, install_only: false,
175
- auto_install_cmd: self.auto_install_cmd, user_install_cmd: self.user_install_cmd)
186
+ auto_install_cmd: self.auto_install_cmd,
187
+ user_install_cmd: self.user_install_cmd)
176
188
  return if packages.empty?
177
189
 
178
190
  handled_os = ws.supported_operating_system?
179
191
  if handled_os
180
- shell_script = generate_auto_os_script(packages, auto_install_cmd: auto_install_cmd)
181
- user_shell_script = generate_user_os_script(packages, user_install_cmd: user_install_cmd)
192
+ shell_script = generate_auto_os_script(
193
+ packages, auto_install_cmd: auto_install_cmd
194
+ )
195
+ user_shell_script = generate_user_os_script(
196
+ packages, user_install_cmd: user_install_cmd
197
+ )
182
198
  end
183
199
  if osdeps_interaction(packages, user_shell_script)
184
- Autoproj.message " installing OS packages: #{packages.sort.join(", ")}"
200
+ Autoproj.message " installing OS packages: "\
201
+ "#{packages.sort.join(', ')}"
185
202
 
186
203
  if Autoproj.verbose
187
- Autoproj.message "Generating installation script for non-ruby OS dependencies"
204
+ Autoproj.message "Generating installation script for "\
205
+ "non-ruby OS dependencies"
188
206
  Autoproj.message shell_script
189
207
  end
190
208
 
191
- ShellScriptManager.execute([*auto_install_cmd, *packages], needs_locking?, needs_root?, env: ws.env)
209
+ ShellScriptManager.execute(
210
+ [*auto_install_cmd, *packages], needs_locking?,
211
+ needs_root?, env: ws.env
212
+ )
192
213
  return true
193
214
  end
194
215
  false
@@ -196,4 +217,3 @@ def install(packages, filter_uptodate_packages: false, install_only: false,
196
217
  end
197
218
  end
198
219
  end
199
-
@@ -30,13 +30,15 @@ def self.load(package, file, ros_manifest: false)
30
30
  # @param [Boolean] ros_manifest whether the file follows the ROS format
31
31
  # @return [PackageManifest]
32
32
  # @see load
33
- def self.parse(package, contents, path: '<loaded from string>', loader_class: Loader)
34
- manifest = PackageManifest.new(package)
33
+ def self.parse(package, contents,
34
+ path: '<loaded from string>', loader_class: Loader)
35
+ manifest = PackageManifest.new(package, path)
35
36
  loader = loader_class.new(path, manifest)
36
37
  begin
37
38
  REXML::Document.parse_stream(contents, loader)
38
39
  rescue REXML::ParseException => e
39
- raise Autobuild::PackageException.new(package.name, 'prepare'), "invalid #{file}: #{e.message}"
40
+ raise Autobuild::PackageException.new(package.name, 'prepare'),
41
+ "invalid #{file}: #{e.message}"
40
42
  end
41
43
  manifest
42
44
  end
@@ -45,7 +47,8 @@ def self.parse(package, contents, path: '', loader_class: Lo
45
47
  Dependency = Struct.new :name, :optional, :modes
46
48
 
47
49
  # The Autobuild::Package instance this manifest applies on
48
- attr_reader :package
50
+ attr_accessor :package
51
+ attr_reader :path
49
52
  attr_accessor :description
50
53
  attr_accessor :brief_description
51
54
  attr_reader :dependencies
@@ -63,7 +66,7 @@ def add_dependency(name, optional: false, modes: [])
63
66
  end
64
67
 
65
68
  def has_documentation?
66
- !!description
69
+ description
67
70
  end
68
71
 
69
72
  def documentation
@@ -71,16 +74,18 @@ def documentation
71
74
  end
72
75
 
73
76
  def has_short_documentation?
74
- !!brief_description
77
+ brief_description
75
78
  end
76
79
 
77
80
  def short_documentation
78
81
  brief_description ||
79
- "no documentation available for package '#{package.name}' in its manifest.xml file"
82
+ "no documentation available for package '#{package.name}' "\
83
+ "in its manifest.xml file"
80
84
  end
81
85
 
82
- def initialize(package, null: false)
86
+ def initialize(package, path = nil, null: false)
83
87
  @package = package
88
+ @path = path
84
89
  @dependencies = []
85
90
  @authors = []
86
91
  @maintainers = []
@@ -92,11 +97,12 @@ def initialize(package, null: false)
92
97
  # Whether this is a null manifest (used for packages that have actually
93
98
  # no manifest) or not
94
99
  def null?
95
- !!@null
100
+ @null
96
101
  end
97
102
 
98
- def each_dependency(in_modes = Array.new, &block)
99
- return enum_for(__method__, in_modes) if !block_given?
103
+ def each_dependency(in_modes = [])
104
+ return enum_for(__method__, in_modes) unless block_given?
105
+
100
106
  dependencies.each do |dep|
101
107
  if dep.modes.empty? || in_modes.any? { |m| dep.modes.include?(m) }
102
108
  yield(dep.name, dep.optional)
@@ -105,24 +111,28 @@ def each_dependency(in_modes = Array.new, &block)
105
111
  end
106
112
 
107
113
  def each_os_dependency(modes = Array.new, &block)
108
- Autoproj.warn_deprecated "#{self.class}##{__method__}", "call #each_dependency instead"
109
- return each_dependency(modes, &block)
114
+ Autoproj.warn_deprecated "#{self.class}##{__method__}",
115
+ "call #each_dependency instead"
116
+ each_dependency(modes, &block)
110
117
  end
111
118
 
112
119
  def each_package_dependency(modes = Array.new, &block)
113
- Autoproj.warn_deprecated "#{self.class}##{__method__}", "call #each_dependency instead"
114
- return each_dependency(modes, &block)
120
+ Autoproj.warn_deprecated "#{self.class}##{__method__}",
121
+ "call #each_dependency instead"
122
+ each_dependency(modes, &block)
115
123
  end
116
124
 
117
125
  def each_rock_maintainer
118
- return enum_for(__method__) if !block_given?
126
+ return enum_for(__method__) unless block_given?
127
+
119
128
  rock_maintainers.each do |m|
120
129
  yield(m.name, m.email)
121
130
  end
122
131
  end
123
132
 
124
133
  def each_maintainer
125
- return enum_for(__method__) if !block_given?
134
+ return enum_for(__method__) unless block_given?
135
+
126
136
  maintainers.each do |m|
127
137
  yield(m.name, m.email)
128
138
  end
@@ -131,7 +141,8 @@ def each_maintainer
131
141
  # Enumerates the name and email of each author. If no email is present,
132
142
  # yields (name, nil)
133
143
  def each_author
134
- return enum_for(__method__) if !block_given?
144
+ return enum_for(__method__) unless block_given?
145
+
135
146
  authors.each do |m|
136
147
  yield(m.name, m.email)
137
148
  end
@@ -175,11 +186,13 @@ def initialize(path, manifest)
175
186
 
176
187
  def parse_depend_tag(tag_name, attributes, modes: [], optional: false)
177
188
  package = attributes['package'] || attributes['name']
178
- if !package
179
- raise InvalidPackageManifest, "found '#{tag_name}' tag in #{path} without a 'package' attribute"
189
+ unless package
190
+ raise InvalidPackageManifest,
191
+ "found '#{tag_name}' tag in #{path} "\
192
+ "without a 'package' attribute"
180
193
  end
181
194
 
182
- if tag_modes = attributes['modes']
195
+ if (tag_modes = attributes['modes'])
183
196
  modes += tag_modes.split(',')
184
197
  end
185
198
 
@@ -192,7 +205,7 @@ def parse_depend_tag(tag_name, attributes, modes: [], optional: false)
192
205
  def parse_contact_field(text)
193
206
  text.strip.split(',').map do |str|
194
207
  name, email = str.split('/').map(&:strip)
195
- email = nil if email && email.empty?
208
+ email = nil if email&.empty?
196
209
  ContactInfo.new(name, email)
197
210
  end
198
211
  end
@@ -210,7 +223,7 @@ def toplevel_tag_start(name, attributes)
210
223
  elsif name =~ /^(\w+)_depend$/
211
224
  parse_depend_tag(name, attributes, modes: [$1])
212
225
  elsif name == 'description'
213
- if brief = attributes['brief']
226
+ if (brief = attributes['brief'])
214
227
  manifest.brief_description = brief
215
228
  end
216
229
  @tag_text = ''
@@ -222,14 +235,13 @@ def toplevel_tag_start(name, attributes)
222
235
  @tag_text = nil
223
236
  end
224
237
  end
238
+
225
239
  def toplevel_tag_end(name)
226
240
  if AUTHOR_FIELDS.include?(name)
227
241
  manifest.send("#{name}s").concat(parse_contact_field(@tag_text))
228
242
  elsif TEXT_FIELDS.include?(name)
229
243
  field = @tag_text.strip
230
- if !field.empty?
231
- manifest.send("#{name}=", field)
232
- end
244
+ manifest.send("#{name}=", field) unless field.empty?
233
245
  elsif name == 'tags'
234
246
  manifest.tags.concat(@tag_text.strip.split(',').map(&:strip))
235
247
  end
@@ -242,10 +254,10 @@ def toplevel_tag_end(name)
242
254
  # REXML stream parser object used to load the XML contents into a
243
255
  # {PackageManifest} object
244
256
  class RosLoader < Loader
245
- SUPPORTED_MODES = ['test'].freeze
246
- DEPEND_TAGS = Set['depend', 'build_depend', 'build_export_depend',
247
- 'buildtool_depend', 'buildtool_export_depend',
248
- 'exec_depend', 'test_depend', 'run_depend']
257
+ SUPPORTED_MODES = %w[test doc].freeze
258
+ DEPEND_TAGS = %w[depend build_depend build_export_depend
259
+ buildtool_depend buildtool_export_depend
260
+ exec_depend test_depend run_depend doc_depend].to_set.freeze
249
261
 
250
262
  def toplevel_tag_start(name, attributes)
251
263
  if DEPEND_TAGS.include?(name)
@@ -262,18 +274,21 @@ def toplevel_tag_start(name, attributes)
262
274
 
263
275
  def toplevel_tag_end(name)
264
276
  if DEPEND_TAGS.include?(name)
265
- raise InvalidPackageManifest, "found '#{name}' tag in #{path} without content" if @tag_text.strip.empty?
277
+ if @tag_text.strip.empty?
278
+ raise InvalidPackageManifest, "found '#{name}' tag in #{path} "\
279
+ "without content"
280
+ end
266
281
 
267
282
  mode = []
268
- if name =~ /^(\w+)_depend$/
269
- mode = SUPPORTED_MODES & [$1]
283
+ if (m = /^(\w+)_depend$/.match(name))
284
+ mode = SUPPORTED_MODES & [m[1]]
270
285
  end
271
286
 
272
287
  manifest.add_dependency(@tag_text, modes: mode)
273
288
  elsif AUTHOR_FIELDS.include?(name)
274
289
  author_name = @tag_text.strip
275
290
  email = @author_email ? @author_email.strip : nil
276
- email = nil if email && email.empty?
291
+ email = nil if email&.empty?
277
292
  contact = ContactInfo.new(author_name, email)
278
293
  manifest.send("#{name}s").concat([contact])
279
294
  elsif TEXT_FIELDS.include?(name)
@@ -168,7 +168,7 @@ def initialize(
168
168
  @version_control = Array.new
169
169
  @overrides = Array.new
170
170
  @raw_local_dir = raw_local_dir
171
- @default_importer = VCSDefinition.from_raw(type: 'none')
171
+ @default_importer = VCSDefinition.from_raw({ type: 'none' })
172
172
 
173
173
  @imports = Set.new
174
174
  @imports_vcs = Array.new
@@ -239,7 +239,7 @@ def snapshot(target_dir, options = Hash.new)
239
239
  else
240
240
  package = create_autobuild_package
241
241
  if package.importer.respond_to?(:snapshot)
242
- package.importer.snapshot(package, target_dir, options)
242
+ package.importer.snapshot(package, target_dir, **options)
243
243
  end
244
244
  end
245
245
  end
@@ -535,7 +535,9 @@ def parse_source_definition(source_definition)
535
535
 
536
536
  Autoproj.in_file(source_file) do
537
537
  default_vcs_spec, raw = version_control_field(
538
- 'default', version_control, file: source_file)
538
+ 'default', version_control,
539
+ file: source_file, section: 'version_control'
540
+ )
539
541
  if default_vcs_spec
540
542
  @default_importer = VCSDefinition.from_raw(default_vcs_spec,
541
543
  raw: raw, from: self)
@@ -653,28 +655,30 @@ def normalize_vcs_list(section_name, file, list)
653
655
  # package in the form (PackageSet,Hash), where PackageSet is self.
654
656
  # The Hash part is nil if there are no matching entries. Hash keys are
655
657
  # normalized to symbols
656
- def version_control_field(package_name, entry_list, validate: true, file: source_file)
658
+ def version_control_field(package_name, entry_list, validate: true,
659
+ file: source_file, section: nil)
657
660
  raw = []
658
- vcs_spec = Hash.new
661
+ vcs_spec = entry_list.inject({}) do |resolved_spec, (name_match, spec)|
662
+ next(resolved_spec) unless name_match === package_name
659
663
 
660
- entry_list.each do |name_match, spec|
661
- if name_match === package_name
662
- raw << VCSDefinition::RawEntry.new(self, file, spec)
663
- vcs_spec =
664
- begin
665
- VCSDefinition.update_raw_vcs_spec(vcs_spec, spec)
666
- rescue ConfigError => e
667
- raise ConfigError.new, "invalid VCS definition in the #{section_name} section for '#{name}': #{e.message}", e.backtrace
668
- end
664
+ raw << VCSDefinition::RawEntry.new(self, file, spec)
665
+ begin
666
+ VCSDefinition.update_raw_vcs_spec(resolved_spec, spec)
667
+ rescue ArgumentError => e
668
+ raise ConfigError.new,
669
+ 'invalid VCS definition while resolving package '\
670
+ "'#{package_name}', entry '#{name_match}' of "\
671
+ "#{section ? "section '#{section}'" : ''}: "\
672
+ "#{e.message}", e.backtrace
669
673
  end
670
674
  end
671
675
 
672
- if vcs_spec.empty?
673
- return nil, []
674
- end
676
+ return nil, [] if vcs_spec.empty?
675
677
 
676
- expansions = Hash["PACKAGE" => package_name,
677
- "PACKAGE_BASENAME" => File.basename(package_name)]
678
+ expansions = {
679
+ 'PACKAGE' => package_name,
680
+ 'PACKAGE_BASENAME' => File.basename(package_name)
681
+ }
678
682
 
679
683
  vcs_spec = expand(vcs_spec, expansions)
680
684
  vcs_spec.dup.each do |name, value|
@@ -682,7 +686,7 @@ def version_control_field(package_name, entry_list, validate: true, file: source
682
686
  end
683
687
 
684
688
  # Resolve relative paths w.r.t. the workspace root dir
685
- if url = (vcs_spec.delete('url') || vcs_spec.delete(:url))
689
+ if (url = (vcs_spec.delete('url') || vcs_spec.delete(:url)))
686
690
  vcs_spec[:url] = VCSDefinition.to_absolute_url(url, ws.root_dir)
687
691
  end
688
692
 
@@ -691,11 +695,14 @@ def version_control_field(package_name, entry_list, validate: true, file: source
691
695
  if validate
692
696
  begin
693
697
  VCSDefinition.from_raw(vcs_spec)
694
- rescue ConfigError => e
695
- raise ConfigError.new, "invalid resulting VCS definition for package #{package_name}: #{e.message}", e.backtrace
698
+ rescue ArgumentError => e
699
+ raise ConfigError.new,
700
+ 'invalid resulting VCS definition for package '\
701
+ "'#{package_name}': #{e.message}",
702
+ e.backtrace
696
703
  end
697
704
  end
698
- return vcs_spec, raw
705
+ [vcs_spec, raw]
699
706
  end
700
707
 
701
708
  # @api private
@@ -706,15 +713,20 @@ def invalidate_importer_definitions_cache
706
713
  end
707
714
 
708
715
  # Returns the VCS definition for +package_name+ as defined in this
709
- # source, or nil if the source does not have any.
716
+ # package set, or nil if the source does not have any.
710
717
  #
711
718
  # @param [PackageDefinition] package
712
719
  # @return [VCSDefinition] the importer definition, or nil if none
713
720
  # could be found
714
721
  def importer_definition_for(package, default: default_importer, require_existing: true)
715
- package_name = manifest.validate_package_name_argument(package, require_existing: require_existing)
722
+ package_name = manifest.validate_package_name_argument(
723
+ package, require_existing: require_existing
724
+ )
716
725
  importer_definitions_cache[package_name] ||= Autoproj.in_file source_file do
717
- vcs_spec, raw = version_control_field(package_name, version_control, file: source_file)
726
+ vcs_spec, raw = version_control_field(
727
+ package_name, version_control,
728
+ file: source_file, section: 'version_control'
729
+ )
718
730
  if vcs_spec
719
731
  VCSDefinition.from_raw(vcs_spec, raw: raw, from: self)
720
732
  else
@@ -729,7 +741,9 @@ def importer_definition_for(package, default: default_importer, require_existing
729
741
  # @param [VCSDefinition] the vcs to be updated
730
742
  # @return [VCSDefinition] the new, updated vcs object
731
743
  def overrides_for(package, vcs, require_existing: true)
732
- package_name = manifest.validate_package_name_argument(package, require_existing: require_existing)
744
+ package_name = manifest.validate_package_name_argument(
745
+ package, require_existing: require_existing
746
+ )
733
747
  resolve_overrides(package_name, vcs)
734
748
  end
735
749
 
@@ -742,7 +756,10 @@ def resolve_overrides(key, vcs)
742
756
  overrides.each do |file, file_overrides|
743
757
  new_spec, new_raw_entry =
744
758
  Autoproj.in_file file do
745
- version_control_field(key, file_overrides, validate: false, file: file)
759
+ version_control_field(
760
+ key, file_overrides,
761
+ validate: false, file: file, section: 'overrides'
762
+ )
746
763
  end
747
764
 
748
765
  if new_spec
@@ -750,7 +767,9 @@ def resolve_overrides(key, vcs)
750
767
  begin
751
768
  vcs = vcs.update(new_spec, raw: new_raw_entry, from: self)
752
769
  rescue ConfigError => e
753
- raise ConfigError.new, "invalid resulting VCS specification in the overrides section for #{key}: #{e.message}"
770
+ raise ConfigError.new, "invalid resulting VCS specification "\
771
+ "in the overrides section for "\
772
+ "#{key}: #{e.message}"
754
773
  end
755
774
  end
756
775
  end