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,4 +1,4 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  module Autoproj
3
3
  module PackageManagers
4
4
  # Package manager interface for the RubyGems system
@@ -49,23 +49,23 @@ module Autoproj
49
49
 
50
50
  config = ws.config
51
51
 
52
- env.add_path 'PATH', File.join(ws.prefix_dir, 'gems', 'bin')
53
- env.add_path 'PATH', File.join(ws.dot_autoproj_dir, 'bin')
54
- env.set 'GEM_HOME', config.gems_gem_home
55
- env.clear 'GEM_PATH'
52
+ env.add_path "PATH", File.join(ws.prefix_dir, "gems", "bin")
53
+ env.add_path "PATH", File.join(ws.dot_autoproj_dir, "bin")
54
+ env.set "GEM_HOME", config.gems_gem_home
55
+ env.clear "GEM_PATH"
56
56
  if (bundler_version = config.bundler_version)
57
- env.set 'BUNDLER_VERSION', bundler_version
57
+ env.set "BUNDLER_VERSION", bundler_version
58
58
  else
59
- env.clear 'BUNDLER_VERSION'
59
+ env.clear "BUNDLER_VERSION"
60
60
  end
61
61
 
62
- gemfile_path = File.join(ws.prefix_dir, 'gems', 'Gemfile')
63
- env.set('BUNDLE_GEMFILE', gemfile_path) if File.file?(gemfile_path)
62
+ gemfile_path = File.join(ws.prefix_dir, "gems", "Gemfile")
63
+ env.set("BUNDLE_GEMFILE", gemfile_path) if File.file?(gemfile_path)
64
64
 
65
65
  if cache_dir && File.exist?(cache_dir)
66
- vendor_dir = File.join(File.dirname(gemfile_path), 'vendor')
66
+ vendor_dir = File.join(File.dirname(gemfile_path), "vendor")
67
67
  FileUtils.mkdir_p vendor_dir
68
- bundler_cache_dir = File.join(vendor_dir, 'cache')
68
+ bundler_cache_dir = File.join(vendor_dir, "cache")
69
69
  if File.writable?(cache_dir)
70
70
  create_cache_symlink(cache_dir, bundler_cache_dir)
71
71
  else
@@ -75,16 +75,16 @@ module Autoproj
75
75
  end
76
76
  end
77
77
 
78
- Autobuild.programs['bundler'] =
79
- Autobuild.programs['bundle'] =
80
- File.join(ws.dot_autoproj_dir, 'bin', 'bundle')
78
+ Autobuild.programs["bundler"] =
79
+ Autobuild.programs["bundle"] =
80
+ File.join(ws.dot_autoproj_dir, "bin", "bundle")
81
81
 
82
- env.init_from_env 'RUBYLIB'
83
- env.inherit 'RUBYLIB'
82
+ env.init_from_env "RUBYLIB"
83
+ env.inherit "RUBYLIB"
84
84
  # Sanitize the rubylib we get from the environment by removing
85
85
  # anything that comes from Gem or Bundler
86
86
  original_rubylib =
87
- (env['RUBYLIB'] || "").split(File::PATH_SEPARATOR).find_all do |p|
87
+ (env["RUBYLIB"] || "").split(File::PATH_SEPARATOR).find_all do |p|
88
88
  !p.start_with?(Bundler.rubygems.gem_dir) &&
89
89
  Bundler.rubygems.gem_path
90
90
  .none? { |gem_p| p.start_with?(gem_p) }
@@ -97,22 +97,22 @@ module Autoproj
97
97
  #
98
98
  # This allows to use a binstub generated for one of ruby
99
99
  # interpreter version on our workspace
100
- env.system_env['RUBYLIB'] = []
101
- env.original_env['RUBYLIB'] = (original_rubylib - system_rubylib)
100
+ env.system_env["RUBYLIB"] = []
101
+ env.original_env["RUBYLIB"] = (original_rubylib - system_rubylib)
102
102
  .join(File::PATH_SEPARATOR)
103
103
  end
104
104
 
105
105
  ws.config.each_reused_autoproj_installation do |p|
106
106
  reused_w = ws.new(p)
107
- env.add_path 'PATH', File.join(reused_w.prefix_dir, 'gems', 'bin')
107
+ env.add_path "PATH", File.join(reused_w.prefix_dir, "gems", "bin")
108
108
  end
109
109
 
110
110
  prefix_gems = File.join(ws.prefix_dir, "gems")
111
111
  FileUtils.mkdir_p prefix_gems
112
- gemfile = File.join(prefix_gems, 'Gemfile')
112
+ gemfile = File.join(prefix_gems, "Gemfile")
113
113
  unless File.exist?(gemfile)
114
114
  Ops.atomic_write(gemfile) do |io|
115
- dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, 'Gemfile')
115
+ dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, "Gemfile")
116
116
  io.puts "eval_gemfile \"#{dot_autoproj_gemfile}\""
117
117
  end
118
118
  end
@@ -152,7 +152,7 @@ module Autoproj
152
152
  FileUtils.rm_f bundler_cache_dir if File.symlink?(bundler_cache_dir)
153
153
  FileUtils.mkdir_p bundler_cache_dir
154
154
 
155
- Dir.glob(File.join(cache_dir, '*.gem')) do |path_src|
155
+ Dir.glob(File.join(cache_dir, "*.gem")) do |path_src|
156
156
  path_dest = File.join(bundler_cache_dir, File.basename(path_src))
157
157
  next if File.exist?(path_dest)
158
158
 
@@ -162,7 +162,7 @@ module Autoproj
162
162
 
163
163
  # Enumerate the per-gem build configurations
164
164
  def self.per_gem_build_config(ws)
165
- ws.config.get('bundler.build', {})
165
+ ws.config.get("bundler.build", {})
166
166
  end
167
167
 
168
168
  # Add new build configuration arguments for a given gem
@@ -170,9 +170,9 @@ module Autoproj
170
170
  # This is meant to be used from the Autoproj configuration files,
171
171
  # e.g. overrides.rb or package configuration
172
172
  def self.add_build_configuration_for(gem_name, build_config, ws: Autoproj.workspace)
173
- c = ws.config.get('bundler.build', {})
173
+ c = ws.config.get("bundler.build", {})
174
174
  c[gem_name] = [c[gem_name], build_config].compact.join(" ")
175
- ws.config.set('bundler.build', c)
175
+ ws.config.set("bundler.build", c)
176
176
  end
177
177
 
178
178
  # Set the build configuration for the given gem
@@ -180,9 +180,9 @@ module Autoproj
180
180
  # This is meant to be used from the Autoproj configuration files,
181
181
  # e.g. overrides.rb or package configuration
182
182
  def self.configure_build_for(gem_name, build_config, ws: Autoproj.workspace)
183
- c = ws.config.get('bundler.build', {})
183
+ c = ws.config.get("bundler.build", {})
184
184
  c[gem_name] = build_config
185
- ws.config.set('bundler.build', c)
185
+ ws.config.set("bundler.build", c)
186
186
  end
187
187
 
188
188
  # Removes build configuration flags for the given gem
@@ -190,9 +190,9 @@ module Autoproj
190
190
  # This is meant to be used from the Autoproj configuration files,
191
191
  # e.g. overrides.rb or package configuration
192
192
  def self.remove_build_configuration_for(gem_name, ws: Autoproj.workspace)
193
- c = ws.config.get('bundler.build', {})
193
+ c = ws.config.get("bundler.build", {})
194
194
  c.delete(gem_name)
195
- ws.config.set('bundler.build', c)
195
+ ws.config.set("bundler.build", c)
196
196
  end
197
197
 
198
198
  # @api private
@@ -203,7 +203,7 @@ module Autoproj
203
203
  # should be updated
204
204
  # @return [void]
205
205
  def self.apply_build_config(ws)
206
- root_dir = File.join(ws.prefix_dir, 'gems')
206
+ root_dir = File.join(ws.prefix_dir, "gems")
207
207
  current_config_path = File.join(root_dir, ".bundle", "config")
208
208
  current_config =
209
209
  if File.file?(current_config_path)
@@ -221,10 +221,10 @@ module Autoproj
221
221
  next(line) unless (m = line.match(/BUNDLE_BUILD__(.*): "(.*)"$/))
222
222
  next unless (desired_config = build_config.delete(m[1]))
223
223
 
224
- if m[2] != desired_config
225
- "BUNDLE_BUILD__#{m[1]}: \"#{desired_config}\""
226
- else
224
+ if m[2] == desired_config
227
225
  line
226
+ else
227
+ "BUNDLE_BUILD__#{m[1]}: \"#{desired_config}\""
228
228
  end
229
229
  end.compact
230
230
 
@@ -234,7 +234,7 @@ module Autoproj
234
234
 
235
235
  if new_config != current_config
236
236
  FileUtils.mkdir_p File.dirname(current_config_path)
237
- File.open(current_config_path, 'w') do |io|
237
+ File.open(current_config_path, "w") do |io|
238
238
  io.write new_config.join
239
239
  end
240
240
  end
@@ -250,28 +250,10 @@ module Autoproj
250
250
  # @param [Array<String>] system_rubylib the rubylib entries that are
251
251
  # set by the underlying ruby interpreter itself
252
252
  def update_env_rubylib(bundle_rubylib, system_rubylib = discover_rubylib)
253
- current = (ws.env.resolved_env['RUBYLIB'] || '')
253
+ current = (ws.env.resolved_env["RUBYLIB"] || "")
254
254
  .split(File::PATH_SEPARATOR) + system_rubylib
255
255
  (bundle_rubylib - current).each do |p|
256
- ws.env.add_path('RUBYLIB', p)
257
- end
258
- end
259
-
260
- # @api private
261
- #
262
- # Parse an osdep entry into a gem name and gem version
263
- #
264
- # The 'gem' entries in the osdep files can contain a version
265
- # specification. This method parses the two parts and return them
266
- #
267
- # @param [String] entry the osdep entry
268
- # @return [(String,String),(String,nil)] the gem name, and an
269
- # optional version specification
270
- def parse_package_entry(entry)
271
- if entry =~ /^([^><=~]*)([><=~]+.*)$/
272
- [$1.strip, $2.strip]
273
- else
274
- [entry]
256
+ ws.env.add_path("RUBYLIB", p)
275
257
  end
276
258
  end
277
259
 
@@ -321,21 +303,21 @@ module Autoproj
321
303
  )
322
304
  FileUtils.rm "#{gemfile}.lock" if update && File.file?("#{gemfile}.lock")
323
305
 
324
- options << '--path' << gem_path
306
+ options << "--path" << gem_path
325
307
  options << "--shebang" << Gem.ruby
326
308
  options << "--binstubs" << binstubs if binstubs
327
309
 
328
310
  apply_build_config(ws)
329
311
 
330
312
  connections = Set.new
331
- run_bundler(ws, 'install', *options,
313
+ run_bundler(ws, "install", *options,
332
314
  bundler_version: bundler_version,
333
315
  gem_home: gem_home, gemfile: gemfile) do |line|
334
316
  case line
335
317
  when /Installing (.*)/
336
318
  Autobuild.message " bundler: installing #{$1}"
337
319
  when /Fetching.*from (.*)/
338
- host = $1.gsub(/\.+$/, '')
320
+ host = $1.gsub(/\.+$/, "")
339
321
  unless connections.include?(host)
340
322
  Autobuild.message " bundler: connected to #{host}"
341
323
  connections << host
@@ -345,41 +327,42 @@ module Autoproj
345
327
  end
346
328
 
347
329
  def self.bundle_gem_path(ws, gem_name,
348
- bundler_version: ws.config.bundler_version,
349
- gem_home: nil, gemfile: nil)
330
+ bundler_version: ws.config.bundler_version,
331
+ gem_home: nil, gemfile: nil)
350
332
  path = String.new
351
333
  run_bundler(
352
- ws, 'show', gem_name,
334
+ ws, "show", gem_name,
353
335
  bundler_version: bundler_version, gem_home: gem_home,
354
- gemfile: gemfile) { |line| path << line }
336
+ gemfile: gemfile
337
+ ) { |line| path << line }
355
338
  path.chomp
356
339
  end
357
340
 
358
341
  def self.default_bundler(ws)
359
- File.join(ws.dot_autoproj_dir, 'bin', 'bundle')
342
+ File.join(ws.dot_autoproj_dir, "bin", "bundle")
360
343
  end
361
344
 
362
345
  def self.run_bundler(ws, *commandline,
363
- bundler_version: ws.config.bundler_version,
364
- gem_home: ws.config.gems_gem_home,
365
- gemfile: default_gemfile_path(ws))
366
- bundle = Autobuild.programs['bundle'] || default_bundler(ws)
346
+ bundler_version: ws.config.bundler_version,
347
+ gem_home: ws.config.gems_gem_home,
348
+ gemfile: default_gemfile_path(ws))
349
+ bundle = Autobuild.programs["bundle"] || default_bundler(ws)
367
350
 
368
351
  Autoproj.bundler_with_unbundled_env do
369
352
  bundler_version_env =
370
353
  if bundler_version
371
- { 'BUNDLER_VERSION' => bundler_version }
354
+ { "BUNDLER_VERSION" => bundler_version }
372
355
  else
373
356
  {}
374
357
  end
375
358
  target_env = Hash[
376
- 'GEM_HOME' => gem_home,
377
- 'GEM_PATH' => nil,
378
- 'BUNDLE_GEMFILE' => gemfile,
379
- 'RUBYOPT' => nil,
380
- 'RUBYLIB' => rubylib_for_bundler,
359
+ "GEM_HOME" => gem_home,
360
+ "GEM_PATH" => nil,
361
+ "BUNDLE_GEMFILE" => gemfile,
362
+ "RUBYOPT" => nil,
363
+ "RUBYLIB" => rubylib_for_bundler,
381
364
  ].merge(bundler_version_env)
382
- ws.run('autoproj', 'osdeps',
365
+ ws.run("autoproj", "osdeps",
383
366
  bundle, *commandline,
384
367
  working_directory: File.dirname(gemfile),
385
368
  env: target_env) { |line| yield(line) if block_given? }
@@ -401,21 +384,21 @@ module Autoproj
401
384
  begin Bundler::Dsl.evaluate(gemfile, nil, [])
402
385
  rescue Exception => e
403
386
  cleaned_message = e
404
- .message
405
- .gsub(/There was an error parsing([^:]+)/,
406
- "Error in gem definitions")
407
- .gsub(/# from.*/, '')
387
+ .message
388
+ .gsub(/There was an error parsing([^:]+)/,
389
+ "Error in gem definitions")
390
+ .gsub(/# from.*/, "")
408
391
  raise ConfigError, cleaned_message
409
392
  end
410
393
  gems_remotes |= bundler_def.send(:sources).rubygems_remotes.to_set
411
394
  bundler_def.dependencies.each do |d|
412
395
  d.groups.each do |group_name|
413
- if !d.platforms.empty?
396
+ if d.platforms.empty?
397
+ dependencies[group_name][""][d.name] = d
398
+ else
414
399
  d.platforms.each do |platform_name|
415
400
  dependencies[group_name][platform_name][d.name] = d
416
401
  end
417
- else
418
- dependencies[group_name][''][d.name] = d
419
402
  end
420
403
  end
421
404
  end
@@ -424,7 +407,7 @@ module Autoproj
424
407
  contents = []
425
408
  gems_remotes.each do |g|
426
409
  g = g.to_s
427
- g = g[0..-2] if g.end_with?('/')
410
+ g = g[0..-2] if g.end_with?("/")
428
411
  contents << "source '#{g}'"
429
412
  end
430
413
  valid_keys = %w[group groups git path glob name branch ref tag
@@ -445,11 +428,11 @@ module Autoproj
445
428
  options = options.map { |k, v| "#{k}: \"#{v}\"" }
446
429
  end
447
430
  contents << [" #{platform_indent}gem \"#{d.name}\",
448
- \"#{d.requirement}\"", *options].join(', ')
431
+ \"#{d.requirement}\"", *options].join(", ")
449
432
  end
450
- contents << ' end' unless platform_name.empty?
433
+ contents << " end" unless platform_name.empty?
451
434
  end
452
- contents << 'end'
435
+ contents << "end"
453
436
  end
454
437
  contents.join("\n")
455
438
  end
@@ -457,7 +440,7 @@ module Autoproj
457
440
  def workspace_configuration_gemfiles
458
441
  gemfiles = []
459
442
  ws.manifest.each_package_set do |source|
460
- pkg_set_gemfile = File.join(source.local_dir, 'Gemfile')
443
+ pkg_set_gemfile = File.join(source.local_dir, "Gemfile")
461
444
  if source.local_dir && File.file?(pkg_set_gemfile)
462
445
  gemfiles << pkg_set_gemfile
463
446
  end
@@ -470,7 +453,58 @@ module Autoproj
470
453
  end
471
454
 
472
455
  def self.default_gemfile_path(ws)
473
- File.join(ws.prefix_dir, 'gems', 'Gemfile')
456
+ File.join(ws.prefix_dir, "gems", "Gemfile")
457
+ end
458
+
459
+ GemEntry = Struct.new :name, :version, :options do
460
+ def self.parse(object)
461
+ if object.respond_to?(:to_str)
462
+ parse_from_string(object)
463
+ elsif object.respond_to?(:to_hash)
464
+ parse_from_hash(object)
465
+ else
466
+ raise ArgumentError,
467
+ "expected #{object} to either be a string or a map"
468
+ end
469
+ end
470
+
471
+ # Parse an osdep entry string into a gem name and gem version
472
+ #
473
+ # The 'gem' entries in the osdep files can contain a version
474
+ # specification. This method parses the two parts and return them
475
+ #
476
+ # @param [String] entry the osdep entry
477
+ # @return [(String,String),(String,nil)] the gem name, and an
478
+ # optional version specification
479
+ def self.parse_from_string(entry)
480
+ if entry =~ /^([^><=~]*)([><=~]+.*)$/
481
+ GemEntry.new($1.strip, $2.strip, {})
482
+ else
483
+ GemEntry.new(entry, nil, {})
484
+ end
485
+ end
486
+
487
+ # Parse an option hash into a GemEntry
488
+ def self.parse_from_hash(hash)
489
+ hash = hash.dup
490
+ unless (name = hash.delete("name"))
491
+ raise ArgumentError,
492
+ "expected gem entry #{hash} to have at least a 'name' key"
493
+ end
494
+
495
+ version = hash.delete("version")
496
+ GemEntry.new(name, version, hash)
497
+ end
498
+
499
+ def to_gemfile_line
500
+ options_s = options.map { |k, v| "#{k}: \"#{v}\"" }.join(", ")
501
+ entries = [
502
+ "\"#{name}\"",
503
+ ("\"#{version}\"" if version),
504
+ (options_s unless options_s.empty?)
505
+ ].compact
506
+ "gem #{entries.join(', ')}"
507
+ end
474
508
  end
475
509
 
476
510
  def install(gems, filter_uptodate_packages: false, install_only: false)
@@ -487,21 +521,21 @@ module Autoproj
487
521
  backup_files(backups)
488
522
  unless File.file?("#{gemfile_path}.orig")
489
523
  Ops.atomic_write("#{gemfile_path}.orig") do |io|
490
- dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, 'Gemfile')
524
+ dot_autoproj_gemfile = File.join(ws.dot_autoproj_dir, "Gemfile")
491
525
  io.puts "eval_gemfile \"#{dot_autoproj_gemfile}\""
492
526
  end
493
527
  end
494
528
 
495
529
  gemfiles = workspace_configuration_gemfiles
496
- gemfiles << File.join(ws.dot_autoproj_dir, 'Gemfile')
530
+ gemfiles << File.join(ws.dot_autoproj_dir, "Gemfile")
497
531
 
498
532
  # Save the osdeps entries in a temporary gemfile and finally
499
533
  # merge the whole lot of it
500
- gemfile_contents = Tempfile.open 'autoproj-gemfile' do |io|
501
- gems.sort.each do |name|
502
- name, version = parse_package_entry(name)
503
- io.puts "gem \"#{name}\", \"#{version || '>= 0'}\""
504
- end
534
+ gemfile_contents = Tempfile.open "autoproj-gemfile" do |io|
535
+ gems.map { |entry| GemEntry.parse(entry) }
536
+ .sort_by(&:name)
537
+ .each { |entry| io.puts entry.to_gemfile_line }
538
+
505
539
  io.flush
506
540
  gemfiles.unshift io.path
507
541
  # The autoproj gemfile needs to be last, we really don't
@@ -520,7 +554,7 @@ module Autoproj
520
554
  end
521
555
 
522
556
  options = Array.new
523
- binstubs_path = File.join(root_dir, 'bin')
557
+ binstubs_path = File.join(root_dir, "bin")
524
558
  if updated || !install_only || !File.file?("#{gemfile_path}.lock")
525
559
  self.class.run_bundler_install(ws, gemfile_path, *options,
526
560
  binstubs: binstubs_path)
@@ -540,20 +574,21 @@ module Autoproj
540
574
  raise
541
575
  ensure
542
576
  if binstubs_path
543
- FileUtils.rm_f File.join(binstubs_path, 'bundle')
544
- FileUtils.rm_f File.join(binstubs_path, 'bundler')
577
+ FileUtils.rm_f File.join(binstubs_path, "bundle")
578
+ FileUtils.rm_f File.join(binstubs_path, "bundler")
545
579
  end
546
580
  backup_clean(backups)
547
581
  end
548
582
 
549
583
  def discover_rubylib
550
- require 'bundler'
551
- Tempfile.open 'autoproj-rubylib' do |io|
584
+ require "bundler"
585
+ Tempfile.open "autoproj-rubylib" do |io|
552
586
  result = Autoproj.bundler_unbundled_system(
553
- Hash['RUBYLIB' => nil],
554
- Autobuild.tool('ruby'), '-e', 'puts $LOAD_PATH',
587
+ Hash["RUBYLIB" => nil],
588
+ Autobuild.tool("ruby"), "-e", "puts $LOAD_PATH",
555
589
  out: io,
556
- err: '/dev/null')
590
+ err: "/dev/null"
591
+ )
557
592
  if result
558
593
  io.rewind
559
594
  io.readlines.map(&:chomp).find_all { |l| !l.empty? }
@@ -567,19 +602,20 @@ module Autoproj
567
602
  end
568
603
 
569
604
  def discover_bundle_rubylib(silent_errors: false)
570
- require 'bundler'
571
- gemfile = File.join(ws.prefix_dir, 'gems', 'Gemfile')
605
+ require "bundler"
606
+ gemfile = File.join(ws.prefix_dir, "gems", "Gemfile")
572
607
  silent_redirect = Hash.new
573
608
  silent_redirect[:err] = :close if silent_errors
574
609
  env = ws.env.resolved_env
575
- Tempfile.open 'autoproj-rubylib' do |io|
610
+ Tempfile.open "autoproj-rubylib" do |io|
576
611
  result = Autoproj.bundler_unbundled_system(
577
- Hash['GEM_HOME' => env['GEM_HOME'], 'GEM_PATH' => env['GEM_PATH'],
578
- 'BUNDLE_GEMFILE' => gemfile, 'RUBYOPT' => nil,
579
- 'RUBYLIB' => self.class.rubylib_for_bundler],
580
- Autobuild.tool('ruby'), '-rbundler/setup',
581
- '-e', 'puts $LOAD_PATH',
582
- out: io, **silent_redirect)
612
+ Hash["GEM_HOME" => env["GEM_HOME"], "GEM_PATH" => env["GEM_PATH"],
613
+ "BUNDLE_GEMFILE" => gemfile, "RUBYOPT" => nil,
614
+ "RUBYLIB" => self.class.rubylib_for_bundler],
615
+ Autobuild.tool("ruby"), "-rbundler/setup",
616
+ "-e", "puts $LOAD_PATH",
617
+ out: io, **silent_redirect
618
+ )
583
619
 
584
620
  if result
585
621
  io.rewind
@@ -20,14 +20,15 @@ module Autoproj
20
20
  def <=>(b)
21
21
  (0..2).inject(0) do |result, i|
22
22
  return result unless result == 0
23
- normalize(compare_fragments(self.split[i], b.split[i]))
23
+
24
+ normalize(compare_fragments(split[i], b.split[i]))
24
25
  end
25
26
  end
26
27
 
27
28
  def self.compare(a, b)
28
- new(a)<=>new(b)
29
+ new(a) <=> new(b)
29
30
  end
30
-
31
+
31
32
  private
32
33
 
33
34
  def normalize(value)
@@ -38,21 +39,21 @@ module Autoproj
38
39
 
39
40
  # Reference: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
40
41
  def parse_version
41
- @epoch = '0'
42
- @debian_revision = '0'
42
+ @epoch = "0"
43
+ @debian_revision = "0"
43
44
 
44
- @upstream_version = @version.split(':')
45
+ @upstream_version = @version.split(":")
45
46
  if @upstream_version.size > 1
46
47
  @epoch = @upstream_version.first
47
- @upstream_version = @upstream_version[1..-1].join(':')
48
+ @upstream_version = @upstream_version[1..-1].join(":")
48
49
  else
49
50
  @upstream_version = @upstream_version.first
50
51
  end
51
52
 
52
- @upstream_version = @upstream_version.split('-')
53
+ @upstream_version = @upstream_version.split("-")
53
54
  if @upstream_version.size > 1
54
55
  @debian_revision = @upstream_version.last
55
- @upstream_version = @upstream_version[0..-2].join('-')
56
+ @upstream_version = @upstream_version[0..-2].join("-")
56
57
  else
57
58
  @upstream_version = @upstream_version.first
58
59
  end
@@ -68,15 +69,15 @@ module Autoproj
68
69
 
69
70
  def order(c)
70
71
  if digit?(c)
71
- return 0
72
+ 0
72
73
  elsif alpha?(c)
73
- return c.ord
74
- elsif c == '~'
75
- return -1
74
+ c.ord
75
+ elsif c == "~"
76
+ -1
76
77
  elsif c
77
- return c.ord + 256
78
+ c.ord + 256
78
79
  else
79
- return 0
80
+ 0
80
81
  end
81
82
  end
82
83
 
@@ -89,13 +90,14 @@ module Autoproj
89
90
  while i != a.size && j != b.size && (!digit?(a[i]) || !digit?(b[j]))
90
91
  vc = order(a[i])
91
92
  rc = order(b[j])
92
- return vc-rc if vc != rc
93
+ return vc - rc if vc != rc
94
+
93
95
  i += 1
94
96
  j += 1
95
97
  end
96
98
 
97
- i += 1 while a[i] == '0'
98
- j += 1 while b[j] == '0'
99
+ i += 1 while a[i] == "0"
100
+ j += 1 while b[j] == "0"
99
101
  while digit?(a[i]) && digit?(b[j])
100
102
  first_diff = a[i].ord - b[j].ord if first_diff == 0
101
103
  i += 1
@@ -110,12 +112,14 @@ module Autoproj
110
112
  return 0 if i == a.size && j == b.size
111
113
 
112
114
  if i == a.size
113
- return 1 if b[j] == '~'
115
+ return 1 if b[j] == "~"
116
+
114
117
  return -1
115
118
  end
116
119
  if j == b.size
117
- return -1 if a[i] == '~'
118
- return 1
120
+ return -1 if a[i] == "~"
121
+
122
+ 1
119
123
  end
120
124
  end
121
125
  end
@@ -5,10 +5,9 @@ module Autoproj
5
5
  class EmergeManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{emerge},
9
- %w{emerge --noreplace})
8
+ %w[emerge],
9
+ %w[emerge --noreplace])
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
-