autoproj 2.13.0 → 2.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +24 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +5 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +224 -199
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +223 -198
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +9 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +64 -34
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/python.rb +18 -0
  25. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  26. data/lib/autoproj/base.rb +1 -1
  27. data/lib/autoproj/bash_completion.rb +5 -6
  28. data/lib/autoproj/build_option.rb +22 -24
  29. data/lib/autoproj/cli/base.rb +26 -26
  30. data/lib/autoproj/cli/bootstrap.rb +14 -16
  31. data/lib/autoproj/cli/build.rb +10 -7
  32. data/lib/autoproj/cli/cache.rb +11 -11
  33. data/lib/autoproj/cli/clean.rb +10 -10
  34. data/lib/autoproj/cli/commit.rb +7 -8
  35. data/lib/autoproj/cli/doc.rb +2 -2
  36. data/lib/autoproj/cli/envsh.rb +1 -2
  37. data/lib/autoproj/cli/exec.rb +60 -20
  38. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  39. data/lib/autoproj/cli/locate.rb +30 -41
  40. data/lib/autoproj/cli/log.rb +7 -7
  41. data/lib/autoproj/cli/main.rb +213 -204
  42. data/lib/autoproj/cli/main_doc.rb +22 -21
  43. data/lib/autoproj/cli/main_global.rb +44 -19
  44. data/lib/autoproj/cli/main_plugin.rb +18 -18
  45. data/lib/autoproj/cli/main_test.rb +28 -27
  46. data/lib/autoproj/cli/manifest.rb +7 -7
  47. data/lib/autoproj/cli/osdeps.rb +12 -11
  48. data/lib/autoproj/cli/patcher.rb +2 -3
  49. data/lib/autoproj/cli/query.rb +17 -18
  50. data/lib/autoproj/cli/reconfigure.rb +1 -2
  51. data/lib/autoproj/cli/reset.rb +9 -12
  52. data/lib/autoproj/cli/show.rb +38 -39
  53. data/lib/autoproj/cli/status.rb +45 -39
  54. data/lib/autoproj/cli/switch_config.rb +5 -6
  55. data/lib/autoproj/cli/tag.rb +12 -11
  56. data/lib/autoproj/cli/test.rb +7 -7
  57. data/lib/autoproj/cli/update.rb +35 -37
  58. data/lib/autoproj/cli/utility.rb +11 -10
  59. data/lib/autoproj/cli/version.rb +42 -40
  60. data/lib/autoproj/cli/versions.rb +14 -15
  61. data/lib/autoproj/cli/watch.rb +33 -37
  62. data/lib/autoproj/cli/which.rb +16 -20
  63. data/lib/autoproj/cli.rb +4 -2
  64. data/lib/autoproj/configuration.rb +77 -85
  65. data/lib/autoproj/default.osdeps +18 -3
  66. data/lib/autoproj/environment.rb +42 -23
  67. data/lib/autoproj/exceptions.rb +9 -3
  68. data/lib/autoproj/find_workspace.rb +20 -25
  69. data/lib/autoproj/git_server_configuration.rb +40 -44
  70. data/lib/autoproj/gitorious.rb +1 -1
  71. data/lib/autoproj/installation_manifest.rb +64 -29
  72. data/lib/autoproj/local_package_set.rb +13 -11
  73. data/lib/autoproj/manifest.rb +137 -130
  74. data/lib/autoproj/metapackage.rb +2 -6
  75. data/lib/autoproj/ops/atomic_write.rb +7 -6
  76. data/lib/autoproj/ops/build.rb +4 -6
  77. data/lib/autoproj/ops/cache.rb +41 -43
  78. data/lib/autoproj/ops/cached_env.rb +5 -4
  79. data/lib/autoproj/ops/configuration.rb +525 -507
  80. data/lib/autoproj/ops/import.rb +76 -64
  81. data/lib/autoproj/ops/install.rb +217 -191
  82. data/lib/autoproj/ops/loader.rb +77 -76
  83. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  84. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  85. data/lib/autoproj/ops/snapshot.rb +250 -247
  86. data/lib/autoproj/ops/tools.rb +76 -78
  87. data/lib/autoproj/ops/watch.rb +6 -6
  88. data/lib/autoproj/ops/which.rb +17 -14
  89. data/lib/autoproj/options.rb +13 -2
  90. data/lib/autoproj/os_package_installer.rb +102 -92
  91. data/lib/autoproj/os_package_query.rb +7 -13
  92. data/lib/autoproj/os_package_resolver.rb +189 -140
  93. data/lib/autoproj/os_repository_installer.rb +4 -4
  94. data/lib/autoproj/os_repository_resolver.rb +8 -6
  95. data/lib/autoproj/package_definition.rb +12 -13
  96. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
  97. data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
  98. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  99. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  100. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  101. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  102. data/lib/autoproj/package_managers/manager.rb +8 -3
  103. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  104. data/lib/autoproj/package_managers/pip_manager.rb +30 -28
  105. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  106. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  107. data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
  108. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  109. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  110. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  111. data/lib/autoproj/package_manifest.rb +28 -74
  112. data/lib/autoproj/package_selection.rb +187 -187
  113. data/lib/autoproj/package_set.rb +144 -113
  114. data/lib/autoproj/python.rb +297 -0
  115. data/lib/autoproj/query_base.rb +20 -14
  116. data/lib/autoproj/reporter.rb +19 -19
  117. data/lib/autoproj/repository_managers/apt.rb +102 -68
  118. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  119. data/lib/autoproj/ros_condition_parser.rb +84 -0
  120. data/lib/autoproj/ros_package_manifest.rb +125 -0
  121. data/lib/autoproj/shell_completion.rb +16 -13
  122. data/lib/autoproj/source_package_query.rb +29 -36
  123. data/lib/autoproj/system.rb +32 -21
  124. data/lib/autoproj/test.rb +127 -104
  125. data/lib/autoproj/variable_expansion.rb +7 -9
  126. data/lib/autoproj/vcs_definition.rb +35 -32
  127. data/lib/autoproj/version.rb +1 -1
  128. data/lib/autoproj/workspace.rb +142 -108
  129. data/lib/autoproj/zsh_completion.rb +8 -9
  130. data/lib/autoproj.rb +55 -55
  131. data/samples/autoproj/init.rb +1 -2
  132. metadata +80 -46
  133. data/.travis.yml +0 -24
data/lib/autoproj/test.rb CHANGED
@@ -1,30 +1,30 @@
1
1
  # simplecov must be loaded FIRST. Only the files required after it gets loaded
2
2
  # will be profiled !!!
3
- if ENV['TEST_ENABLE_COVERAGE'] == '1'
3
+ if ENV["TEST_ENABLE_COVERAGE"] == "1"
4
4
  begin
5
- require 'simplecov'
5
+ require "simplecov"
6
6
  SimpleCov.start do
7
- command_name 'master'
7
+ command_name "master"
8
8
  add_filter "/test/"
9
9
  end
10
10
  rescue LoadError
11
- require 'autoproj'
11
+ require "autoproj"
12
12
  Autoproj.warn "coverage is disabled because the 'simplecov' gem cannot be loaded"
13
13
  rescue Exception => e
14
- require 'autoproj'
14
+ require "autoproj"
15
15
  Autoproj.warn "coverage is disabled: #{e.message}"
16
16
  end
17
17
  end
18
18
 
19
- require 'minitest/autorun'
20
- require 'autoproj'
21
- require 'flexmock/minitest'
19
+ require "minitest/autorun"
20
+ require "autoproj"
21
+ require "flexmock/minitest"
22
22
  FlexMock.partials_are_based = true
23
- require 'minitest/spec'
23
+ require "minitest/spec"
24
24
 
25
- if ENV['TEST_ENABLE_PRY'] != '0'
25
+ if ENV["TEST_ENABLE_PRY"] != "0"
26
26
  begin
27
- require 'pry'
27
+ require "pry"
28
28
  rescue Exception
29
29
  Autoproj.warn "debugging is disabled because the 'pry' gem cannot be loaded"
30
30
  end
@@ -55,11 +55,13 @@ module Autoproj
55
55
  attr_reader :ws
56
56
 
57
57
  def setup
58
- if ENV['AUTOPROJ_CURRENT_ROOT']
58
+ if ENV["AUTOPROJ_CURRENT_ROOT"]
59
59
  raise "cannot have a workspace's env.sh loaded while running the "\
60
60
  "Autoproj test suite"
61
61
  end
62
62
 
63
+ Autobuild.progress_display_mode = :newline
64
+
63
65
  if defined?(Autoproj::CLI::Main)
64
66
  Autoproj::CLI::Main.default_report_on_package_failures = :raise
65
67
  end
@@ -69,8 +71,8 @@ module Autoproj
69
71
  @ws = nil
70
72
  @ws_package_managers = Hash.new
71
73
  Autobuild.logdir = make_tmpdir
72
- ws_define_package_manager 'os'
73
- ws_define_package_manager 'os_indep'
74
+ ws_define_package_manager "os"
75
+ ws_define_package_manager "os_indep"
74
76
  Autobuild.progress_display_period = 0
75
77
 
76
78
  super
@@ -91,14 +93,14 @@ module Autoproj
91
93
  if defined?(Autoproj::CLI::Main)
92
94
  Autoproj::CLI::Main.default_report_on_package_failures = nil
93
95
  end
94
- if ENV.delete('AUTOPROJ_CURRENT_ROOT')
96
+ if ENV.delete("AUTOPROJ_CURRENT_ROOT")
95
97
  raise "AUTOPROJ_CURRENT_ROOT has been set by this test !!!!"
96
98
  end
97
99
  end
98
100
 
99
101
  def data_path(*args)
100
102
  File.expand_path(File.join(*args),
101
- File.join(__dir__, '..', '..', 'test', 'data'))
103
+ File.join(__dir__, "..", "..", "test", "data"))
102
104
  end
103
105
 
104
106
  def create_bootstrap
@@ -106,7 +108,7 @@ module Autoproj
106
108
  end
107
109
 
108
110
  def skip_long_tests?
109
- ENV['AUTOPROJ_SKIP_LONG_TESTS'] == '1'
111
+ ENV["AUTOPROJ_SKIP_LONG_TESTS"] == "1"
110
112
  end
111
113
 
112
114
  def make_tmpdir
@@ -116,7 +118,7 @@ module Autoproj
116
118
  end
117
119
 
118
120
  def scripts_dir
119
- File.expand_path(File.join('..', '..', 'test', 'scripts'), __dir__)
121
+ File.expand_path(File.join("..", "..", "test", "scripts"), __dir__)
120
122
  end
121
123
 
122
124
  def find_gem_dir(gem_name)
@@ -127,38 +129,43 @@ module Autoproj
127
129
  end
128
130
 
129
131
  def autoproj_gemfile_to_local_checkout
130
- autoproj_dir = find_gem_dir('autoproj').full_gem_path
131
- autobuild_dir = find_gem_dir('autobuild').full_gem_path
132
- "source \"http://localhost:8808\"
133
- gem 'autoproj', path: '#{autoproj_dir}'
134
- gem 'autobuild', path: '#{autobuild_dir}'
135
- "
132
+ autoproj_dir = find_gem_dir("autoproj").full_gem_path
133
+ autobuild_dir = find_gem_dir("autobuild").full_gem_path
134
+ <<~GEMFILE
135
+ source "https://rubygems.org"
136
+ gem "autoproj", path: "#{autoproj_dir}"
137
+ gem "autobuild", path: "#{autobuild_dir}"
138
+ GEMFILE
136
139
  end
137
140
 
138
141
  def invoke_test_script(name, *arguments,
139
- dir: nil,
140
- gemfile_source: nil,
141
- use_autoproj_from_rubygems: (ENV['USE_AUTOPROJ_FROM_RUBYGEMS'] == '1'),
142
- interactive: true,
143
- seed_config: File.join(scripts_dir, 'seed-config.yml'),
144
- env: Hash.new, display_output: false, copy_from: nil,
145
- **system_options)
146
- package_base_dir = File.expand_path(File.join('..', '..'), __dir__)
142
+ dir: make_tmpdir,
143
+ gemfile_source: nil,
144
+ use_autoproj_from_rubygems: (ENV["USE_AUTOPROJ_FROM_RUBYGEMS"] == "1"),
145
+ interactive: true,
146
+ seed_config: File.join(scripts_dir, "seed-config.yml"),
147
+ env: {}, display_output: false, copy_from: nil,
148
+ **system_options)
149
+ package_base_dir = File.expand_path(File.join("..", ".."), __dir__)
147
150
 
148
151
  script = File.expand_path(name, scripts_dir)
149
152
  unless File.file?(script)
150
153
  raise ArgumentError, "no test script #{name} in #{scripts_dir}"
151
154
  end
152
155
 
153
- arguments << '--seed-config' << seed_config if seed_config
154
- dir ||= make_tmpdir
156
+ if env["HOME"]
157
+ @home_dir = env["HOME"]
158
+ else
159
+ env["HOME"] = (@home_dir ||= make_tmpdir)
160
+ end
161
+ arguments << "--seed-config" << seed_config if seed_config
155
162
 
156
163
  if gemfile_source || !use_autoproj_from_rubygems
157
- gemfile_path = File.join(dir, 'Gemfile-dev')
158
- File.open(gemfile_path, 'w') do |io|
164
+ gemfile_path = File.join(dir, "Gemfile-dev")
165
+ File.open(gemfile_path, "w") do |io|
159
166
  io.puts(gemfile_source || autoproj_gemfile_to_local_checkout)
160
167
  end
161
- arguments << "--gemfile" << gemfile_path << "--gem-source" << "http://localhost:8808"
168
+ arguments << "--gemfile" << gemfile_path
162
169
  end
163
170
 
164
171
  arguments << "--no-interactive" unless interactive
@@ -173,13 +180,14 @@ gem 'autobuild', path: '#{autobuild_dir}'
173
180
  result = nil
174
181
  stdout, stderr = capture_subprocess_io do
175
182
  default_env = Hash[
176
- 'TEST_COMMAND_NAME' => to_s.gsub(/[^\w]/, '_'),
177
- 'PACKAGE_BASE_DIR' => package_base_dir,
178
- 'RUBY' => Gem.ruby
183
+ "TEST_COMMAND_NAME" => to_s.gsub(/[^\w]/, "_"),
184
+ "PACKAGE_BASE_DIR" => package_base_dir,
185
+ "RUBY" => Gem.ruby
179
186
  ]
180
187
  result = Autoproj.bundler_unbundled_system(
181
188
  default_env.merge(env), script, *arguments,
182
- in: :close, **Hash[chdir: dir].merge(system_options))
189
+ in: :close, **Hash[chdir: dir].merge(system_options)
190
+ )
183
191
  end
184
192
 
185
193
  if !result
@@ -194,59 +202,64 @@ gem 'autobuild', path: '#{autobuild_dir}'
194
202
  end
195
203
 
196
204
  def fixture_gem_home
197
- File.join(__dir__, '..', '..', 'vendor', 'test_gem_home')
205
+ File.join(__dir__, "..", "..", "vendor", "test_gem_home")
198
206
  end
199
207
 
200
208
  def prepare_fixture_gem_home
201
209
  FileUtils.rm_rf fixture_gem_home
210
+ FileUtils.mkdir_p File.dirname(fixture_gem_home)
202
211
  bundled_gems_path = File.expand_path(File.join("..", ".."),
203
- find_gem_dir('utilrb').full_gem_path)
212
+ find_gem_dir("utilrb").full_gem_path)
204
213
  FileUtils.cp_r bundled_gems_path, fixture_gem_home
205
214
 
206
- vendor = File.join(__dir__, '..', '..', 'vendor')
215
+ vendor = File.join(__dir__, "..", "..", "vendor")
207
216
  bundler_filename = "bundler-#{Bundler::VERSION}.gem"
208
217
  cached_bundler_gem = File.join(vendor, bundler_filename)
209
218
  unless File.file?(cached_bundler_gem)
210
219
  FileUtils.mkdir_p vendor
211
220
  Autoproj.bundler_unbundled_system(
212
- Ops::Install.guess_gem_program, 'fetch', '-v',
213
- Bundler::VERSION, 'bundler', chdir: vendor)
214
-
215
- unless File.file?(bundler_filename)
216
- raise "cannot download the bundler gem"
221
+ Ops::Install.guess_gem_program, "fetch", "-v",
222
+ Bundler::VERSION, "bundler", chdir: vendor
223
+ )
224
+
225
+ unless File.file?(cached_bundler_gem)
226
+ existing = Dir.enum_for(:glob, File.join(vendor, "*")).to_a.sort
227
+ raise "cannot download the bundler gem. "\
228
+ "Expected #{bundler_filename}, found: #{existing.join(', ')}"
217
229
  end
218
230
  end
219
231
 
220
232
  capture_subprocess_io do
221
233
  Autoproj.bundler_unbundled_system(
222
- Hash['GEM_HOME' => fixture_gem_home, 'GEM_PATH' => nil],
223
- Ops::Install.guess_gem_program, 'install', '--no-document',
224
- cached_bundler_gem)
234
+ Hash["GEM_HOME" => fixture_gem_home, "GEM_PATH" => nil],
235
+ Ops::Install.guess_gem_program, "install", "--no-document",
236
+ cached_bundler_gem
237
+ )
225
238
  end
226
239
  end
227
240
 
228
241
  def start_gem_server(path = fixture_gem_home)
229
- require 'socket'
230
- require 'rubygems/server'
242
+ require "socket"
243
+ require "rubygems/server"
231
244
  if @gem_server_pid
232
- raise ArgumentError, "#start_gem_server already called, "\
233
- "call stop_gem_server before calling start_gem_server again"
245
+ raise ArgumentError,
246
+ "#start_gem_server already called, "\
247
+ "call stop_gem_server before calling start_gem_server again"
234
248
  end
235
249
  @gem_server_pid = spawn(
236
- Hash['RUBYOPT' => nil],
237
- Gem.ruby, Ops::Install.guess_gem_program, 'server',
238
- '--quiet', '--dir', path, out: :close, err: :close)
250
+ Hash["RUBYOPT" => nil],
251
+ Gem.ruby, Ops::Install.guess_gem_program, "server",
252
+ "--quiet", "--dir", path, out: :close, err: :close
253
+ )
239
254
  loop do
240
- begin
241
- TCPSocket.new('127.0.0.1', 8808)
242
- break
243
- rescue Errno::ECONNREFUSED # rubocop:disable Lint/HandleExceptions
244
- end
255
+ TCPSocket.new("127.0.0.1", 8808)
256
+ break
257
+ rescue Errno::ECONNREFUSED
245
258
  end
246
259
  end
247
260
 
248
261
  def stop_gem_server
249
- Process.kill 'INT', @gem_server_pid
262
+ Process.kill "INT", @gem_server_pid
250
263
  Process.waitpid @gem_server_pid
251
264
  @gem_server_pid = nil
252
265
  end
@@ -264,17 +277,18 @@ gem 'autobuild', path: '#{autobuild_dir}'
264
277
  def find_bundled_gem_path(bundler, gem_name, gemfile)
265
278
  out_r, out_w = IO.pipe
266
279
  result = Autoproj.bundler_unbundled_system(
267
- bundler, 'show', gem_name,
280
+ bundler, "show", gem_name,
268
281
  out: out_w,
269
- chdir: File.dirname(gemfile))
282
+ chdir: File.dirname(gemfile)
283
+ )
270
284
  out_w.close
271
285
  output = out_r.read.chomp
272
286
  assert result, "bundler show #{gem_name} failed, output: '#{output}'"
273
287
  output
274
288
  end
275
289
 
276
- def workspace_env(varname)
277
- _, stdout, = invoke_test_script 'display-env.sh', varname, dir: install_dir
290
+ def workspace_env(dir, varname)
291
+ _, stdout, = invoke_test_script "display-env.sh", varname, dir: dir
278
292
  stdout.chomp
279
293
  end
280
294
 
@@ -298,34 +312,36 @@ gem 'autobuild', path: '#{autobuild_dir}'
298
312
 
299
313
  def ws_create_os_package_resolver
300
314
  @ws_os_package_resolver = OSPackageResolver.new(
301
- operating_system: [['test_os_family'], ['test_os_version']],
315
+ operating_system: [["test_os_family"], ["test_os_version"]],
302
316
  package_managers: ws_package_managers.keys,
303
- os_package_manager: 'os')
317
+ os_package_manager: "os"
318
+ )
304
319
  end
305
320
 
306
321
  def ws_create(dir = make_tmpdir, partial_config: false)
307
- require 'autoproj/ops/main_config_switcher'
322
+ require "autoproj/ops/main_config_switcher"
308
323
  FileUtils.cp_r Ops::MainConfigSwitcher::MAIN_CONFIGURATION_TEMPLATE,
309
- File.join(dir, 'autoproj')
310
- FileUtils.mkdir_p File.join(dir, '.autoproj')
324
+ File.join(dir, "autoproj")
325
+ FileUtils.mkdir_p File.join(dir, ".autoproj")
311
326
 
312
327
  ws_create_os_package_resolver
313
328
  @ws = Workspace.new(
314
329
  dir, os_package_resolver: ws_os_package_resolver,
315
- package_managers: ws_package_managers)
330
+ package_managers: ws_package_managers
331
+ )
316
332
 
317
333
  unless partial_config
318
- ws.config.set 'osdeps_mode', 'all'
319
- ws.config.set 'apt_dpkg_update', true
334
+ ws.config.set "osdeps_mode", "all"
335
+ ws.config.set "apt_dpkg_update", true
320
336
  end
321
- ws.config.set 'GITHUB', 'http,ssh', true
322
- ws.config.set 'GITORIOUS', 'http,ssh', true
323
- ws.config.set 'gems_install_path', File.join(dir, 'gems')
337
+ ws.config.set "GITHUB", "http,ssh", true
338
+ ws.config.set "GITORIOUS", "http,ssh", true
339
+ ws.config.set "gems_install_path", File.join(dir, "gems")
324
340
  ws.prefix_dir = make_tmpdir
325
341
  ws.config.save
326
342
 
327
343
  # Make a valid (albeit empty) Gemfile
328
- File.open(File.join(ws.dot_autoproj_dir, 'Gemfile'), 'w').close
344
+ File.open(File.join(ws.dot_autoproj_dir, "Gemfile"), "w").close
329
345
  ws
330
346
  end
331
347
 
@@ -334,26 +350,29 @@ gem 'autobuild', path: '#{autobuild_dir}'
334
350
  end
335
351
 
336
352
  def ws_define_package_set(
337
- name, vcs = VCSDefinition.from_raw({ type: 'none' }), **options
353
+ name, vcs = VCSDefinition.from_raw({ type: "none" }),
354
+ raw_local_dir: PackageSet.raw_local_dir_of(ws, vcs)
338
355
  )
339
- package_set = PackageSet.new(ws, vcs, name: name, **options)
356
+ package_set = PackageSet.new(
357
+ ws, vcs, name: name, raw_local_dir: raw_local_dir
358
+ )
340
359
  ws.manifest.register_package_set(package_set)
341
360
  package_set
342
361
  end
343
362
 
344
363
  def ws_create_local_package_set(name, path, source_data: Hash.new, **options)
345
- vcs = VCSDefinition.from_raw(type: 'local', url: path)
364
+ vcs = VCSDefinition.from_raw({ type: "local", url: path })
346
365
  package_set = PackageSet.new(ws, vcs, name: name, **options)
347
366
  FileUtils.mkdir_p(path)
348
- File.open(File.join(path, 'source.yml'), 'w') do |io|
349
- YAML.dump(Hash['name' => name].merge(source_data), io)
367
+ File.open(File.join(path, "source.yml"), "w") do |io|
368
+ YAML.dump(Hash["name" => name].merge(source_data), io)
350
369
  end
351
370
  ws.manifest.register_package_set(package_set)
352
371
  package_set
353
372
  end
354
373
 
355
374
  def ws_add_package_set_to_layout(
356
- name, vcs = VCSDefinition.from_raw({ type: 'none' }), **options
375
+ name, vcs = VCSDefinition.from_raw({ type: "none" }), **options
357
376
  )
358
377
  package_set = ws_define_package_set(name, vcs, **options)
359
378
  ws.manifest.add_package_set_to_layout(package_set)
@@ -378,8 +397,8 @@ gem 'autobuild', path: '#{autobuild_dir}'
378
397
  end
379
398
 
380
399
  def ws_define_package(package_type, package_name,
381
- package_set: ws.manifest.main_package_set,
382
- create: true, &block)
400
+ package_set: ws.manifest.main_package_set,
401
+ create: true, &block)
383
402
  package = Autobuild.send(package_type, package_name)
384
403
  ws_setup_package(
385
404
  package, package_set: package_set, create: create, &block
@@ -387,7 +406,7 @@ gem 'autobuild', path: '#{autobuild_dir}'
387
406
  end
388
407
 
389
408
  def ws_setup_package(package, package_set: ws.manifest.main_package_set,
390
- create: true)
409
+ create: true)
391
410
  package.srcdir = File.join(ws.root_dir, package.name.to_s)
392
411
  FileUtils.mkdir_p package.srcdir if create
393
412
  autoproj_package = ws.register_package(package, nil, package_set)
@@ -399,14 +418,18 @@ gem 'autobuild', path: '#{autobuild_dir}'
399
418
  package.package_set.add_version_control_entry(package.name, vcs_spec)
400
419
  end
401
420
 
421
+ def ws_resolve_vcs(package)
422
+ package.vcs = ws.manifest.importer_definition_for(package)
423
+ end
424
+
402
425
  def ws_define_package_overrides(package, package_set, vcs_spec)
403
426
  package_set.add_overrides_entry(package.name, vcs_spec)
404
427
  end
405
428
 
406
429
  def ws_add_package_to_layout(package_type, package_name,
407
- package_set: ws.manifest.main_package_set, &block)
430
+ package_set: ws.manifest.main_package_set, &block)
408
431
  pkg = ws_define_package(package_type, package_name,
409
- package_set: package_set, &block)
432
+ package_set: package_set, &block)
410
433
  ws.manifest.add_package_to_layout(pkg)
411
434
  pkg
412
435
  end
@@ -427,26 +450,26 @@ gem 'autobuild', path: '#{autobuild_dir}'
427
450
  FileUtils.rm_rf srcdir
428
451
  end
429
452
  package.autobuild.builddir = builddir =
430
- File.join(ws.root_dir, 'build', package.name)
453
+ File.join(ws.root_dir, "build", package.name)
431
454
  package.autobuild.prefix = prefix =
432
- File.join(ws.root_dir, 'prefix', package.name)
455
+ File.join(ws.root_dir, "prefix", package.name)
433
456
  [srcdir, builddir, prefix]
434
457
  end
435
458
 
436
459
  def ws_create_git_package_set(name, source_data = Hash.new)
437
460
  dir = make_tmpdir
438
- unless system('git', 'init', chdir: dir, out: :close)
461
+ unless system("git", "init", chdir: dir, out: :close)
439
462
  raise "failed to run git init"
440
463
  end
441
464
 
442
- File.open(File.join(dir, 'source.yml'), 'w') do |io|
443
- YAML.dump(Hash['name' => name].merge(source_data), io)
465
+ File.open(File.join(dir, "source.yml"), "w") do |io|
466
+ YAML.dump(Hash["name" => name].merge(source_data), io)
444
467
  end
445
- unless system('git', 'add', 'source.yml', chdir: dir, out: :close)
468
+ unless system("git", "add", "source.yml", chdir: dir, out: :close)
446
469
  raise "failed to add the source.yml"
447
470
  end
448
471
 
449
- unless system('git', 'commit', '-m', 'add source.yml',
472
+ unless system("git", "commit", "-m", "add source.yml",
450
473
  chdir: dir, out: :close)
451
474
  raise "failed to commit the source.yml"
452
475
  end
@@ -457,7 +480,7 @@ gem 'autobuild', path: '#{autobuild_dir}'
457
480
  def ws_create_package_set_file(pkg_set, name, content)
458
481
  path = File.join(pkg_set.raw_local_dir, name)
459
482
  FileUtils.mkdir_p File.dirname(path)
460
- File.open(path, 'w') do |io|
483
+ File.open(path, "w") do |io|
461
484
  io.write content
462
485
  end
463
486
  path
@@ -466,16 +489,16 @@ gem 'autobuild', path: '#{autobuild_dir}'
466
489
  def ws_create_package_file(pkg, name, content)
467
490
  path = File.join(pkg.autobuild.srcdir, name)
468
491
  FileUtils.mkdir_p File.dirname(path)
469
- File.open(path, 'w') do |io|
492
+ File.open(path, "w") do |io|
470
493
  io.write content
471
494
  end
472
495
  path
473
496
  end
474
497
 
475
498
  def gemfile_aruba
476
- base_dir = File.expand_path('../../', __dir__)
477
- gemfile_path = File.join(base_dir, 'tmp', 'Gemfile.local')
478
- File.open(gemfile_path, 'w') do |io|
499
+ base_dir = File.expand_path("../../", __dir__)
500
+ gemfile_path = File.join(base_dir, "tmp", "Gemfile.local")
501
+ File.open(gemfile_path, "w") do |io|
479
502
  io.write <<~GEMFILE
480
503
  source 'https://rubygems.org'
481
504
  gem 'autoproj', path: '#{base_dir}'
@@ -32,17 +32,15 @@ module Autoproj
32
32
  # If the values listed in +definitions+ also contain configuration
33
33
  # variables, they do not get expanded
34
34
  def self.single_expansion(data, definitions)
35
- if !data.respond_to?(:to_str)
36
- return data
37
- end
35
+ return data unless data.respond_to?(:to_str)
38
36
 
39
37
  data = data.gsub(/(.|^)\$(\w+)/) do |constant_name|
40
38
  prefix = constant_name[0, 1]
41
- if prefix == "\\"
42
- next(constant_name[1..-1])
43
- end
39
+ next(constant_name[1..-1]) if prefix == "\\"
40
+
44
41
  if prefix == "$"
45
- prefix, constant_name = "", constant_name[1..-1]
42
+ prefix = ""
43
+ constant_name = constant_name[1..-1]
46
44
  else
47
45
  constant_name = constant_name[2..-1]
48
46
  end
@@ -75,6 +73,7 @@ module Autoproj
75
73
  if contains_expansion?(value)
76
74
  raise ConfigError.new, "some expansions are not defined in #{value.inspect}"
77
75
  end
76
+
78
77
  value
79
78
  end
80
79
  end
@@ -97,7 +96,7 @@ module Autoproj
97
96
  # refers to variables defined in +constants+
98
97
  def self.resolve_constant_definitions(constants, definitions = Hash.new)
99
98
  definitions = definitions.merge(constants)
100
-
99
+
101
100
  all_resolutions = Hash.new
102
101
  resolution_cache = Hash.new
103
102
  constants.each do |key, value|
@@ -106,4 +105,3 @@ module Autoproj
106
105
  all_resolutions
107
106
  end
108
107
  end
109
-