autoproj 2.10.2 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -232,54 +232,54 @@ def parse_options(args = ARGV)
232
232
  opt.on '--debug', 'Run in debug mode' do
233
233
  @autoproj_options << '--debug'
234
234
  end
235
- opt.on '--gem-source=URL', String, "use this source for RubyGems "\
236
- "instead of rubygems.org" do |url|
235
+ opt.on '--gem-source=URL', String, 'use this source for RubyGems '\
236
+ 'instead of rubygems.org' do |url|
237
237
  @gem_source = url
238
238
  end
239
- opt.on '--gems-path=PATH', "install gems under this path instead "\
240
- "of ~/.autoproj/gems" do |path|
239
+ opt.on '--gems-path=PATH', 'install gems under this path instead '\
240
+ 'of ~/.autoproj/gems' do |path|
241
241
  self.gems_install_path = path
242
242
  end
243
243
  opt.on '--public-gems', "install gems in the default gem location" do
244
244
  self.install_gems_in_gem_user_dir
245
245
  end
246
- opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided "\
247
- "string as a version constraint for autoproj' do |version|
246
+ opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided '\
247
+ 'string as a version constraint for autoproj' do |version|
248
248
  if @gemfile
249
249
  raise "cannot give both --version and --gemfile"
250
250
  end
251
251
  @gemfile = default_gemfile_contents(version)
252
252
  end
253
- opt.on '--gemfile=PATH', String, 'use the given Gemfile to install "\
254
- "autoproj instead of the default' do |path|
253
+ opt.on '--gemfile=PATH', String, 'use the given Gemfile to install '\
254
+ 'autoproj instead of the default' do |path|
255
255
  if @gemfile
256
256
  raise "cannot give both --version and --gemfile"
257
257
  end
258
258
  @gemfile = File.read(path)
259
259
  end
260
- opt.on '--seed-config=PATH', String, 'path to a seed file that "\
261
- "should be used to initialize the configuration' do |path|
260
+ opt.on '--seed-config=PATH', String, 'path to a seed file that '\
261
+ 'should be used to initialize the configuration' do |path|
262
262
  @config.merge!(YAML.load(File.read(path)))
263
263
  end
264
- opt.on '--prefer-os-independent-packages', 'prefer OS-independent "\
265
- "packages (such as a RubyGem) over their OS-packaged equivalent "\
266
- "(e.g. the thor gem vs. the ruby-thor debian package)' do
264
+ opt.on '--prefer-os-independent-packages', 'prefer OS-independent '\
265
+ 'packages (such as a RubyGem) over their OS-packaged equivalent '\
266
+ '(e.g. the thor gem vs. the ruby-thor debian package)' do
267
267
  @prefer_indep_over_os_packages = true
268
268
  end
269
- opt.on '--[no-]color', 'do not use colored output (enabled by "\
270
- "default if the terminal supports it)' do |color|
269
+ opt.on '--[no-]color', 'do not use colored output (enabled by '\
270
+ 'default if the terminal supports it)' do |color|
271
271
  if color then @autoproj_options << "--color"
272
272
  else @autoproj_options << '--no-color'
273
273
  end
274
274
  end
275
- opt.on '--[no-]progress', 'do not use progress output (enabled by "\
276
- "default if the terminal supports it)' do |progress|
275
+ opt.on '--[no-]progress', 'do not use progress output (enabled by '\
276
+ 'default if the terminal supports it)' do |progress|
277
277
  if progress then @autoproj_options << "--progress"
278
278
  else @autoproj_options << '--no-progress'
279
279
  end
280
280
  end
281
- opt.on '--[no-]interactive', 'if non-interactive, use default "\
282
- "answer for questions' do |flag|
281
+ opt.on '--[no-]interactive', 'if non-interactive, use default '\
282
+ 'answer for questions' do |flag|
283
283
  if flag then @autoproj_options << "--interactive"
284
284
  else @autoproj_options << "--no-interactive"
285
285
  end
@@ -19,7 +19,9 @@ class PackageDefinition
19
19
  #
20
20
  # If the package is set up, its importer as well as all target
21
21
  # directories are properly set, and all {user_blocks} have been called.
22
- def setup?; !!@setup end
22
+ def setup?
23
+ @setup
24
+ end
23
25
 
24
26
  # Sets the {setup?} flag
25
27
  attr_writer :setup
@@ -29,10 +31,11 @@ def setup?; !!@setup end
29
31
  attr_accessor :vcs
30
32
 
31
33
  def initialize(autobuild, package_set, file)
32
- @autobuild, @package_set, @file =
33
- autobuild, package_set, file
34
+ @autobuild = autobuild
35
+ @package_set = package_set
36
+ @file = file
34
37
  @user_blocks = []
35
- @modes = ['import', 'build']
38
+ @modes = %w[import build]
36
39
  @setup = false
37
40
  @vcs = VCSDefinition.none
38
41
  end
@@ -44,9 +47,8 @@ def initialize(autobuild, package_set, file)
44
47
  #
45
48
  # @return [Array<String>]
46
49
  def modes
47
- @modes + autobuild.utilities.values.
48
- find_all { |u| u.enabled? }.
49
- map(&:name)
50
+ @modes + autobuild.utilities
51
+ .values.find_all(&:enabled?).map(&:name)
50
52
  end
51
53
 
52
54
  # The package name
@@ -65,9 +67,7 @@ def name
65
67
  # @see {user_blocks}
66
68
  def add_setup_block(block)
67
69
  user_blocks << block
68
- if setup?
69
- block.call(autobuild)
70
- end
70
+ block.call(autobuild) if setup?
71
71
  end
72
72
 
73
73
  # Whether this package is already checked out
@@ -79,5 +79,24 @@ def checked_out?
79
79
  def depends_on(pkg)
80
80
  autobuild.depends_on(pkg.autobuild)
81
81
  end
82
+
83
+ def apply_dependencies_from_manifest
84
+ manifest = autobuild.description
85
+ manifest.each_dependency(modes) do |name, is_optional|
86
+ begin
87
+ if is_optional
88
+ autobuild.optional_dependency name
89
+ else
90
+ autobuild.depends_on name
91
+ end
92
+ rescue ConfigError => e
93
+ raise ConfigError.new(manifest.path),
94
+ "manifest #{manifest.path} of #{self.name} from "\
95
+ "#{package_set.name} lists '#{name}' as dependency, "\
96
+ 'but it is neither a normal package nor an osdeps '\
97
+ "package. osdeps reports: #{e.message}", e.backtrace
98
+ end
99
+ end
100
+ end
82
101
  end
83
102
  end
@@ -47,12 +47,12 @@ def initialize_environment
47
47
  env.clear 'GEM_PATH'
48
48
 
49
49
  gemfile_path = File.join(ws.prefix_dir, 'gems', 'Gemfile')
50
- if File.file?(gemfile_path)
51
- env.set('BUNDLE_GEMFILE', gemfile_path)
52
- end
50
+ env.set('BUNDLE_GEMFILE', gemfile_path) if File.file?(gemfile_path)
53
51
 
54
- Autobuild.programs['bundler'] = File.join(ws.dot_autoproj_dir, 'bin', 'bundle')
55
- Autobuild.programs['bundle'] = File.join(ws.dot_autoproj_dir, 'bin', 'bundle')
52
+ Autobuild.programs['bundler'] = File.join(ws.dot_autoproj_dir,
53
+ 'bin', 'bundle')
54
+ Autobuild.programs['bundle'] = File.join(ws.dot_autoproj_dir,
55
+ 'bin', 'bundle')
56
56
 
57
57
  env.init_from_env 'RUBYLIB'
58
58
  env.inherit 'RUBYLIB'
@@ -61,17 +61,19 @@ def initialize_environment
61
61
  original_rubylib =
62
62
  (env['RUBYLIB'] || "").split(File::PATH_SEPARATOR).find_all do |p|
63
63
  !p.start_with?(Bundler.rubygems.gem_dir) &&
64
- !Bundler.rubygems.gem_path.any? { |gem_p| p.start_with?(p) }
64
+ Bundler.rubygems.gem_path
65
+ .none? { |gem_p| p.start_with?(gem_p) }
65
66
  end
66
67
  # And discover the system's rubylib
67
- if system_rubylib = discover_rubylib
68
+ if (system_rubylib = discover_rubylib)
68
69
  # Do not explicitely add the system rubylib to the
69
70
  # environment, the interpreter will do it for us.
70
71
  #
71
72
  # This allows to use a binstub generated for one of ruby
72
73
  # interpreter version on our workspace
73
74
  env.system_env['RUBYLIB'] = []
74
- env.original_env['RUBYLIB'] = (original_rubylib - system_rubylib).join(File::PATH_SEPARATOR)
75
+ env.original_env['RUBYLIB'] = (original_rubylib - system_rubylib)
76
+ .join(File::PATH_SEPARATOR)
75
77
  end
76
78
 
77
79
  ws.config.each_reused_autoproj_installation do |p|
@@ -82,17 +84,98 @@ def initialize_environment
82
84
  prefix_gems = File.join(ws.prefix_dir, "gems")
83
85
  FileUtils.mkdir_p prefix_gems
84
86
  gemfile = File.join(prefix_gems, 'Gemfile')
85
- if !File.exist?(gemfile)
87
+ unless File.exist?(gemfile)
86
88
  Ops.atomic_write(gemfile) do |io|
87
- io.puts "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'Gemfile')}\""
89
+ dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, 'Gemfile')
90
+ io.puts "eval_gemfile \"#{dot_autoproj_gemfile}\""
88
91
  end
89
92
  end
90
93
 
91
- if bundle_rubylib = discover_bundle_rubylib(silent_errors: true)
94
+ if (bundle_rubylib = discover_bundle_rubylib(silent_errors: true))
92
95
  update_env_rubylib(bundle_rubylib, system_rubylib)
93
96
  end
94
97
  end
95
98
 
99
+ # Enumerate the per-gem build configurations
100
+ def self.per_gem_build_config(ws)
101
+ ws.config.get('bundler.build', {})
102
+ end
103
+
104
+ # Add new build configuration arguments for a given gem
105
+ #
106
+ # This is meant to be used from the Autoproj configuration files,
107
+ # e.g. overrides.rb or package configuration
108
+ def self.add_build_configuration_for(gem_name, build_config, ws: Autoproj.workspace)
109
+ c = ws.config.get('bundler.build', {})
110
+ c[gem_name] = [c[gem_name], build_config].compact.join(" ")
111
+ ws.config.set('bundler.build', c)
112
+ end
113
+
114
+ # Set the build configuration for the given gem
115
+ #
116
+ # This is meant to be used from the Autoproj configuration files,
117
+ # e.g. overrides.rb or package configuration
118
+ def self.configure_build_for(gem_name, build_config, ws: Autoproj.workspace)
119
+ c = ws.config.get('bundler.build', {})
120
+ c[gem_name] = build_config
121
+ ws.config.set('bundler.build', c)
122
+ end
123
+
124
+ # Removes build configuration flags for the given gem
125
+ #
126
+ # This is meant to be used from the Autoproj configuration files,
127
+ # e.g. overrides.rb or package configuration
128
+ def self.remove_build_configuration_for(gem_name, ws: Autoproj.workspace)
129
+ c = ws.config.get('bundler.build', {})
130
+ c.delete(gem_name)
131
+ ws.config.set('bundler.build', c)
132
+ end
133
+
134
+ # @api private
135
+ #
136
+ # Apply configured per-gem build configuration options
137
+ #
138
+ # @param [Workspace] ws the workspace whose bundler configuration
139
+ # should be updated
140
+ # @return [void]
141
+ def self.apply_build_config(ws)
142
+ root_dir = File.join(ws.prefix_dir, 'gems')
143
+ current_config_path = File.join(root_dir, ".bundle", "config")
144
+ current_config =
145
+ if File.file?(current_config_path)
146
+ File.readlines(current_config_path)
147
+ else
148
+ []
149
+ end
150
+
151
+ build_config = {}
152
+ per_gem_build_config(ws).each do |name, conf|
153
+ build_config[name.upcase] = conf
154
+ end
155
+
156
+ new_config = current_config.map do |line|
157
+ next(line) unless (m = line.match(/BUNDLE_BUILD__(.*): "(.*)"$/))
158
+ next unless (desired_config = build_config.delete(m[1]))
159
+
160
+ if m[2] != desired_config
161
+ "BUNDLE_BUILD__#{m[1]}: \"#{desired_config}\""
162
+ else
163
+ line
164
+ end
165
+ end.compact
166
+
167
+ build_config.each do |name, config|
168
+ new_config << "BUNDLE_BUILD__#{name}: \"#{config}\""
169
+ end
170
+
171
+ if new_config != current_config
172
+ FileUtils.mkdir_p File.dirname(current_config_path)
173
+ File.open(current_config_path, 'w') do |io|
174
+ io.write new_config.join
175
+ end
176
+ end
177
+ end
178
+
96
179
  # @api private
97
180
  #
98
181
  # Update RUBYLIB to add the gems that are part of the bundler
@@ -103,7 +186,8 @@ def initialize_environment
103
186
  # @param [Array<String>] system_rubylib the rubylib entries that are
104
187
  # set by the underlying ruby interpreter itself
105
188
  def update_env_rubylib(bundle_rubylib, system_rubylib = discover_rubylib)
106
- current = (ws.env.resolved_env['RUBYLIB'] || '').split(File::PATH_SEPARATOR) + system_rubylib
189
+ current = (ws.env.resolved_env['RUBYLIB'] || '')
190
+ .split(File::PATH_SEPARATOR) + system_rubylib
107
191
  (bundle_rubylib - current).each do |p|
108
192
  ws.env.add_path('RUBYLIB', p)
109
193
  end
@@ -128,7 +212,7 @@ def parse_package_entry(entry)
128
212
  end
129
213
 
130
214
  class NotCleanState < RuntimeError; end
131
-
215
+
132
216
  # @api private
133
217
  #
134
218
  # Create backup files matching a certain file mapping
@@ -138,9 +222,7 @@ class NotCleanState < RuntimeError; end
138
222
  # file might not exist.
139
223
  def backup_files(mapping)
140
224
  mapping.each do |file, backup_file|
141
- if File.file?(file)
142
- FileUtils.cp file, backup_file
143
- end
225
+ FileUtils.cp file, backup_file if File.file?(file)
144
226
  end
145
227
  end
146
228
 
@@ -151,9 +233,7 @@ def backup_files(mapping)
151
233
  # @param (see #backup_file)
152
234
  def backup_restore(mapping)
153
235
  mapping.each do |file, backup_file|
154
- if File.file?(backup_file)
155
- FileUtils.cp backup_file, file
156
- end
236
+ FileUtils.cp backup_file, file if File.file?(backup_file)
157
237
  end
158
238
  end
159
239
 
@@ -163,34 +243,32 @@ def backup_restore(mapping)
163
243
  #
164
244
  # @param (see #backup_file)
165
245
  def backup_clean(mapping)
166
- mapping.each do |file, backup_file|
167
- if File.file?(backup_file)
168
- FileUtils.rm backup_file
169
- end
246
+ mapping.each do |_file, backup_file|
247
+ FileUtils.rm backup_file if File.file?(backup_file)
170
248
  end
171
249
  end
172
250
 
173
- def self.run_bundler_install(ws, gemfile, *options, update: true, binstubs: nil,
174
- gem_home: ws.config.gems_gem_home,
175
- gem_path: ws.config.gems_install_path)
176
- if update && File.file?("#{gemfile}.lock")
177
- FileUtils.rm "#{gemfile}.lock"
178
- end
251
+ def self.run_bundler_install(ws, gemfile, *options,
252
+ update: true, binstubs: nil,
253
+ gem_home: ws.config.gems_gem_home,
254
+ gem_path: ws.config.gems_install_path)
255
+ FileUtils.rm "#{gemfile}.lock" if update && File.file?("#{gemfile}.lock")
179
256
 
180
257
  options << '--path' << gem_path
181
258
  options << "--shebang" << Gem.ruby
182
- if binstubs
183
- options << "--binstubs" << binstubs
184
- end
259
+ options << "--binstubs" << binstubs if binstubs
260
+
261
+ apply_build_config(ws)
185
262
 
186
263
  connections = Set.new
187
- run_bundler(ws, 'install', *options, gem_home: gem_home, gemfile: gemfile) do |line|
264
+ run_bundler(ws, 'install', *options,
265
+ gem_home: gem_home, gemfile: gemfile) do |line|
188
266
  case line
189
267
  when /Installing (.*)/
190
268
  Autobuild.message " bundler: installing #{$1}"
191
269
  when /Fetching.*from (.*)/
192
270
  host = $1.gsub(/\.+$/, '')
193
- if !connections.include?(host)
271
+ unless connections.include?(host)
194
272
  Autobuild.message " bundler: connected to #{host}"
195
273
  connections << host
196
274
  end
@@ -200,13 +278,20 @@ def self.run_bundler_install(ws, gemfile, *options, update: true, binstubs: nil,
200
278
 
201
279
  def self.bundle_gem_path(ws, gem_name, gem_home: nil, gemfile: nil)
202
280
  path = String.new
203
- PackageManagers::BundlerManager.run_bundler(ws, 'show', gem_name, gem_home: gem_home, gemfile: gemfile) do |line|
204
- path << line
205
- end
281
+ PackageManagers::BundlerManager.run_bundler(
282
+ ws, 'show', gem_name,
283
+ gem_home: gem_home,
284
+ gemfile: gemfile) { |line| path << line }
206
285
  path.chomp
207
286
  end
208
287
 
288
+ def self.default_bundler(ws)
289
+ File.join(ws.dot_autoproj_dir, 'bin', 'bundle')
290
+ end
291
+
209
292
  def self.run_bundler(ws, *commandline, gem_home: nil, gemfile: nil)
293
+ bundle = Autobuild.programs['bundle'] || default_bundler(ws)
294
+
210
295
  Bundler.with_clean_env do
211
296
  target_env = Hash[
212
297
  'GEM_HOME' => gem_home,
@@ -215,15 +300,14 @@ def self.run_bundler(ws, *commandline, gem_home: nil, gemfile: nil)
215
300
  'RUBYOPT' => nil,
216
301
  'RUBYLIB' => rubylib_for_bundler
217
302
  ]
218
- ws.run 'autoproj', 'osdeps',
219
- Autobuild.tool('bundle'), *commandline,
220
- working_directory: File.dirname(gemfile), env: target_env do |line|
221
- yield(line) if block_given?
222
- end
303
+ ws.run('autoproj', 'osdeps',
304
+ bundle, *commandline,
305
+ working_directory: File.dirname(gemfile),
306
+ env: target_env) { |line| yield(line) if block_given? }
223
307
  end
224
308
  end
225
309
 
226
- # Parse the contents of a gemfile into a set of
310
+ # Parse the contents of a gemfile into a set of
227
311
  def merge_gemfiles(*path, unlock: [])
228
312
  gems_remotes = Set.new
229
313
  dependencies = Hash.new do |h, k|
@@ -237,9 +321,11 @@ def merge_gemfiles(*path, unlock: [])
237
321
  bundler_def =
238
322
  begin Bundler::Dsl.evaluate(gemfile, nil, [])
239
323
  rescue Exception => e
240
- cleaned_message = e.message.
241
- gsub(/There was an error parsing([^:]+)/, "Error in gem definitions").
242
- gsub(/# from.*/, '')
324
+ cleaned_message = e
325
+ .message
326
+ .gsub(/There was an error parsing([^:]+)/,
327
+ "Error in gem definitions")
328
+ .gsub(/# from.*/, '')
243
329
  raise ConfigError, cleaned_message
244
330
  end
245
331
  gems_remotes |= bundler_def.send(:sources).rubygems_remotes.to_set
@@ -259,17 +345,17 @@ def merge_gemfiles(*path, unlock: [])
259
345
  contents = []
260
346
  gems_remotes.each do |g|
261
347
  g = g.to_s
262
- if g.end_with?('/')
263
- g = g[0..-2]
264
- end
265
- contents << "source '#{g.to_s}'"
348
+ g = g[0..-2] if g.end_with?('/')
349
+ contents << "source '#{g}'"
266
350
  end
267
- valid_keys = %w{group groups git path glob name branch ref tag require submodules platform platforms type source install_if}
351
+ valid_keys = %w[group groups git path glob name branch ref tag
352
+ require submodules platform platforms type
353
+ source install_if]
268
354
  dependencies.each do |group_name, by_platform|
269
355
  contents << "group :#{group_name} do"
270
356
  by_platform.each do |platform_name, deps|
271
357
  deps = deps.values.sort_by(&:name)
272
- if !platform_name.empty?
358
+ unless platform_name.empty?
273
359
  contents << " platform :#{platform_name} do"
274
360
  platform_indent = " "
275
361
  end
@@ -279,13 +365,12 @@ def merge_gemfiles(*path, unlock: [])
279
365
  options.delete_if { |k, _| !valid_keys.include?(k) }
280
366
  options = options.map { |k, v| "#{k}: \"#{v}\"" }
281
367
  end
282
- contents << [" #{platform_indent}gem \"#{d.name}\", \"#{d.requirement}\"", *options].join(", ")
283
- end
284
- if !platform_name.empty?
285
- contents << " end"
368
+ contents << [" #{platform_indent}gem \"#{d.name}\",
369
+ \"#{d.requirement}\"", *options].join(', ')
286
370
  end
371
+ contents << ' end' unless platform_name.empty?
287
372
  end
288
- contents << "end"
373
+ contents << 'end'
289
374
  end
290
375
  contents.join("\n")
291
376
  end
@@ -293,13 +378,14 @@ def merge_gemfiles(*path, unlock: [])
293
378
  def workspace_configuration_gemfiles
294
379
  gemfiles = []
295
380
  ws.manifest.each_package_set do |source|
296
- if source.local_dir && File.file?(pkg_set_gemfile = File.join(source.local_dir, 'Gemfile'))
381
+ pkg_set_gemfile = File.join(source.local_dir, 'Gemfile')
382
+ if source.local_dir && File.file?(pkg_set_gemfile)
297
383
  gemfiles << pkg_set_gemfile
298
384
  end
299
385
  end
300
386
  # In addition, look into overrides.d
301
- Dir.glob(File.join(ws.overrides_dir, "*.gemfile")) do |overrides_gemfile_path|
302
- gemfiles << overrides_gemfile_path
387
+ Dir.glob(File.join(ws.overrides_dir, "*.gemfile")) do |overrides_gemfile|
388
+ gemfiles << overrides_gemfile
303
389
  end
304
390
  gemfiles
305
391
  end
@@ -316,9 +402,10 @@ def install(gems, filter_uptodate_packages: false, install_only: false)
316
402
  # Back up the existing gemfile, we'll restore it if something is
317
403
  # wrong to avoid leaving bundler in an inconsistent state
318
404
  backup_files(backups)
319
- if !File.file?("#{gemfile_path}.orig")
405
+ unless File.file?("#{gemfile_path}.orig")
320
406
  Ops.atomic_write("#{gemfile_path}.orig") do |io|
321
- io.puts "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'Gemfile')}\""
407
+ dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, 'Gemfile')
408
+ io.puts "eval_gemfile \"#{dot_autoproj_gemfile}\""
322
409
  end
323
410
  end
324
411
 
@@ -330,7 +417,7 @@ def install(gems, filter_uptodate_packages: false, install_only: false)
330
417
  gemfile_contents = Tempfile.open 'autoproj-gemfile' do |io|
331
418
  gems.sort.each do |name|
332
419
  name, version = parse_package_entry(name)
333
- io.puts "gem \"#{name}\", \"#{version || ">= 0"}\""
420
+ io.puts "gem \"#{name}\", \"#{version || '>= 0'}\""
334
421
  end
335
422
  io.flush
336
423
  gemfiles.unshift io.path
@@ -340,7 +427,9 @@ def install(gems, filter_uptodate_packages: false, install_only: false)
340
427
  end
341
428
 
342
429
  FileUtils.mkdir_p root_dir
343
- if updated = (!File.exist?(gemfile_path) || File.read(gemfile_path) != gemfile_contents)
430
+ updated = (!File.exist?(gemfile_path) ||
431
+ File.read(gemfile_path) != gemfile_contents)
432
+ if updated
344
433
  Ops.atomic_write(gemfile_path) do |io|
345
434
  io.puts "ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)"
346
435
  io.puts gemfile_contents
@@ -350,24 +439,25 @@ def install(gems, filter_uptodate_packages: false, install_only: false)
350
439
  options = Array.new
351
440
  binstubs_path = File.join(root_dir, 'bin')
352
441
  if updated || !install_only || !File.file?("#{gemfile_path}.lock")
353
- self.class.run_bundler_install ws, gemfile_path, *options,
354
- binstubs: binstubs_path
442
+ self.class.run_bundler_install(ws, gemfile_path, *options,
443
+ binstubs: binstubs_path)
355
444
  end
356
445
 
357
- if bundle_rubylib = discover_bundle_rubylib
446
+ if (bundle_rubylib = discover_bundle_rubylib)
358
447
  update_env_rubylib(bundle_rubylib)
359
448
  else
360
- raise NotCleanState, "bundler executed successfully, but the result was not in a clean state"
449
+ raise NotCleanState, "bundler executed successfully, "\
450
+ "but the result was not in a clean state"
361
451
  end
362
-
363
452
  rescue Exception
364
- Autoproj.warn "saved the new Gemfile in #{gemfile_path}.FAILED and restored the last Gemfile version"
453
+ Autoproj.warn "saved the new Gemfile in #{gemfile_path}.FAILED "\
454
+ "and restored the last Gemfile version"
365
455
  FileUtils.cp gemfile_path, "#{gemfile_path}.FAILED"
366
456
  backup_restore(backups)
367
457
  raise
368
458
  ensure
369
459
  if binstubs_path
370
- FileUtils.rm_f File.join(binstubs_path, 'bundle')
460
+ FileUtils.rm_f File.join(binstubs_path, 'bundle')
371
461
  FileUtils.rm_f File.join(binstubs_path, 'bundler')
372
462
  end
373
463
  backup_clean(backups)
@@ -383,7 +473,7 @@ def discover_rubylib
383
473
  err: '/dev/null')
384
474
  if result
385
475
  io.rewind
386
- io.readlines.map { |l| l.chomp }.find_all { |l| !l.empty? }
476
+ io.readlines.map(&:chomp).find_all { |l| !l.empty? }
387
477
  end
388
478
  end
389
479
  end
@@ -397,25 +487,23 @@ def discover_bundle_rubylib(silent_errors: false)
397
487
  require 'bundler'
398
488
  gemfile = File.join(ws.prefix_dir, 'gems', 'Gemfile')
399
489
  silent_redirect = Hash.new
400
- if silent_errors
401
- silent_redirect[:err] = :close
402
- end
490
+ silent_redirect[:err] = :close if silent_errors
403
491
  env = ws.env.resolved_env
404
492
  Tempfile.open 'autoproj-rubylib' do |io|
405
493
  result = Bundler.clean_system(
406
494
  Hash['GEM_HOME' => env['GEM_HOME'], 'GEM_PATH' => env['GEM_PATH'],
407
495
  'BUNDLE_GEMFILE' => gemfile, 'RUBYOPT' => nil,
408
496
  'RUBYLIB' => self.class.rubylib_for_bundler],
409
- Autobuild.tool('ruby'), '-rbundler/setup', '-e', 'puts $LOAD_PATH',
497
+ Autobuild.tool('ruby'), '-rbundler/setup',
498
+ '-e', 'puts $LOAD_PATH',
410
499
  out: io, **silent_redirect)
411
-
500
+
412
501
  if result
413
502
  io.rewind
414
- io.readlines.map { |l| l.chomp }.find_all { |l| !l.empty? }
503
+ io.readlines.map(&:chomp).find_all { |l| !l.empty? }
415
504
  end
416
505
  end
417
506
  end
418
507
  end
419
508
  end
420
509
  end
421
-