autoproj 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) 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 +22 -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 +185 -182
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +184 -181
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +5 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +38 -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/svn.rb +1 -2
  25. data/lib/autoproj/base.rb +1 -1
  26. data/lib/autoproj/bash_completion.rb +5 -6
  27. data/lib/autoproj/build_option.rb +22 -24
  28. data/lib/autoproj/cli/base.rb +26 -26
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +10 -7
  31. data/lib/autoproj/cli/cache.rb +11 -11
  32. data/lib/autoproj/cli/clean.rb +10 -10
  33. data/lib/autoproj/cli/commit.rb +7 -8
  34. data/lib/autoproj/cli/doc.rb +2 -2
  35. data/lib/autoproj/cli/envsh.rb +1 -2
  36. data/lib/autoproj/cli/exec.rb +60 -20
  37. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  38. data/lib/autoproj/cli/locate.rb +30 -41
  39. data/lib/autoproj/cli/log.rb +7 -7
  40. data/lib/autoproj/cli/main.rb +213 -204
  41. data/lib/autoproj/cli/main_doc.rb +22 -21
  42. data/lib/autoproj/cli/main_global.rb +44 -19
  43. data/lib/autoproj/cli/main_plugin.rb +18 -18
  44. data/lib/autoproj/cli/main_test.rb +28 -27
  45. data/lib/autoproj/cli/manifest.rb +7 -7
  46. data/lib/autoproj/cli/osdeps.rb +12 -11
  47. data/lib/autoproj/cli/patcher.rb +2 -3
  48. data/lib/autoproj/cli/query.rb +17 -18
  49. data/lib/autoproj/cli/reconfigure.rb +1 -2
  50. data/lib/autoproj/cli/reset.rb +9 -12
  51. data/lib/autoproj/cli/show.rb +38 -39
  52. data/lib/autoproj/cli/status.rb +45 -39
  53. data/lib/autoproj/cli/switch_config.rb +5 -6
  54. data/lib/autoproj/cli/tag.rb +12 -11
  55. data/lib/autoproj/cli/test.rb +7 -7
  56. data/lib/autoproj/cli/update.rb +35 -37
  57. data/lib/autoproj/cli/utility.rb +11 -10
  58. data/lib/autoproj/cli/version.rb +42 -40
  59. data/lib/autoproj/cli/versions.rb +14 -15
  60. data/lib/autoproj/cli/watch.rb +33 -37
  61. data/lib/autoproj/cli/which.rb +16 -20
  62. data/lib/autoproj/cli.rb +4 -2
  63. data/lib/autoproj/configuration.rb +77 -84
  64. data/lib/autoproj/environment.rb +28 -13
  65. data/lib/autoproj/exceptions.rb +9 -3
  66. data/lib/autoproj/find_workspace.rb +20 -25
  67. data/lib/autoproj/git_server_configuration.rb +40 -44
  68. data/lib/autoproj/gitorious.rb +1 -1
  69. data/lib/autoproj/installation_manifest.rb +64 -29
  70. data/lib/autoproj/local_package_set.rb +13 -11
  71. data/lib/autoproj/manifest.rb +132 -130
  72. data/lib/autoproj/metapackage.rb +2 -6
  73. data/lib/autoproj/ops/atomic_write.rb +7 -6
  74. data/lib/autoproj/ops/build.rb +4 -6
  75. data/lib/autoproj/ops/cache.rb +41 -43
  76. data/lib/autoproj/ops/cached_env.rb +5 -4
  77. data/lib/autoproj/ops/configuration.rb +511 -506
  78. data/lib/autoproj/ops/import.rb +73 -63
  79. data/lib/autoproj/ops/install.rb +178 -174
  80. data/lib/autoproj/ops/loader.rb +77 -76
  81. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  82. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  83. data/lib/autoproj/ops/snapshot.rb +250 -247
  84. data/lib/autoproj/ops/tools.rb +76 -78
  85. data/lib/autoproj/ops/watch.rb +6 -6
  86. data/lib/autoproj/ops/which.rb +17 -14
  87. data/lib/autoproj/options.rb +13 -2
  88. data/lib/autoproj/os_package_installer.rb +102 -92
  89. data/lib/autoproj/os_package_query.rb +7 -13
  90. data/lib/autoproj/os_package_resolver.rb +189 -140
  91. data/lib/autoproj/os_repository_installer.rb +4 -4
  92. data/lib/autoproj/os_repository_resolver.rb +8 -6
  93. data/lib/autoproj/package_definition.rb +12 -13
  94. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +10 -10
  95. data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
  96. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  97. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  98. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  99. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  100. data/lib/autoproj/package_managers/manager.rb +8 -3
  101. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  102. data/lib/autoproj/package_managers/pip_manager.rb +20 -22
  103. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  104. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  105. data/lib/autoproj/package_managers/shell_script_manager.rb +32 -22
  106. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  107. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  108. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  109. data/lib/autoproj/package_manifest.rb +27 -26
  110. data/lib/autoproj/package_selection.rb +187 -187
  111. data/lib/autoproj/package_set.rb +127 -113
  112. data/lib/autoproj/python.rb +55 -55
  113. data/lib/autoproj/query_base.rb +20 -14
  114. data/lib/autoproj/reporter.rb +19 -19
  115. data/lib/autoproj/repository_managers/apt.rb +101 -67
  116. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  117. data/lib/autoproj/shell_completion.rb +16 -13
  118. data/lib/autoproj/source_package_query.rb +29 -36
  119. data/lib/autoproj/system.rb +32 -21
  120. data/lib/autoproj/test.rb +127 -104
  121. data/lib/autoproj/variable_expansion.rb +7 -9
  122. data/lib/autoproj/vcs_definition.rb +35 -32
  123. data/lib/autoproj/version.rb +1 -1
  124. data/lib/autoproj/workspace.rb +123 -107
  125. data/lib/autoproj/zsh_completion.rb +8 -9
  126. data/lib/autoproj.rb +53 -55
  127. data/samples/autoproj/init.rb +1 -2
  128. metadata +53 -51
  129. data/.travis.yml +0 -24
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
4
- require 'optparse'
5
- require 'fileutils'
6
- require 'yaml'
7
- require 'English'
3
+ require "pathname"
4
+ require "optparse"
5
+ require "fileutils"
6
+ require "yaml"
7
+ require "English"
8
8
 
9
9
  module Autoproj
10
10
  module Ops
@@ -71,33 +71,30 @@ module Autoproj
71
71
  @autoproj_options = Array.new
72
72
 
73
73
  @env = Hash.new
74
- env['RUBYOPT'] = []
75
- env['RUBYLIB'] = []
76
- env['PATH'] = self.class.sanitize_env(ENV['PATH'] || "")
77
- env['BUNDLE_GEMFILE'] = []
74
+ env["RUBYOPT"] = []
75
+ env["RUBYLIB"] = []
76
+ env["PATH"] = self.class.sanitize_env(ENV["PATH"] || "")
77
+ env["BUNDLE_GEMFILE"] = []
78
78
 
79
79
  load_config
80
80
 
81
- if config['ruby_executable'] != Gem.ruby
81
+ if config["ruby_executable"] != Gem.ruby
82
82
  raise "this autoproj installation was already bootstrapped using "\
83
- "#{config['ruby_executable']}, but you are currently running "\
84
- "under #{Gem.ruby}. Changing the ruby interpreter in a given "\
85
- "workspace is not supported, you need to do a clean bootstrap"
83
+ "#{config['ruby_executable']}, but you are currently running "\
84
+ "under #{Gem.ruby}. Changing the ruby interpreter in a given "\
85
+ "workspace is not supported, you need to do a clean bootstrap"
86
86
  end
87
- @ruby_executable = config['ruby_executable']
87
+ @ruby_executable = config["ruby_executable"]
88
88
  @local = false
89
89
 
90
- unless @gems_install_path
91
- install_gems_in_gem_user_dir
92
- end
93
- env['GEM_HOME'] = [gems_gem_home]
94
- env['GEM_PATH'] = [gems_gem_home]
90
+ install_gems_in_gem_user_dir unless @gems_install_path
91
+ env["GEM_HOME"] = [gems_gem_home]
92
+ env["GEM_PATH"] = [gems_gem_home]
95
93
  end
96
94
 
97
95
  def env_for_child(env = self.env)
98
96
  env.inject(Hash.new) do |h, (k, v)|
99
- h[k] = if v && !v.empty? then v.join(File::PATH_SEPARATOR)
100
- end
97
+ h[k] = (v.join(File::PATH_SEPARATOR) if v && !v.empty?)
101
98
  h
102
99
  end
103
100
  end
@@ -113,45 +110,56 @@ module Autoproj
113
110
  end
114
111
 
115
112
  def self.sanitize_env(value)
116
- value.split(File::PATH_SEPARATOR).
117
- find_all { |p| !in_workspace?(p) }
113
+ value.split(File::PATH_SEPARATOR)
114
+ .find_all { |p| !in_workspace?(p) }
118
115
  end
119
116
 
120
117
  def self.in_workspace?(base_dir)
121
118
  path = Pathname.new(base_dir)
122
- while !path.root?
123
- if (path + ".autoproj").exist? || (path + "autoproj").exist?
119
+ until path.root?
120
+ if path.join(".autoproj").exist? || path.join("autoproj").exist?
124
121
  return true
125
122
  end
123
+
126
124
  path = path.parent
127
125
  end
128
- return false
126
+ false
129
127
  end
130
128
 
131
129
  # The path to the .autoproj configuration directory
132
130
  #
133
131
  # @return [String]
134
- def dot_autoproj; File.join(root_dir, '.autoproj') end
132
+ def dot_autoproj
133
+ File.join(root_dir, ".autoproj")
134
+ end
135
135
 
136
136
  # The path to the gemfile used to install autoproj
137
137
  #
138
138
  # @return [String]
139
- def autoproj_gemfile_path; File.join(dot_autoproj, 'Gemfile') end
139
+ def autoproj_gemfile_path
140
+ File.join(dot_autoproj, "Gemfile")
141
+ end
140
142
 
141
143
  # The path to the autoproj configuration file
142
144
  #
143
145
  # @return [String]
144
- def autoproj_config_path; File.join(dot_autoproj, 'config.yml') end
146
+ def autoproj_config_path
147
+ File.join(dot_autoproj, "config.yml")
148
+ end
145
149
 
146
150
  # Whether the stage2 install should be called or not
147
- def skip_stage2?; !!@skip_stage2 end
151
+ def skip_stage2?
152
+ !!@skip_stage2
153
+ end
148
154
  # (see #skip_stage2?)
149
- def skip_stage2=(flag); @skip_stage2 = flag end
155
+ attr_writer :skip_stage2
150
156
 
151
157
  # Whether we can access the network while installing
152
- def local?; !!@local end
158
+ def local?
159
+ !!@local
160
+ end
153
161
  # (see #local?)
154
- def local=(flag); @local = flag end
162
+ attr_writer :local
155
163
 
156
164
  # The user-wide place where RubyGems installs gems
157
165
  def dot_gem_dir
@@ -162,8 +170,8 @@ module Autoproj
162
170
  #
163
171
  # This is also the suffix used by bundler to install gems
164
172
  def gem_path_suffix
165
- @gem_path_suffix ||= Pathname.new(Gem.user_dir).
166
- relative_path_from(Pathname.new(dot_gem_dir)).to_s
173
+ @gem_path_suffix ||= Pathname.new(Gem.user_dir)
174
+ .relative_path_from(Pathname.new(dot_gem_dir)).to_s
167
175
  end
168
176
 
169
177
  # The path into which the workspace's gems should be installed
@@ -172,7 +180,8 @@ module Autoproj
172
180
  # {#gem_path_suffix}.
173
181
  #
174
182
  # @return [String]
175
- attr_reader :gems_install_path
183
+ attr_accessor :gems_install_path
184
+
176
185
  # The GEM_HOME under which the workspace's gems should be installed
177
186
  #
178
187
  # @return [String]
@@ -184,9 +193,6 @@ module Autoproj
184
193
  # @param [String] path the absolute path that should be given to
185
194
  # bundler. The gems themselves will be installed in the
186
195
  # {#gem_path_suffix} subdirectory under this
187
- def gems_install_path=(path)
188
- @gems_install_path = path
189
- end
190
196
 
191
197
  private def xdg_var(varname, default)
192
198
  if (env = ENV[varname]) && !env.empty?
@@ -198,10 +204,11 @@ module Autoproj
198
204
 
199
205
  # Install autoproj in Gem's default user dir
200
206
  def install_gems_in_gem_user_dir
201
- xdg_default_gem_path = xdg_var('XDG_DATA_HOME',
202
- File.join(Dir.home, '.local', 'share', 'autoproj', 'gems'))
207
+ xdg_default_gem_path = xdg_var("XDG_DATA_HOME",
208
+ File.join(Dir.home, ".local", "share", "autoproj", "gems"))
203
209
  default_gem_path = File.join(
204
- Dir.home, '.autoproj', 'gems')
210
+ Dir.home, ".autoproj", "gems"
211
+ )
205
212
  @gems_install_path =
206
213
  if File.directory?(xdg_default_gem_path)
207
214
  xdg_default_gem_path
@@ -218,19 +225,18 @@ module Autoproj
218
225
  def prefer_indep_over_os_packages?
219
226
  @prefer_indep_over_os_packages
220
227
  end
228
+
221
229
  # (see #prefer_index_over_os_packages?)
222
230
  def prefer_indep_over_os_packages=(flag)
223
231
  @prefer_indep_over_os_packages = !!flag
224
232
  end
225
233
 
226
234
  def self.guess_gem_program
227
- ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
228
- ruby_bindir = RbConfig::CONFIG['bindir']
235
+ ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
236
+ ruby_bindir = RbConfig::CONFIG["bindir"]
229
237
 
230
- candidates = ['gem']
231
- if ruby_bin =~ /^ruby(.+)$/
232
- candidates.unshift "gem#{$1}"
233
- end
238
+ candidates = ["gem"]
239
+ candidates.unshift "gem#{$1}" if ruby_bin =~ /^ruby(.+)$/
234
240
 
235
241
  candidates.each do |gem_name|
236
242
  if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
@@ -238,7 +244,7 @@ module Autoproj
238
244
  end
239
245
  end
240
246
  raise ArgumentError, "cannot find a gem program "\
241
- "(tried #{candidates.sort.join(", ")} in #{ruby_bindir})"
247
+ "(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
242
248
  end
243
249
 
244
250
  # The content of the default {#gemfile}
@@ -260,74 +266,75 @@ module Autoproj
260
266
  # Parse the provided command line options and returns the non-options
261
267
  def parse_options(args = ARGV)
262
268
  options = OptionParser.new do |opt|
263
- opt.on '--local', 'do not access the network (may fail)' do
269
+ opt.on "--local", "do not access the network (may fail)" do
264
270
  @local = true
265
271
  end
266
- opt.on '--skip-stage2', 'do not run the stage2 install' do
272
+ opt.on "--skip-stage2", "do not run the stage2 install" do
267
273
  @skip_stage2 = true
268
274
  end
269
- opt.on '--debug', 'Run in debug mode' do
270
- @autoproj_options << '--debug'
275
+ opt.on "--debug", "Run in debug mode" do
276
+ @autoproj_options << "--debug"
271
277
  end
272
- opt.on '--gem-source=URL', String, 'use this source for RubyGems '\
273
- 'instead of rubygems.org' do |url|
278
+ opt.on "--gem-source=URL", String, "use this source for RubyGems "\
279
+ "instead of rubygems.org" do |url|
274
280
  @gem_source = url
275
281
  end
276
- opt.on '--gems-path=PATH', 'install gems under this path instead '\
277
- 'of ~/.autoproj/gems' do |path|
278
- self.gems_install_path = path
282
+ opt.on "--gems-path=PATH", "install gems under this path instead "\
283
+ "of ~/.autoproj/gems" do |path|
284
+ self.gems_install_path = path
279
285
  end
280
- opt.on '--public-gems', "install gems in the default gem location" do
281
- self.install_gems_in_gem_user_dir
286
+ opt.on "--public-gems", "install gems in the default gem location" do
287
+ install_gems_in_gem_user_dir
282
288
  end
283
- opt.on '--bundler-version=VERSION_CONSTRAINT', String, 'use the provided '\
284
- 'string as a version constraint for bundler' do |version|
285
- @config['bundler_version'] = version
289
+ opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
290
+ "string as a version constraint for bundler" do |version|
291
+ @config["bundler_version"] = version
286
292
  end
287
- opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided '\
288
- 'string as a version constraint for autoproj' do |version|
289
- if @gemfile
290
- raise "cannot give both --version and --gemfile"
291
- end
293
+ opt.on "--version=VERSION_CONSTRAINT", String, "use the provided "\
294
+ "string as a version constraint for autoproj" do |version|
295
+ raise "cannot give both --version and --gemfile" if @gemfile
296
+
292
297
  @gemfile = default_gemfile_contents(version)
293
298
  end
294
- opt.on '--gemfile=PATH', String, 'use the given Gemfile to install '\
295
- 'autoproj instead of the default' do |path|
296
- if @gemfile
297
- raise "cannot give both --version and --gemfile"
298
- end
299
+ opt.on "--gemfile=PATH", String, "use the given Gemfile to install "\
300
+ "autoproj instead of the default" do |path|
301
+ raise "cannot give both --version and --gemfile" if @gemfile
302
+
299
303
  @gemfile = File.read(path)
300
304
  end
301
- opt.on '--no-seed-config',
302
- 'when reinstalling an existing autoproj workspace, do not '\
303
- 'use the config in .autoproj/ as seed' do
305
+ opt.on "--no-seed-config",
306
+ "when reinstalling an existing autoproj workspace, do not "\
307
+ "use the config in .autoproj/ as seed" do
304
308
  @config.clear
305
309
  end
306
- opt.on '--seed-config=PATH', String, 'path to a seed file that '\
307
- 'should be used to initialize the configuration' do |path|
310
+ opt.on "--seed-config=PATH", String, "path to a seed file that "\
311
+ "should be used to initialize the configuration" do |path|
308
312
  add_seed_config(path)
309
313
  end
310
- opt.on '--prefer-os-independent-packages', 'prefer OS-independent '\
311
- 'packages (such as a RubyGem) over their OS-packaged equivalent '\
312
- '(e.g. the thor gem vs. the ruby-thor debian package)' do
314
+ opt.on "--prefer-os-independent-packages", "prefer OS-independent "\
315
+ "packages (such as a RubyGem) over their OS-packaged equivalent "\
316
+ "(e.g. the thor gem vs. the ruby-thor debian package)" do
313
317
  @prefer_indep_over_os_packages = true
314
318
  end
315
- opt.on '--[no-]color', 'do not use colored output (enabled by '\
316
- 'default if the terminal supports it)' do |color|
319
+ opt.on "--[no-]color", "do not use colored output (enabled by "\
320
+ "default if the terminal supports it)" do |color|
317
321
  if color then @autoproj_options << "--color"
318
- else @autoproj_options << '--no-color'
322
+ else
323
+ @autoproj_options << "--no-color"
319
324
  end
320
325
  end
321
- opt.on '--[no-]progress', 'do not use progress output (enabled by '\
322
- 'default if the terminal supports it)' do |progress|
326
+ opt.on "--[no-]progress", "do not use progress output (enabled by "\
327
+ "default if the terminal supports it)" do |progress|
323
328
  if progress then @autoproj_options << "--progress"
324
- else @autoproj_options << '--no-progress'
329
+ else
330
+ @autoproj_options << "--no-progress"
325
331
  end
326
332
  end
327
- opt.on '--[no-]interactive', 'if non-interactive, use default '\
328
- 'answer for questions' do |flag|
333
+ opt.on "--[no-]interactive", "if non-interactive, use default "\
334
+ "answer for questions" do |flag|
329
335
  if flag then @autoproj_options << "--interactive"
330
- else @autoproj_options << "--no-interactive"
336
+ else
337
+ @autoproj_options << "--no-interactive"
331
338
  end
332
339
  end
333
340
  end
@@ -336,11 +343,11 @@ module Autoproj
336
343
  end
337
344
 
338
345
  def bundler_version
339
- @config['bundler_version']
346
+ @config["bundler_version"]
340
347
  end
341
348
 
342
349
  def find_bundler(gem_program, version: nil)
343
- bundler_path = File.join(gems_gem_home, 'bin', 'bundle')
350
+ bundler_path = File.join(gems_gem_home, "bin", "bundle")
344
351
  return unless File.exist?(bundler_path)
345
352
 
346
353
  setup_paths =
@@ -359,7 +366,7 @@ module Autoproj
359
366
  def find_versioned_bundler_setup(gem_program, version)
360
367
  contents = IO.popen(
361
368
  [env_for_child, Gem.ruby, gem_program,
362
- 'contents', '-v', version, 'bundler'],
369
+ "contents", "-v", version, "bundler"],
363
370
  &:readlines
364
371
  )
365
372
  return [] unless $CHILD_STATUS.success?
@@ -370,7 +377,7 @@ module Autoproj
370
377
  def find_unversioned_bundler_setup(gem_program)
371
378
  setup_paths = IO.popen(
372
379
  [env_for_child, Gem.ruby, gem_program,
373
- 'which', '-a', 'bundler/setup'],
380
+ "which", "-a", "bundler/setup"],
374
381
  &:readlines
375
382
  )
376
383
  return [] unless $CHILD_STATUS.success?
@@ -379,29 +386,30 @@ module Autoproj
379
386
  end
380
387
 
381
388
  def install_bundler(gem_program, version: nil, silent: false)
382
- local = ['--local'] if local?
389
+ local = ["--local"] if local?
383
390
 
384
391
  redirection = Hash.new
385
- if silent
386
- redirection = Hash[out: :close]
387
- end
392
+ redirection = Hash[out: :close] if silent
388
393
 
389
394
  version_args = []
390
- version_args << '-v' << version if version
395
+ version_args << "-v" << version if version
391
396
 
392
397
  # Shut up the bundler warning about 'bin' not being in PATH
393
398
  env = self.env
394
- env['PATH'] += [File.join(gems_gem_home, 'bin')]
399
+ env = env.merge(
400
+ { "PATH" => env["PATH"] + [File.join(gems_gem_home, "bin")] }
401
+ )
395
402
  result = system(
396
403
  env_for_child(env),
397
- Gem.ruby, gem_program, 'install',
398
- '--env-shebang', '--no-document', '--no-format-executable',
399
- '--clear-sources', '--source', gem_source,
400
- '--no-user-install', '--install-dir', gems_gem_home,
401
- *local, "--bindir=#{File.join(gems_gem_home, 'bin')}",
402
- 'bundler', *version_args, **redirection)
403
-
404
- if !result
404
+ Gem.ruby, gem_program, "install",
405
+ "--env-shebang", "--no-document", "--no-format-executable",
406
+ "--clear-sources", "--source", gem_source,
407
+ "--no-user-install", "--install-dir", gems_gem_home,
408
+ *local, "--bindir=#{File.join(gems_gem_home, 'bin')}",
409
+ "bundler", *version_args, **redirection
410
+ )
411
+
412
+ unless result
405
413
  STDERR.puts "FATAL: failed to install bundler in #{gems_gem_home}"
406
414
  nil
407
415
  end
@@ -410,7 +418,7 @@ module Autoproj
410
418
  bundler_path
411
419
  else
412
420
  STDERR.puts "gem install bundler returned successfully, but still "\
413
- "cannot find bundler in #{gems_gem_home}"
421
+ "cannot find bundler in #{gems_gem_home}"
414
422
  nil
415
423
  end
416
424
  end
@@ -418,24 +426,22 @@ module Autoproj
418
426
  def install_autoproj(bundler, bundler_version: self.bundler_version)
419
427
  # Force bundler to update. If the user does not want this, let
420
428
  # him specify a Gemfile with tighter version constraints
421
- lockfile = File.join(dot_autoproj, 'Gemfile.lock')
422
- if File.exist?(lockfile)
423
- FileUtils.rm lockfile
424
- end
429
+ lockfile = File.join(dot_autoproj, "Gemfile.lock")
430
+ FileUtils.rm lockfile if File.exist?(lockfile)
425
431
 
426
432
  clean_env = env_for_child.dup
427
433
 
428
434
  opts = Array.new
429
- opts << '--local' if local?
435
+ opts << "--local" if local?
430
436
  opts << "--path=#{gems_install_path}"
431
- shims_path = File.join(dot_autoproj, 'bin')
437
+ shims_path = File.join(dot_autoproj, "bin")
432
438
 
433
439
  version_arg = []
434
440
  version_arg << "_#{bundler_version}_" if bundler_version
435
441
 
436
442
  result = system(
437
443
  clean_env,
438
- Gem.ruby, bundler, *version_arg, 'install',
444
+ Gem.ruby, bundler, *version_arg, "install",
439
445
  "--gemfile=#{autoproj_gemfile_path}",
440
446
  "--shebang=#{Gem.ruby}",
441
447
  "--binstubs=#{shims_path}",
@@ -448,7 +454,7 @@ module Autoproj
448
454
  end
449
455
  ensure
450
456
  self.class.rewrite_shims(shims_path, ruby_executable,
451
- root_dir, autoproj_gemfile_path, gems_gem_home)
457
+ root_dir, autoproj_gemfile_path, gems_gem_home)
452
458
  end
453
459
 
454
460
  EXCLUDED_FROM_SHIMS = %w[rake thor].freeze
@@ -456,13 +462,13 @@ module Autoproj
456
462
  def self.rewrite_shims(shim_path, ruby_executable,
457
463
  root_dir, autoproj_gemfile_path, gems_gem_home)
458
464
  FileUtils.mkdir_p shim_path
459
- File.open(File.join(shim_path, 'ruby'), 'w') do |io|
465
+ File.open(File.join(shim_path, "ruby"), "w") do |io|
460
466
  io.puts "#! /bin/sh"
461
467
  io.puts "exec #{ruby_executable} \"$@\""
462
468
  end
463
- FileUtils.chmod 0755, File.join(shim_path, 'ruby')
469
+ FileUtils.chmod 0755, File.join(shim_path, "ruby")
464
470
 
465
- Dir.glob(File.join(shim_path, '*')) do |bin_script|
471
+ Dir.glob(File.join(shim_path, "*")) do |bin_script|
466
472
  next unless File.file?(bin_script)
467
473
 
468
474
  bin_name = File.basename(bin_script)
@@ -470,19 +476,19 @@ module Autoproj
470
476
  FileUtils.rm_f bin_script
471
477
  next
472
478
  end
473
- next if bin_name == 'ruby'
479
+ next if bin_name == "ruby"
474
480
 
475
481
  bin_shim = File.join(shim_path, bin_name)
476
482
  bin_script_lines = File.readlines(bin_script)
477
483
  next if has_autoproj_preamble?(bin_script_lines)
478
484
 
479
- File.open(bin_shim, 'w') do |io|
480
- if bin_name == 'bundler' || bin_name == 'bundle'
485
+ File.open(bin_shim, "w") do |io|
486
+ if bin_name == "bundler" || bin_name == "bundle"
481
487
  io.puts shim_bundler(bin_script_lines, ruby_executable,
482
- autoproj_gemfile_path, gems_gem_home)
488
+ autoproj_gemfile_path, gems_gem_home)
483
489
  else
484
490
  io.puts shim_script(bin_script_lines, ruby_executable, root_dir,
485
- autoproj_gemfile_path, gems_gem_home)
491
+ autoproj_gemfile_path, gems_gem_home)
486
492
  end
487
493
  end
488
494
  FileUtils.chmod 0755, bin_shim
@@ -517,7 +523,7 @@ Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
517
523
  end
518
524
 
519
525
  def self.shim_bundler_old(ruby_executable, autoproj_gemfile_path, gems_gem_home)
520
- "#! #{ruby_executable}
526
+ "#! #{ruby_executable}
521
527
 
522
528
  #{WITHOUT_BUNDLER}
523
529
  ENV['BUNDLE_GEMFILE'] ||= '#{autoproj_gemfile_path}'
@@ -529,13 +535,13 @@ load Gem.bin_path('bundler', 'bundler')"
529
535
  end
530
536
 
531
537
  def self.shim_script(script_lines, ruby_executable, root_dir,
532
- autoproj_gemfile_path, gems_gem_home)
538
+ autoproj_gemfile_path, gems_gem_home)
533
539
  new_style = !script_lines.empty? && script_lines.any? do |l|
534
540
  l =~ /This file was generated by Bundler/
535
541
  end
536
542
  load_line = script_lines.grep(/load Gem.bin_path/).first
537
543
  return shim_script_old(ruby_executable, root_dir,
538
- autoproj_gemfile_path, gems_gem_home, load_line) \
544
+ autoproj_gemfile_path, gems_gem_home, load_line) \
539
545
  unless new_style
540
546
 
541
547
  script_lines.insert(1, <<-AUTOPROJ_PREAMBLE)
@@ -549,12 +555,12 @@ ENV['BUNDLE_GEMFILE'] = '#{autoproj_gemfile_path}'
549
555
  ENV['AUTOPROJ_CURRENT_ROOT'] = '#{root_dir}'
550
556
  Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
551
557
  AUTOPROJ_PREAMBLE
552
- return script_lines.join
558
+ script_lines.join
553
559
  end
554
560
 
555
561
  def self.shim_script_old(ruby_executable, root_dir, autoproj_gemfile_path,
556
562
  gems_gem_home, load_line)
557
- "#! #{ruby_executable}
563
+ "#! #{ruby_executable}
558
564
 
559
565
  #{RUBYLIB_REINIT}
560
566
  ENV['BUNDLE_GEMFILE'] = '#{autoproj_gemfile_path}'
@@ -579,15 +585,15 @@ require 'bundler/setup'
579
585
  end
580
586
  end
581
587
  # Generate environment files right now, we can at least use bundler
582
- File.open(File.join(dot_autoproj, 'env.sh'), 'w') do |io|
588
+ File.open(File.join(dot_autoproj, "env.sh"), "w") do |io|
583
589
  env.export_env_sh(io)
584
590
  end
585
591
 
586
592
  # And now the root envsh
587
593
  env = Autobuild::Environment.new
588
- env.source_before File.join(dot_autoproj, 'env.sh')
589
- env.set('AUTOPROJ_CURRENT_ROOT', root_dir)
590
- File.open(File.join(root_dir, 'env.sh'), 'w') do |io|
594
+ env.source_before File.join(dot_autoproj, "env.sh")
595
+ env.set("AUTOPROJ_CURRENT_ROOT", root_dir)
596
+ File.open(File.join(root_dir, "env.sh"), "w") do |io|
591
597
  env.export_env_sh(io)
592
598
  end
593
599
  end
@@ -616,22 +622,19 @@ require 'bundler/setup'
616
622
  ].join("\n")
617
623
 
618
624
  FileUtils.mkdir_p File.dirname(autoproj_gemfile_path)
619
- File.open(autoproj_gemfile_path, 'w') do |io|
625
+ File.open(autoproj_gemfile_path, "w") do |io|
620
626
  io.write gemfile
621
627
  end
622
628
  end
623
629
 
624
630
  ENV_BUNDLE_GEMFILE_RX = /^(\s*ENV\[['"]BUNDLE_GEMFILE['"]\]\s*)(?:\|\|)?=/
625
631
 
626
-
627
632
  def find_in_clean_path(command, *additional_paths)
628
- clean_path = env_for_child['PATH'].split(File::PATH_SEPARATOR) +
629
- additional_paths
633
+ clean_path = env_for_child["PATH"].split(File::PATH_SEPARATOR) +
634
+ additional_paths
630
635
  clean_path.each do |p|
631
636
  full_path = File.join(p, command)
632
- if File.file?(full_path)
633
- return full_path
634
- end
637
+ return full_path if File.file?(full_path)
635
638
  end
636
639
  nil
637
640
  end
@@ -652,7 +655,7 @@ require 'bundler/setup'
652
655
  # actual bindir
653
656
  bindir = IO.popen(
654
657
  env_for_child,
655
- [Gem.ruby, '-e', 'puts "#{Gem.user_dir}/bin"'], # rubocop:disable Lint/InterpolationCheck
658
+ [Gem.ruby, "-e", 'puts "#{Gem.user_dir}/bin"'], # rubocop:disable Lint/InterpolationCheck
656
659
  &:read
657
660
  )
658
661
  if bindir
@@ -663,16 +666,16 @@ require 'bundler/setup'
663
666
  end
664
667
 
665
668
  def install(bundler_version: self.bundler_version)
666
- if ENV['BUNDLER_GEMFILE']
669
+ if ENV["BUNDLER_GEMFILE"]
667
670
  raise "cannot run autoproj_install or autoproj_bootstrap while "\
668
671
  "under a 'bundler exec' subcommand or having loaded an "\
669
672
  "env.sh. Open a new console and try again"
670
673
  end
671
674
 
672
- gem_program = self.class.guess_gem_program
675
+ gem_program = self.class.guess_gem_program
673
676
  puts "Detected 'gem' to be #{gem_program}"
674
- env['GEM_HOME'] = [gems_gem_home]
675
- env['GEM_PATH'] = [gems_gem_home]
677
+ env["GEM_HOME"] = [gems_gem_home]
678
+ env["GEM_PATH"] = [gems_gem_home]
676
679
 
677
680
  if (bundler = find_bundler(gem_program, version: bundler_version))
678
681
  puts "Detected bundler at #{bundler}"
@@ -682,12 +685,13 @@ require 'bundler/setup'
682
685
  exit(1) unless bundler
683
686
  end
684
687
  self.class.rewrite_shims(
685
- File.join(dot_autoproj, 'bin'),
688
+ File.join(dot_autoproj, "bin"),
686
689
  ruby_executable,
687
690
  root_dir,
688
691
  autoproj_gemfile_path,
689
- gems_gem_home)
690
- env['PATH'].unshift File.join(dot_autoproj, 'bin')
692
+ gems_gem_home
693
+ )
694
+ env["PATH"].unshift File.join(dot_autoproj, "bin")
691
695
  save_gemfile
692
696
 
693
697
  puts "Installing autoproj in #{gems_gem_home}"
@@ -695,7 +699,7 @@ require 'bundler/setup'
695
699
  end
696
700
 
697
701
  def load_config
698
- v1_config_path = File.join(root_dir, 'autoproj', 'config.yml')
702
+ v1_config_path = File.join(root_dir, "autoproj", "config.yml")
699
703
 
700
704
  config = Hash.new
701
705
  if File.file?(v1_config_path)
@@ -705,49 +709,49 @@ require 'bundler/setup'
705
709
  config.merge!(YAML.load(File.read(autoproj_config_path)) || Hash.new)
706
710
  end
707
711
 
708
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
709
- ruby_bindir = RbConfig::CONFIG['bindir']
712
+ ruby = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
713
+ ruby_bindir = RbConfig::CONFIG["bindir"]
710
714
  ruby_executable = File.join(ruby_bindir, ruby)
711
- if current = config['ruby_executable'] # When upgrading or reinstalling
715
+ if (current = config["ruby_executable"]) # When upgrading or reinstalling
712
716
  if current != ruby_executable
713
717
  raise "this workspace has already been initialized using "\
714
- "#{current}, you cannot run autoproj install with "\
715
- "#{ruby_executable}. If you know what you're doing, "\
716
- "delete the ruby_executable line in config.yml and try again"
718
+ "#{current}, you cannot run autoproj install with "\
719
+ "#{ruby_executable}. If you know what you're doing, "\
720
+ "delete the ruby_executable line in config.yml and try again"
717
721
  end
718
722
  else
719
- config['ruby_executable'] = ruby_executable
723
+ config["ruby_executable"] = ruby_executable
720
724
  end
721
725
 
722
726
  @config = config
723
- %w{gems_install_path prefer_indep_over_os_packages}.each do |flag|
727
+ %w[gems_install_path prefer_indep_over_os_packages].each do |flag|
724
728
  instance_variable_set "@#{flag}", config.fetch(flag, false)
725
729
  end
726
730
  end
727
731
 
728
732
  def save_config
729
- config['gems_install_path'] = gems_install_path
730
- config['prefer_indep_over_os_packages'] = prefer_indep_over_os_packages?
731
- File.open(autoproj_config_path, 'w') { |io| YAML.dump(config, io) }
733
+ config["gems_install_path"] = gems_install_path
734
+ config["prefer_indep_over_os_packages"] = prefer_indep_over_os_packages?
735
+ File.open(autoproj_config_path, "w") { |io| YAML.dump(config, io) }
732
736
  end
733
737
 
734
738
  def autoproj_path
735
- File.join(dot_autoproj, 'bin', 'autoproj')
739
+ File.join(dot_autoproj, "bin", "autoproj")
736
740
  end
737
741
 
738
742
  def run_autoproj(*args)
739
- system env_for_child.merge('BUNDLE_GEMFILE' => autoproj_gemfile_path),
740
- Gem.ruby, autoproj_path, *args, *@autoproj_options
743
+ system env_for_child.merge("BUNDLE_GEMFILE" => autoproj_gemfile_path),
744
+ Gem.ruby, autoproj_path, *args, *@autoproj_options
741
745
  end
742
746
 
743
747
  def v1_workspace?
744
- File.file?(File.join(root_dir, 'autoproj', 'config.yml')) &&
745
- !File.directory?(File.join(root_dir, '.autoproj'))
748
+ File.file?(File.join(root_dir, "autoproj", "config.yml")) &&
749
+ !File.directory?(File.join(root_dir, ".autoproj"))
746
750
  end
747
751
 
748
752
  def stage1
749
- if v1_workspace? && File.file?(v1_envsh = File.join(root_dir, 'env.sh'))
750
- FileUtils.cp v1_envsh, 'env.sh-autoproj-v1'
753
+ if v1_workspace? && File.file?(v1_envsh = File.join(root_dir, "env.sh"))
754
+ FileUtils.cp v1_envsh, "env.sh-autoproj-v1"
751
755
  end
752
756
  FileUtils.mkdir_p dot_autoproj
753
757
  save_config
@@ -761,27 +765,27 @@ require 'bundler/setup'
761
765
  clean_env = env_for_child
762
766
  stage2_vars = clean_env.map { |k, v| "#{k}=#{v}" }
763
767
  puts "starting the newly installed autoproj for stage2 install"
764
- if !run_autoproj('install-stage2', root_dir, *stage2_vars, *@autoproj_options)
768
+ unless run_autoproj("install-stage2", root_dir, *stage2_vars, *@autoproj_options)
765
769
  raise "failed to execute autoproj install-stage2"
766
770
  end
767
771
  end
768
772
 
769
773
  def stage2(*vars)
770
- require 'autobuild'
774
+ require "autobuild"
771
775
  puts "saving temporary env.sh and .autoproj/env.sh"
772
776
  save_env_sh(*vars)
773
777
  puts "running 'autoproj envsh' to generate a proper env.sh"
774
- if !system(Gem.ruby, autoproj_path, 'envsh', *@autoproj_options)
778
+ unless system(Gem.ruby, autoproj_path, "envsh", *@autoproj_options)
775
779
  STDERR.puts "failed to run autoproj envsh on the newly installed "\
776
- "autoproj (#{autoproj_path})"
780
+ "autoproj (#{autoproj_path})"
777
781
  exit 1
778
782
  end
779
783
  # This is really needed on an existing install to install the
780
784
  # gems that were present in the v1 layout
781
785
  puts "running 'autoproj osdeps' to re-install missing gems"
782
- if !system(Gem.ruby, autoproj_path, 'osdeps', *@autoproj_options)
786
+ unless system(Gem.ruby, autoproj_path, "osdeps", *@autoproj_options)
783
787
  STDERR.puts "failed to run autoproj osdeps on the newly installed "\
784
- "autoproj (#{autoproj_path})"
788
+ "autoproj (#{autoproj_path})"
785
789
  exit 1
786
790
  end
787
791
  end