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
@@ -1,5 +1,5 @@
1
- require 'autoproj/ops/loader'
2
- require 'xdg'
1
+ require "autoproj/ops/loader"
2
+ require "xdg"
3
3
 
4
4
  module Autoproj
5
5
  class Workspace < Ops::Loader
@@ -52,11 +52,12 @@ module Autoproj
52
52
  attr_reader :osdep_suffixes
53
53
 
54
54
  def initialize(root_dir,
55
- os_package_resolver: OSPackageResolver.new,
56
- package_managers: OSPackageInstaller::PACKAGE_MANAGERS,
57
- os_repository_resolver: OSRepositoryResolver.new(
58
- operating_system: os_package_resolver.operating_system),
59
- os_repository_installer: OSRepositoryInstaller.new(self))
55
+ os_package_resolver: OSPackageResolver.new,
56
+ package_managers: OSPackageInstaller::PACKAGE_MANAGERS,
57
+ os_repository_resolver: OSRepositoryResolver.new(
58
+ operating_system: os_package_resolver.operating_system
59
+ ),
60
+ os_repository_installer: OSRepositoryInstaller.new(self))
60
61
  @root_dir = root_dir
61
62
  @root_path = Pathname.new(root_dir)
62
63
  @ruby_version_keyword = "ruby#{RUBY_VERSION.split('.')[0, 2].join('')}"
@@ -65,7 +66,7 @@ module Autoproj
65
66
  @loader = loader
66
67
  @env = Environment.new
67
68
  env.prepare(root_dir)
68
- env.source_before(File.join(dot_autoproj_dir, 'env.sh'))
69
+ env.source_before(File.join(dot_autoproj_dir, "env.sh"))
69
70
 
70
71
  @os_repository_resolver = os_repository_resolver
71
72
  @os_repository_installer = os_repository_installer
@@ -74,7 +75,8 @@ module Autoproj
74
75
  @config = Configuration.new(config_file_path)
75
76
 
76
77
  @os_package_installer = OSPackageInstaller.new(
77
- self, os_package_resolver, package_managers: package_managers)
78
+ self, os_package_resolver, package_managers: package_managers
79
+ )
78
80
  super(root_dir)
79
81
  end
80
82
 
@@ -83,7 +85,7 @@ module Autoproj
83
85
  # @return [String,nil] the root path, or nil if one did not yet source
84
86
  # the workspace's env.sh
85
87
  def self.autoproj_current_root
86
- if (env = ENV['AUTOPROJ_CURRENT_ROOT'])
88
+ if (env = ENV["AUTOPROJ_CURRENT_ROOT"])
87
89
  env unless env.empty?
88
90
  end
89
91
  end
@@ -107,7 +109,7 @@ module Autoproj
107
109
  Workspace.new(path, **workspace_options)
108
110
  elsif Autoproj.find_v1_workspace_dir(dir)
109
111
  raise OutdatedWorkspace, "#{dir} looks like a v1 workspace, "\
110
- "run autoproj upgrade before continuing"
112
+ "run autoproj upgrade before continuing"
111
113
  else
112
114
  raise NotWorkspace, "not in a Autoproj installation"
113
115
  end
@@ -118,13 +120,13 @@ module Autoproj
118
120
  from_dir(path, **workspace_options)
119
121
  elsif Autoproj.find_v1_workspace_dir(dir = Autoproj.default_find_base_dir)
120
122
  raise OutdatedWorkspace, "#{dir} looks like a v1 workspace, "\
121
- "run autoproj upgrade before continuing"
122
- elsif (envvar = ENV['AUTOPROJ_CURRENT_ROOT'])
123
+ "run autoproj upgrade before continuing"
124
+ elsif (envvar = ENV["AUTOPROJ_CURRENT_ROOT"])
123
125
  raise NotWorkspace, "AUTOPROJ_CURRENT_ROOT is currently set "\
124
- "to #{envvar}, but that is not an Autoproj workspace"
126
+ "to #{envvar}, but that is not an Autoproj workspace"
125
127
  else
126
128
  raise NotWorkspace, "not in an Autoproj installation, "\
127
- "and no env.sh has been loaded so far"
129
+ "and no env.sh has been loaded so far"
128
130
  end
129
131
  end
130
132
 
@@ -146,9 +148,10 @@ module Autoproj
146
148
  ws = from_environment(**workspace_options)
147
149
  from_pwd = Autoproj.find_workspace_dir(Dir.pwd)
148
150
  if from_pwd && (from_pwd != ws.root_dir)
149
- raise MismatchingWorkspace, "the current environment points to "\
150
- "#{ws.root_dir}, but you are in #{from_pwd}, make sure you "\
151
- "are loading the right #{ENV_FILENAME} script !"
151
+ raise MismatchingWorkspace,
152
+ "the current environment points to "\
153
+ "#{ws.root_dir}, but you are in #{from_pwd}, make sure you "\
154
+ "are loading the right #{ENV_FILENAME} script !"
152
155
  end
153
156
  ws
154
157
  end
@@ -166,13 +169,13 @@ module Autoproj
166
169
  #
167
170
  # @return [String]
168
171
  def config_dir
169
- File.join(root_dir, 'autoproj')
172
+ File.join(root_dir, "autoproj")
170
173
  end
171
174
 
172
175
  # The directory under which autoproj saves all its internal
173
176
  # configuration and files
174
177
  def dot_autoproj_dir
175
- File.join(root_dir, '.autoproj')
178
+ File.join(root_dir, ".autoproj")
176
179
  end
177
180
 
178
181
  # The installation manifest
@@ -182,12 +185,12 @@ module Autoproj
182
185
 
183
186
  # The path to the workspace configuration file
184
187
  def config_file_path
185
- File.join(dot_autoproj_dir, 'config.yml')
188
+ File.join(dot_autoproj_dir, "config.yml")
186
189
  end
187
190
 
188
191
  # The path to the workspace's manifest file
189
192
  def manifest_file_path
190
- File.join(root_dir, 'autoproj', config.get('manifest_name', 'manifest'))
193
+ File.join(root_dir, "autoproj", config.get("manifest_name", "manifest"))
191
194
  end
192
195
 
193
196
  # Return the directory in which remote package set definition should be
@@ -213,7 +216,7 @@ module Autoproj
213
216
 
214
217
  # Change {#build_dir}
215
218
  def build_dir=(path)
216
- config.set 'build', path, true
219
+ config.set "build", path, true
217
220
  end
218
221
 
219
222
  # (see Configuration#source_dir)
@@ -227,11 +230,11 @@ module Autoproj
227
230
 
228
231
  # Change {#source_dir}
229
232
  def source_dir=(path)
230
- config.set 'source', path, true
233
+ config.set "source", path, true
231
234
  end
232
235
 
233
236
  def log_dir
234
- File.join(prefix_dir, 'log')
237
+ File.join(prefix_dir, "log")
235
238
  end
236
239
 
237
240
  OVERRIDES_DIR = "overrides.d".freeze
@@ -279,23 +282,23 @@ module Autoproj
279
282
  config.reset
280
283
  config.load(path: config_file_path, reconfigure: reconfigure)
281
284
  manifest.vcs =
282
- if (raw_vcs = config.get('manifest_source', nil))
285
+ if (raw_vcs = config.get("manifest_source", nil))
283
286
  VCSDefinition.from_raw(raw_vcs)
284
287
  else
285
- local_vcs = { type: 'local', url: config_dir }
288
+ local_vcs = { type: "local", url: config_dir }
286
289
  VCSDefinition.from_raw(local_vcs)
287
290
  end
288
291
 
289
292
  if config.source_dir && Pathname.new(config.source_dir).absolute?
290
- raise ConfigError, 'source dir path configuration must be relative'
293
+ raise ConfigError, "source dir path configuration must be relative"
291
294
  end
292
295
 
293
296
  os_package_resolver.prefer_indep_over_os_packages =
294
297
  config.prefer_indep_over_os_packages?
295
298
  os_package_resolver.operating_system ||=
296
- config.get('operating_system', nil)
299
+ config.get("operating_system", nil)
297
300
  os_repository_resolver.operating_system ||=
298
- config.get('operating_system', nil)
301
+ config.get("operating_system", nil)
299
302
  end
300
303
  @config
301
304
  end
@@ -322,7 +325,7 @@ module Autoproj
322
325
  ensure
323
326
  Autobuild.progress_done :operating_system_autodetection
324
327
  end
325
- config.set('operating_system', os_package_resolver.operating_system, true)
328
+ config.set("operating_system", os_package_resolver.operating_system, true)
326
329
  end
327
330
  end
328
331
 
@@ -344,21 +347,27 @@ module Autoproj
344
347
  end
345
348
 
346
349
  def setup_ruby_version_handling
347
- os_package_resolver.add_aliases('ruby' => ruby_version_keyword)
350
+ os_package_resolver.add_aliases("ruby" => ruby_version_keyword)
348
351
  osdep_suffixes << ruby_version_keyword
349
352
  end
350
353
 
351
- def setup
354
+ # Perform initial configuration load and workspace setup
355
+ #
356
+ # @param [Boolean] load_global_configuration if true, load the global
357
+ # autoprojrc file if it exists. Otherwise, ignore it.
358
+ def setup(load_global_configuration: true, read_only: false)
352
359
  setup_ruby_version_handling
353
360
  migrate_bundler_and_autoproj_gem_layout
354
361
  load_config
355
- register_workspace
356
- rewrite_shims
362
+ unless read_only
363
+ register_workspace
364
+ rewrite_shims
365
+ end
357
366
  autodetect_operating_system
358
367
  config.validate_ruby_executable
359
- Autobuild.programs['ruby'] = config.ruby_executable
368
+ Autobuild.programs["ruby"] = config.ruby_executable
360
369
  config.apply_autobuild_configuration
361
- load_autoprojrc
370
+ load_autoprojrc if load_global_configuration
362
371
  load_main_initrb
363
372
  config.each_reused_autoproj_installation do |p|
364
373
  manifest.reuse(p)
@@ -366,9 +375,11 @@ module Autoproj
366
375
  manifest.load(manifest_file_path) if File.exist?(manifest_file_path)
367
376
 
368
377
  Autobuild.prefix = prefix_dir
369
- FileUtils.mkdir_p File.join(prefix_dir, '.autoproj')
370
- Ops.atomic_write(File.join(prefix_dir, '.autoproj', 'config.yml')) do |io|
371
- io.puts "workspace: \"#{root_dir}\""
378
+ unless read_only
379
+ FileUtils.mkdir_p File.join(prefix_dir, ".autoproj")
380
+ Ops.atomic_write(File.join(prefix_dir, ".autoproj", "config.yml")) do |io|
381
+ io.puts "workspace: \"#{root_dir}\""
382
+ end
372
383
  end
373
384
 
374
385
  Autobuild.srcdir = source_dir
@@ -378,36 +389,36 @@ module Autoproj
378
389
  os_package_installer.each_manager_with_name do |name, manager|
379
390
  next unless manager.respond_to?(:cache_dir=)
380
391
 
381
- manager_cache_path = File.join(cache_dir, 'package_managers', name)
392
+ manager_cache_path = File.join(cache_dir, "package_managers", name)
382
393
  if File.directory?(manager_cache_path)
383
394
  manager.cache_dir = manager_cache_path
384
395
  end
385
396
  end
386
397
  end
387
398
  setup_os_package_installer
388
- install_ruby_shims
399
+ install_ruby_shims unless read_only
389
400
  end
390
401
 
391
402
  def install_ruby_shims
392
403
  install_suffix = ""
393
- if (match = /ruby(.*)$/.match(RbConfig::CONFIG['RUBY_INSTALL_NAME']))
404
+ if (match = /ruby(.*)$/.match(RbConfig::CONFIG["RUBY_INSTALL_NAME"]))
394
405
  install_suffix = match[1]
395
406
  end
396
407
 
397
- bindir = File.join(prefix_dir, 'bin')
408
+ bindir = File.join(prefix_dir, "bin")
398
409
  FileUtils.mkdir_p bindir
399
- env.add 'PATH', bindir
410
+ env.add "PATH", bindir
400
411
 
401
- Ops.atomic_write(File.join(bindir, 'ruby')) do |io|
412
+ Ops.atomic_write(File.join(bindir, "ruby")) do |io|
402
413
  io.puts "#! /bin/sh"
403
414
  io.puts "exec #{config.ruby_executable} \"$@\""
404
415
  end
405
- FileUtils.chmod 0o755, File.join(bindir, 'ruby')
416
+ FileUtils.chmod 0o755, File.join(bindir, "ruby")
406
417
 
407
418
  %w[gem irb testrb].each do |name|
408
419
  # Look for the corresponding gem program
409
420
  prg_name = "#{name}#{install_suffix}"
410
- if File.file?(prg_path = File.join(RbConfig::CONFIG['bindir'], prg_name))
421
+ if File.file?(prg_path = File.join(RbConfig::CONFIG["bindir"], prg_name))
411
422
  Ops.atomic_write(File.join(bindir, name)) do |io|
412
423
  io.puts "#! #{config.ruby_executable}"
413
424
  io.puts "exec \"#{prg_path}\", *ARGV"
@@ -418,14 +429,14 @@ module Autoproj
418
429
  end
419
430
 
420
431
  def rewrite_shims
421
- gemfile = File.join(dot_autoproj_dir, 'Gemfile')
422
- binstubs = File.join(dot_autoproj_dir, 'bin')
432
+ gemfile = File.join(dot_autoproj_dir, "Gemfile")
433
+ binstubs = File.join(dot_autoproj_dir, "bin")
423
434
  Ops::Install.rewrite_shims(binstubs, config.ruby_executable,
424
435
  root_dir, gemfile, config.gems_gem_home)
425
436
  end
426
437
 
427
438
  def update_bundler
428
- require 'autoproj/ops/install'
439
+ require "autoproj/ops/install"
429
440
  gem_program = Ops::Install.guess_gem_program
430
441
  install = Ops::Install.new(root_dir)
431
442
  Autoproj.message " updating bundler"
@@ -441,13 +452,13 @@ module Autoproj
441
452
 
442
453
  # This is a guard to avoid infinite recursion in case the user is
443
454
  # running autoproj osdeps --force
444
- return if ENV['AUTOPROJ_RESTARTING'] == '1'
455
+ return if ENV["AUTOPROJ_RESTARTING"] == "1"
445
456
 
446
- gemfile = File.join(dot_autoproj_dir, 'Gemfile')
447
- binstubs = File.join(dot_autoproj_dir, 'bin')
457
+ gemfile = File.join(dot_autoproj_dir, "Gemfile")
458
+ binstubs = File.join(dot_autoproj_dir, "bin")
448
459
  if restart_on_update
449
460
  old_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
450
- self, 'autoproj', gemfile: gemfile
461
+ self, "autoproj", gemfile: gemfile
451
462
  )
452
463
  end
453
464
  begin
@@ -460,7 +471,7 @@ module Autoproj
460
471
  end
461
472
  if restart_on_update
462
473
  new_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
463
- self, 'autoproj', gemfile: gemfile
474
+ self, "autoproj", gemfile: gemfile
464
475
  )
465
476
  end
466
477
 
@@ -474,8 +485,8 @@ module Autoproj
474
485
  #
475
486
  # ...But first save the configuration (!)
476
487
  config.save
477
- ENV['AUTOPROJ_RESTARTING'] = '1'
478
- require 'rbconfig'
488
+ ENV["AUTOPROJ_RESTARTING"] = "1"
489
+ require "rbconfig"
479
490
  exec(config.ruby_executable, $PROGRAM_NAME, *ARGV)
480
491
  end
481
492
  end
@@ -484,7 +495,8 @@ module Autoproj
484
495
  options =
485
496
  if args.last.kind_of?(Hash)
486
497
  args.pop
487
- else Hash.new
498
+ else
499
+ Hash.new
488
500
  end
489
501
  options_env = options.fetch(:env, Hash.new)
490
502
  options[:env] = env.resolved_env.merge(options_env)
@@ -492,12 +504,12 @@ module Autoproj
492
504
  end
493
505
 
494
506
  def migrate_bundler_and_autoproj_gem_layout
495
- if !File.directory?(File.join(dot_autoproj_dir, 'autoproj'))
496
- return
497
- else
498
- config_path = File.join(dot_autoproj_dir, 'config.yml')
507
+ if File.directory?(File.join(dot_autoproj_dir, "autoproj"))
508
+ config_path = File.join(dot_autoproj_dir, "config.yml")
499
509
  config = YAML.safe_load(File.read(config_path))
500
- return if config['gems_install_path']
510
+ return if config["gems_install_path"]
511
+ else
512
+ return
501
513
  end
502
514
 
503
515
  Autoproj.silent = false
@@ -540,11 +552,11 @@ module Autoproj
540
552
 
541
553
  def self.find_path(xdg_var, xdg_path, home_path)
542
554
  home_dir = begin Dir.home
543
- rescue ArgumentError
544
- return
545
- end
555
+ rescue ArgumentError
556
+ return
557
+ end
546
558
 
547
- xdg_path = File.join(XDG[xdg_var].to_path, 'autoproj', xdg_path)
559
+ xdg_path = File.join(XDG[xdg_var].to_path, "autoproj", xdg_path)
548
560
  home_path = File.join(home_dir, home_path)
549
561
 
550
562
  if File.exist?(xdg_path)
@@ -557,25 +569,25 @@ module Autoproj
557
569
  end
558
570
 
559
571
  def self.find_user_config_path(xdg_path, home_path = xdg_path)
560
- find_path('CONFIG_HOME', xdg_path, home_path)
572
+ find_path("CONFIG_HOME", xdg_path, home_path)
561
573
  end
562
574
 
563
575
  def self.rcfile_path
564
- find_user_config_path('rc', '.autoprojrc')
576
+ find_user_config_path("rc", ".autoprojrc")
565
577
  end
566
578
 
567
579
  def self.find_user_data_path(xdg_path, home_path = xdg_path)
568
- find_path('DATA_HOME', xdg_path, File.join('.autoproj', home_path))
580
+ find_path("DATA_HOME", xdg_path, File.join(".autoproj", home_path))
569
581
  end
570
582
 
571
583
  def self.find_user_cache_path(xdg_path, home_path = xdg_path)
572
- find_path('CACHE_HOME', xdg_path, File.join('.autoproj', home_path))
584
+ find_path("CACHE_HOME", xdg_path, File.join(".autoproj", home_path))
573
585
  end
574
586
 
575
587
  RegisteredWorkspace = Struct.new :root_dir, :prefix_dir, :build_dir
576
588
 
577
589
  def self.registered_workspaces
578
- path = find_user_data_path('workspaces.yml')
590
+ path = find_user_data_path("workspaces.yml")
579
591
  if File.file?(path)
580
592
  yaml = (YAML.safe_load(File.read(path)) || [])
581
593
  fields = RegisteredWorkspace.members.map(&:to_s)
@@ -590,12 +602,12 @@ module Autoproj
590
602
 
591
603
  def self.save_registered_workspaces(workspaces)
592
604
  workspaces = workspaces.map do |w|
593
- Hash['root_dir' => w.root_dir,
594
- 'prefix_dir' => w.prefix_dir,
595
- 'build_dir' => w.build_dir]
605
+ Hash["root_dir" => w.root_dir,
606
+ "prefix_dir" => w.prefix_dir,
607
+ "build_dir" => w.build_dir]
596
608
  end
597
609
 
598
- path = find_user_data_path('workspaces.yml')
610
+ path = find_user_data_path("workspaces.yml")
599
611
  FileUtils.mkdir_p(File.dirname(path))
600
612
  Ops.atomic_write(path) do |io|
601
613
  io.write YAML.dump(workspaces)
@@ -628,26 +640,26 @@ module Autoproj
628
640
  end
629
641
 
630
642
  def load_package_sets(only_local: false,
631
- checkout_only: true,
632
- reconfigure: false,
633
- keep_going: false,
634
- mainline: nil,
635
- reset: false,
636
- retry_count: nil)
643
+ checkout_only: true,
644
+ reconfigure: false,
645
+ keep_going: false,
646
+ mainline: nil,
647
+ reset: false,
648
+ retry_count: nil)
637
649
  return unless File.file?(manifest_file_path) # empty install, just return
638
650
 
639
- Ops::Configuration.new(self).
640
- load_package_sets(only_local: only_local,
641
- checkout_only: checkout_only,
642
- keep_going: keep_going,
643
- reset: reset,
644
- retry_count: retry_count,
645
- mainline: mainline)
651
+ Ops::Configuration.new(self)
652
+ .load_package_sets(only_local: only_local,
653
+ checkout_only: checkout_only,
654
+ keep_going: keep_going,
655
+ reset: reset,
656
+ retry_count: retry_count,
657
+ mainline: mainline)
646
658
  end
647
659
 
648
660
  def load_packages(selection = manifest.default_packages(false), options = {})
649
- options = Hash[warn_about_ignored_packages: true, checkout_only: true].
650
- merge(options)
661
+ options = Hash[warn_about_ignored_packages: true, checkout_only: true]
662
+ .merge(options)
651
663
  ops = Ops::Import.new(self)
652
664
  ops.import_packages(selection, options)
653
665
  end
@@ -683,7 +695,8 @@ module Autoproj
683
695
  layout =
684
696
  if config.randomize_layout?
685
697
  Digest::SHA256.hexdigest(pkg_name)[0, 12]
686
- else manifest.whereis(pkg_name)
698
+ else
699
+ manifest.whereis(pkg_name)
687
700
  end
688
701
 
689
702
  srcdir =
@@ -705,7 +718,7 @@ module Autoproj
705
718
  pkg.builddir = compute_builddir(pkg) if pkg.respond_to?(:builddir)
706
719
 
707
720
  pkg.prefix = File.join(prefix_dir, prefixdir)
708
- pkg.doc_target_dir = File.join(prefix_dir, 'doc', pkg_name)
721
+ pkg.doc_target_dir = File.join(prefix_dir, "doc", pkg_name)
709
722
  pkg.logdir = File.join(pkg.prefix, "log")
710
723
  end
711
724
 
@@ -750,26 +763,25 @@ module Autoproj
750
763
  #
751
764
  # This must be done after all ignores/excludes and package selection
752
765
  # have been properly set up (a.k.a. after package import)
753
- def finalize_setup
766
+ def finalize_setup(read_only: false)
754
767
  # Finally, disable all ignored packages on the autobuild side
755
768
  manifest.each_ignored_package(&:disable)
756
769
 
757
770
  # We now have processed the process setup blocks. All configuration
758
771
  # should be done and we can save the configuration data.
759
- config.save
772
+ config.save unless read_only
760
773
  end
761
774
 
762
775
  def all_present_packages
763
- manifest.each_autobuild_package.
764
- find_all { |pkg| File.directory?(pkg.srcdir) }.
765
- map(&:name)
776
+ manifest.each_autobuild_package
777
+ .find_all { |pkg| File.directory?(pkg.srcdir) }
778
+ .map(&:name)
766
779
  end
767
780
 
768
- # Update this workspace's installation manifest
781
+ # Generate a {InstallationManifest} with the currently known information
769
782
  #
770
- # @param [Array<String>] package_names the name of the packages that
771
- # should be updated
772
- def export_installation_manifest
783
+ # @return [InstallationManifest]
784
+ def installation_manifest
773
785
  selected_packages = manifest.all_selected_source_packages
774
786
  install_manifest = InstallationManifest.new(installation_manifest_path)
775
787
 
@@ -784,7 +796,15 @@ module Autoproj
784
796
  install_manifest.add_package(pkg)
785
797
  end
786
798
  # And save
787
- install_manifest.save
799
+ install_manifest
800
+ end
801
+
802
+ # Update this workspace's installation manifest
803
+ #
804
+ # @param [Array<String>] package_names the name of the packages that
805
+ # should be updated
806
+ def export_installation_manifest
807
+ installation_manifest.save
788
808
  end
789
809
 
790
810
  # The environment as initialized by all selected packages
@@ -803,6 +823,20 @@ module Autoproj
803
823
  full_env = self.full_env
804
824
  changed = save_cached_env(full_env)
805
825
  full_env.export_env_sh(shell_helpers: shell_helpers)
826
+
827
+ build_dir = Pathname(self.build_dir)
828
+ full_env.each_env_filename do |_, filename|
829
+ basename = File.basename(filename)
830
+ File.open(File.join(prefix_dir, basename), "w") do |io|
831
+ io.puts "source \"#{filename}\""
832
+ end
833
+ if build_dir.absolute?
834
+ build_dir.mkpath
835
+ (build_dir + basename).open("w") do |io|
836
+ io.puts "source \"#{filename}\""
837
+ end
838
+ end
839
+ end
806
840
  changed
807
841
  end
808
842
 
@@ -844,7 +878,7 @@ module Autoproj
844
878
  end
845
879
 
846
880
  def install_os_repositories
847
- return unless os_package_installer.osdeps_mode.include?('os')
881
+ return unless os_package_installer.osdeps_mode.include?("os")
848
882
 
849
883
  os_repository_installer.install_os_repositories
850
884
  end
@@ -862,7 +896,7 @@ module Autoproj
862
896
  # configure the package
863
897
  # @return [PackageDefinition]
864
898
  def define_package(package_type, package_name, block = nil,
865
- package_set = manifest.main_package_set, file = nil)
899
+ package_set = manifest.main_package_set, file = nil)
866
900
  autobuild_package = Autobuild.send(package_type, package_name)
867
901
  register_package(autobuild_package, block, package_set, file)
868
902
  end
@@ -878,7 +912,7 @@ module Autoproj
878
912
  # configure the package
879
913
  # @return [PackageDefinition]
880
914
  def register_package(package, block = nil,
881
- package_set = manifest.main_package_set, file = nil)
915
+ package_set = manifest.main_package_set, file = nil)
882
916
  pkg = manifest.register_package(package, block, package_set, file)
883
917
  pkg.autobuild.ws = self
884
918
  pkg
@@ -897,7 +931,7 @@ module Autoproj
897
931
  # @raise [ExecutableNotFound] if an executable file named `cmd` cannot
898
932
  # be found
899
933
  def which(cmd, _path_entries: nil)
900
- Ops.which(cmd, path_entries: -> { full_env.value('PATH') || Array.new })
934
+ Ops.which(cmd, path_entries: -> { full_env.value("PATH") || Array.new })
901
935
  end
902
936
  end
903
937
 
@@ -1,25 +1,25 @@
1
- require 'autoproj/shell_completion'
1
+ require "autoproj/shell_completion"
2
2
 
3
3
  module Autoproj
4
4
  # This class generates shell completion for code for a given Thor subclasss
5
5
  class ZshCompletion < ShellCompletion
6
- MAIN_FUNCTION_TEMPLATE = 'main.zsh.erb'
7
- SUBCOMMAND_FUNCTION_TEMPLATE = 'subcommand.zsh.erb'
6
+ MAIN_FUNCTION_TEMPLATE = "main.zsh.erb"
7
+ SUBCOMMAND_FUNCTION_TEMPLATE = "subcommand.zsh.erb"
8
8
 
9
9
  def setup_file_completion(metadata)
10
- metadata[:completer] = '_files'
10
+ metadata[:completer] = "_files"
11
11
  end
12
12
 
13
13
  def setup_executable_completion(metadata)
14
- metadata[:completer] = '_path_commands'
14
+ metadata[:completer] = "_path_commands"
15
15
  end
16
16
 
17
17
  def setup_package_completion(metadata)
18
- metadata[:completer] = '_autoproj_installed_packages'
18
+ metadata[:completer] = "_autoproj_installed_packages"
19
19
  end
20
20
 
21
21
  def disable_completion(metadata)
22
- metadata[:completer] = ':'
22
+ metadata[:completer] = ":"
23
23
  end
24
24
 
25
25
  def quote(s)
@@ -35,9 +35,8 @@ module Autoproj
35
35
  if names.size == 1
36
36
  names.first
37
37
  else
38
- '{' + names.join(',') + '}'
38
+ "{#{names.join(',')}}"
39
39
  end
40
40
  end
41
41
  end
42
42
  end
43
-