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,9 +1,11 @@
1
- require 'yaml'
2
- require 'csv'
3
- require 'utilrb/kernel/options'
4
- require 'set'
1
+ require "yaml"
2
+ require "csv"
3
+ require "utilrb/kernel/options"
4
+ require "set"
5
5
 
6
- require 'win32/dir' if RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
6
+ if RbConfig::CONFIG["host_os"] =~ %r{(msdos|mswin|djgpp|mingw|[Ww]indows)}
7
+ require "win32/dir"
8
+ end
7
9
 
8
10
  module Autoproj
9
11
  # The Manifest class represents the information included in the main
@@ -60,6 +62,11 @@ module Autoproj
60
62
  YAML.safe_load(File.read(file)) || {}
61
63
  end
62
64
 
65
+ if data["layout"]&.member?(nil)
66
+ Autoproj.warn "There is an empty entry in your layout in #{file}. All empty entries are ignored."
67
+ data["layout"] = data["layout"].compact
68
+ end
69
+
63
70
  @file = file
64
71
  initialize_from_hash(data)
65
72
  end
@@ -69,22 +76,23 @@ module Autoproj
69
76
  # Initialize the manifest from a hash, as loaded from a manifest file
70
77
  def initialize_from_hash(data)
71
78
  @data = data
72
- @ignored_packages |= (data['ignored_packages'] || Set.new).to_set
73
- @ignored_packages |= (data['ignore_packages'] || Set.new).to_set
79
+ @ignored_packages |= (data["ignored_packages"] || Set.new).to_set
80
+ @ignored_packages |= (data["ignore_packages"] || Set.new).to_set
74
81
  invalidate_ignored_package_names
75
- @manifest_exclusions |= (data['exclude_packages'] || Set.new).to_set
82
+ @manifest_exclusions |= (data["exclude_packages"] || Set.new).to_set
76
83
 
77
84
  normalized_layout = Hash.new
78
85
  compute_normalized_layout(
79
86
  normalized_layout,
80
- '/',
81
- data['layout'] || Hash.new)
87
+ "/",
88
+ data["layout"] || Hash.new
89
+ )
82
90
  @normalized_layout = normalized_layout
83
- @has_layout = !!data['layout']
91
+ @has_layout = !!data["layout"]
84
92
 
85
- if data['constants']
93
+ if data["constants"]
86
94
  @constant_definitions =
87
- Autoproj.resolve_constant_definitions(data['constants'])
95
+ Autoproj.resolve_constant_definitions(data["constants"])
88
96
  end
89
97
  end
90
98
 
@@ -110,7 +118,7 @@ module Autoproj
110
118
  def add_package_to_layout(package)
111
119
  package_name = validate_package_name_argument(package)
112
120
  @has_layout = true
113
- normalized_layout[package_name] = '/'
121
+ normalized_layout[package_name] = "/"
114
122
  end
115
123
 
116
124
  # Add a package into the layout
@@ -123,7 +131,7 @@ module Autoproj
123
131
  def add_metapackage_to_layout(metapackage)
124
132
  validate_metapackage_in_self(metapackage)
125
133
  @has_layout = true
126
- normalized_layout[metapackage.name] = '/'
134
+ normalized_layout[metapackage.name] = "/"
127
135
  end
128
136
 
129
137
  # Add a constant definition, used when resolving $CONSTANT in loaded
@@ -152,10 +160,12 @@ module Autoproj
152
160
  # is not available on the current operating system, or simply return it
153
161
  #
154
162
  # @return [Boolean]
155
- def accept_unavailable_osdeps?; !!@accept_unavailable_osdeps end
163
+ def accept_unavailable_osdeps?
164
+ !!@accept_unavailable_osdeps
165
+ end
156
166
 
157
167
  # Sets {#accept_unavailable_osdeps?}
158
- def accept_unavailable_osdeps=(flag); @accept_unavailable_osdeps = flag end
168
+ attr_writer :accept_unavailable_osdeps
159
169
 
160
170
  attr_reader :constant_definitions
161
171
 
@@ -235,6 +245,7 @@ module Autoproj
235
245
  if require_existing && !has_package?(package)
236
246
  raise PackageNotFound, "no package named #{package} in #{self}"
237
247
  end
248
+
238
249
  package
239
250
  end
240
251
  end
@@ -270,9 +281,7 @@ module Autoproj
270
281
  #
271
282
  # Do not use directly, use {#ignored?} instead
272
283
  def cache_ignored_package_names
273
- if @ignored_package_names
274
- return @ignored_package_names
275
- end
284
+ return @ignored_package_names if @ignored_package_names
276
285
 
277
286
  @ignored_package_names = each_package_definition.find_all do |pkg|
278
287
  ignored_packages.any? do |l|
@@ -293,7 +302,8 @@ module Autoproj
293
302
  #
294
303
  # @yieldparam [Autobuild::Package]
295
304
  def each_ignored_package
296
- return enum_for(__method__) if !block_given?
305
+ return enum_for(__method__) unless block_given?
306
+
297
307
  cache_ignored_package_names.each do |pkg_name|
298
308
  yield(find_autobuild_package(pkg_name))
299
309
  end
@@ -315,7 +325,7 @@ module Autoproj
315
325
 
316
326
  if !explicitely_selected_in_layout?(package_name) && excluded_in_manifest?(package_name)
317
327
  true
318
- elsif automatic_exclusions.any? { |pkg_name, | pkg_name == package_name }
328
+ elsif automatic_exclusions.any? { |pkg_name,| pkg_name == package_name }
319
329
  true
320
330
  else
321
331
  false
@@ -324,7 +334,8 @@ module Autoproj
324
334
 
325
335
  # Enumerates the package names of all ignored packages
326
336
  def each_excluded_package
327
- return enum_for(__method__) if !block_given?
337
+ return enum_for(__method__) unless block_given?
338
+
328
339
  each_autobuild_package do |pkg|
329
340
  yield(pkg) if excluded?(pkg.name)
330
341
  end
@@ -353,10 +364,14 @@ module Autoproj
353
364
  # Exclude +package_name+ from the build. +reason+ is a string describing
354
365
  # why the package is to be excluded.
355
366
  def exclude_package(package_name, reason)
356
- package = validate_package_name_argument(package_name, require_existing: false)
357
- if meta = find_metapackage(package)
367
+ package = validate_package_name_argument(
368
+ package_name, require_existing: false
369
+ )
370
+ if (meta = find_metapackage(package))
358
371
  meta.each_package do |pkg|
359
- automatic_exclusions[pkg.name] = "#{meta.name} is an excluded metapackage, and it includes #{pkg.name}: #{reason}"
372
+ automatic_exclusions[pkg.name] =
373
+ "#{meta.name} is an excluded metapackage, "\
374
+ "and it includes #{pkg.name}: #{reason}"
360
375
  end
361
376
  else
362
377
  automatic_exclusions[package] = reason
@@ -383,11 +398,11 @@ module Autoproj
383
398
  # disabled on this particular operating system.
384
399
  def exclusion_reason(package_name)
385
400
  package_name = validate_package_name_argument(package_name)
386
- if message = automatic_exclusions[package_name]
401
+ if (message = automatic_exclusions[package_name])
387
402
  return message
388
403
  end
389
404
 
390
- if !explicitely_selected_in_layout?(package_name)
405
+ unless explicitely_selected_in_layout?(package_name)
391
406
  manifest_exclusions.each do |matcher|
392
407
  if (pkg_set = metapackages[matcher]) && pkg_set.include?(package_name)
393
408
  return "#{pkg_set.name} is a metapackage listed in the exclude_packages section of the manifest, and it includes #{package_name}"
@@ -416,12 +431,10 @@ module Autoproj
416
431
 
417
432
  # Like #each_package_set, but filters out local package sets
418
433
  def each_remote_package_set
419
- return enum_for(__method__) if !block_given?
434
+ return enum_for(__method__) unless block_given?
420
435
 
421
436
  each_package_set do |pkg_set|
422
- if !pkg_set.local?
423
- yield(pkg_set)
424
- end
437
+ yield(pkg_set) unless pkg_set.local?
425
438
  end
426
439
  end
427
440
 
@@ -461,9 +474,7 @@ module Autoproj
461
474
  def register_package(package, block = nil, package_set = main_package_set, file = nil)
462
475
  invalidate_ignored_package_names
463
476
  pkg = PackageDefinition.new(package, package_set, file)
464
- if block
465
- pkg.add_setup_block(block)
466
- end
477
+ pkg.add_setup_block(block) if block
467
478
  @packages[package.name] = pkg
468
479
  metapackage pkg.package_set.name, pkg.autobuild
469
480
  metapackage "#{pkg.package_set.name}.all", pkg.autobuild
@@ -502,11 +513,11 @@ module Autoproj
502
513
  #
503
514
  # Unlike {#find_package_definition}, raise if the package does not exist
504
515
  def package_definition_by_name(name)
505
- if pkg = find_package_definition(name)
506
- pkg
507
- else
516
+ unless (pkg = find_package_definition(name))
508
517
  raise ArgumentError, "no package defined named '#{name}'"
509
518
  end
519
+
520
+ pkg
510
521
  end
511
522
 
512
523
  # The autobuild description of a package by its name
@@ -514,16 +525,15 @@ module Autoproj
514
525
  # @param [String,#name] name the package name
515
526
  # @return [Autobuild::Package,nil]
516
527
  def find_autobuild_package(name)
517
- if pkg = find_package_definition(name)
518
- pkg.autobuild
519
- end
528
+ find_package_definition(name)&.autobuild
520
529
  end
521
530
 
522
531
  # Lists all defined packages
523
532
  #
524
533
  # @yieldparam [PackageDefinition] pkg
525
534
  def each_package_definition(&block)
526
- return enum_for(__method__) if !block_given?
535
+ return enum_for(__method__) unless block_given?
536
+
527
537
  packages.each_value(&block)
528
538
  end
529
539
 
@@ -531,7 +541,8 @@ module Autoproj
531
541
  #
532
542
  # @yieldparam [Autobuild::Package] pkg
533
543
  def each_autobuild_package
534
- return enum_for(__method__) if !block_given?
544
+ return enum_for(__method__) unless block_given?
545
+
535
546
  each_package_definition { |pkg| yield(pkg.autobuild) }
536
547
  end
537
548
 
@@ -549,28 +560,24 @@ module Autoproj
549
560
  end
550
561
  package_name = validate_package_name_argument(package, require_existing: require_existing)
551
562
  package_set = _package_set || package_set || package.package_set
552
- mainline = if mainline == true
553
- package_set
554
- else mainline
555
- end
563
+ mainline = package_set if mainline == true
556
564
 
557
565
  # package_name is already validated, do not re-validate
558
566
  vcs = package_set.importer_definition_for(package_name, require_existing: false)
559
567
 
560
568
  package_sets = each_package_set.to_a.dup
561
569
  index = package_sets.find_index(package_set)
562
- if !index
570
+ unless index
563
571
  raise RuntimeError, "found inconsistency: package #{package_name} is not in a package set of #{self}"
564
572
  end
565
573
 
566
- if package_sets[0, index + 1].include?(mainline)
567
- return vcs
568
- end
574
+ return vcs if package_sets[0, index + 1].include?(mainline)
569
575
 
570
576
  # Then apply the overrides
571
577
  package_sets[(index + 1)..-1].inject(vcs) do |updated_vcs, pkg_set|
572
578
  updated_vcs = pkg_set.overrides_for(package_name, updated_vcs, require_existing: false)
573
579
  return updated_vcs if pkg_set == mainline
580
+
574
581
  updated_vcs
575
582
  end
576
583
  end
@@ -596,7 +603,8 @@ module Autoproj
596
603
  package_mainline =
597
604
  if mainline == true
598
605
  pkg.package_set
599
- else mainline
606
+ else
607
+ mainline
600
608
  end
601
609
  vcs = importer_definition_for(pkg, mainline: package_mainline)
602
610
 
@@ -636,11 +644,11 @@ module Autoproj
636
644
  # @return [PackageSet] the package set
637
645
  # @raise [ArgumentError] if none exists with that name
638
646
  def package_set(name)
639
- if set = find_package_set(name)
640
- set
641
- else
647
+ unless (set = find_package_set(name))
642
648
  raise ArgumentError, "no package set called #{name} exists"
643
649
  end
650
+
651
+ set
644
652
  end
645
653
 
646
654
  # The root package set, which represents the workspace itself
@@ -665,25 +673,24 @@ module Autoproj
665
673
  # fallback defined with {#add_osdeps_overrides}. If true, it will
666
674
  # return such a package as an osdep.
667
675
  def resolve_package_name(name, include_unavailable: false)
668
- if pkg_set = find_metapackage(name)
669
- pkg_names = pkg_set.each_package.map(&:name)
670
- else
671
- pkg_names = [name.to_str]
672
- end
676
+ pkg_names =
677
+ if (pkg_set = find_metapackage(name))
678
+ pkg_set.each_package.map(&:name)
679
+ else
680
+ [name.to_str]
681
+ end
673
682
 
674
683
  result = []
675
684
  pkg_names.each do |pkg|
676
- begin
677
- result.concat(resolve_single_package_name(pkg))
678
- rescue PackageUnavailable => e
679
- if include_unavailable
680
- result.concat([[:osdeps, pkg]])
681
- else
682
- raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
683
- end
684
- rescue PackageNotFound => e
685
+ result.concat(resolve_single_package_name(pkg))
686
+ rescue PackageUnavailable => e
687
+ if include_unavailable
688
+ result.concat([[:osdeps, pkg]])
689
+ else
685
690
  raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
686
691
  end
692
+ rescue PackageNotFound => e
693
+ raise e, "cannot resolve #{pkg}: #{e}", e.backtrace
687
694
  end
688
695
  result
689
696
  end
@@ -720,11 +727,12 @@ module Autoproj
720
727
  # @raise PackageNotFound if the given package name cannot be resolved
721
728
  # into a package
722
729
  def resolve_package_name_as_source_package(name)
723
- if pkg = find_autobuild_package(name)
724
- return [[:package, pkg.name]]
725
- else
726
- raise PackageNotFound, "cannot resolve #{name}: it is neither a package nor an osdep"
730
+ unless (pkg = find_autobuild_package(name))
731
+ raise PackageNotFound,
732
+ "cannot resolve #{name}: it is neither a package nor an osdep"
727
733
  end
734
+
735
+ [[:package, pkg.name]]
728
736
  end
729
737
 
730
738
  # @api private
@@ -743,7 +751,7 @@ module Autoproj
743
751
  # fallback defined with {#add_osdeps_overrides}.
744
752
  # If true, it will return it as an osdep.
745
753
  def resolve_package_name_as_osdep(name)
746
- osdeps_availability = os_package_resolver.availability_of(name)
754
+ osdeps_availability = os_package_resolver.availability_of(name)
747
755
  if osdeps_availability == OSPackageResolver::NO_PACKAGE
748
756
  raise PackageNotFound, "#{name} is not an osdep"
749
757
  end
@@ -755,13 +763,13 @@ module Autoproj
755
763
  (osdeps_availability == OSPackageResolver::IGNORE)
756
764
  osdeps_overrides = self.osdeps_overrides[name]
757
765
  if osdeps_overrides && (!osdeps_available || osdeps_overrides[:force])
758
- return osdeps_overrides[:packages].inject([]) do |result, src_pkg_name|
766
+ osdeps_overrides[:packages].inject([]) do |result, src_pkg_name|
759
767
  result.concat(resolve_package_name_as_source_package(src_pkg_name))
760
768
  end.uniq
761
769
  elsif !osdeps_available && (pkg = find_autobuild_package(name))
762
- return [[:package, pkg.name]]
770
+ [[:package, pkg.name]]
763
771
  elsif osdeps_available || accept_unavailable_osdeps?
764
- return [[:osdeps, name]]
772
+ [[:osdeps, name]]
765
773
  elsif osdeps_availability == OSPackageResolver::WRONG_OS
766
774
  raise PackageUnavailable, "#{name} is an osdep, but it is not available for this operating system (#{os_package_resolver.operating_system})"
767
775
  elsif osdeps_availability == OSPackageResolver::UNKNOWN_OS
@@ -797,9 +805,9 @@ module Autoproj
797
805
  packages.each do |arg|
798
806
  if !arg.respond_to?(:to_str)
799
807
  meta.add(arg)
800
- elsif pkg = find_autobuild_package(arg)
808
+ elsif (pkg = find_autobuild_package(arg))
801
809
  meta.add(pkg)
802
- elsif pkg_set = find_metapackage(arg)
810
+ elsif (pkg_set = find_metapackage(arg))
803
811
  pkg_set.each_package do |pkg_in_set|
804
812
  meta.add(pkg_in_set)
805
813
  end
@@ -810,9 +818,7 @@ module Autoproj
810
818
  end
811
819
  end
812
820
 
813
- if block
814
- meta.instance_eval(&block)
815
- end
821
+ meta.instance_eval(&block) if block
816
822
  meta
817
823
  end
818
824
 
@@ -829,19 +835,23 @@ module Autoproj
829
835
  # @return [PackageSelection]
830
836
  def layout_packages(validate = true)
831
837
  result = PackageSelection.new
832
- Autoproj.in_file(self.file) do
838
+ Autoproj.in_file(file) do
833
839
  normalized_layout.each_key do |pkg_or_set|
834
- begin
835
- weak = if meta = metapackages[pkg_or_set]
836
- meta.weak_dependencies?
837
- end
838
-
839
- resolve_package_name(pkg_or_set).each do |pkg_type, pkg_name|
840
- result.select(pkg_or_set, pkg_name, osdep: (pkg_type == :osdeps), weak: weak)
840
+ weak =
841
+ if (meta = metapackages[pkg_or_set])
842
+ meta.weak_dependencies?
841
843
  end
842
- rescue PackageNotFound => e
843
- raise e, "#{pkg_or_set}, which is selected in the layout, is unknown: #{e.message}", e.backtrace
844
+
845
+ resolve_package_name(pkg_or_set).each do |pkg_type, pkg_name|
846
+ result.select(
847
+ pkg_or_set, pkg_name,
848
+ osdep: (pkg_type == :osdeps),
849
+ weak: weak
850
+ )
844
851
  end
852
+ rescue PackageNotFound => e
853
+ raise e, "#{pkg_or_set}, which is selected in the layout, "\
854
+ "is unknown: #{e.message}", e.backtrace
845
855
  end
846
856
  end
847
857
 
@@ -932,6 +942,7 @@ module Autoproj
932
942
  all_package_names.each do |pkg_name|
933
943
  package_type, package_name = resolve_single_package_name(pkg_name).first
934
944
  next if excluded?(package_name) || ignored?(package_name)
945
+
935
946
  result.select(package_name, package_name, osdep: (package_type == :osdeps))
936
947
  end
937
948
  result
@@ -963,20 +974,18 @@ module Autoproj
963
974
  package_name = validate_package_name_argument(package_name)
964
975
 
965
976
  matches = [package_name]
966
- if source_package = find_package_definition(package_name)
977
+ if (source_package = find_package_definition(package_name))
967
978
  each_metapackage do |meta|
968
- if meta.include?(source_package)
969
- matches << meta.name
970
- end
979
+ matches << meta.name if meta.include?(source_package)
971
980
  end
972
981
  end
973
982
 
974
983
  matches.each do |name|
975
- if place = normalized_layout[name]
984
+ if (place = normalized_layout[name])
976
985
  return place
977
986
  end
978
987
  end
979
- '/'
988
+ "/"
980
989
  end
981
990
 
982
991
  class NoPackageXML < ConfigError; end
@@ -988,35 +997,38 @@ module Autoproj
988
997
  def load_package_manifest(pkg)
989
998
  if pkg.respond_to?(:to_str)
990
999
  pkg_definition = find_package_definition(pkg)
991
- if !pkg_definition
1000
+ unless pkg_definition
992
1001
  raise ArgumentError, "#{pkg} is not a known package in #{self}"
993
1002
  end
1003
+
994
1004
  pkg = pkg_definition
995
1005
  end
996
- package, package_set = pkg.autobuild, pkg.package_set
1006
+ package = pkg.autobuild
1007
+ package_set = pkg.package_set
997
1008
 
998
1009
  # Look for the package's manifest.xml, but fallback to a manifest in
999
1010
  # the package set if present
1000
1011
  if package.use_package_xml? && package.checked_out?
1001
1012
  manifest_path = File.join(package.srcdir, "package.xml")
1002
1013
  raise NoPackageXML.new(package.srcdir), "#{package.name} from "\
1003
- "#{package_set.name} has use_package_xml set, but the package has "\
1004
- "no package.xml file" unless File.file?(manifest_path)
1014
+ "#{package_set.name} has use_package_xml set, but the package has "\
1015
+ "no package.xml file" unless File.file?(manifest_path)
1005
1016
 
1006
1017
  manifest = PackageManifest.load(package, manifest_path,
1007
- ros_manifest: true)
1018
+ ros_manifest: true)
1008
1019
  else
1009
1020
  manifest_paths = [File.join(package.srcdir, "manifest.xml")]
1010
1021
  if package_set.local_dir
1011
1022
  manifest_paths << File.join(
1012
- package_set.local_dir, "manifests", package.name + ".xml")
1023
+ package_set.local_dir, "manifests", "#{package.name}.xml"
1024
+ )
1013
1025
  end
1014
1026
  manifest_path = manifest_paths.find do |path|
1015
1027
  File.file?(path)
1016
1028
  end
1017
1029
  if manifest_path
1018
1030
  manifest = PackageManifest.load(package, manifest_path,
1019
- ros_manifest: false)
1031
+ ros_manifest: false)
1020
1032
  end
1021
1033
  end
1022
1034
 
@@ -1067,9 +1079,7 @@ module Autoproj
1067
1079
  # The :force option allows to force the usage of the source package(s),
1068
1080
  # regardless of the availability of the osdeps package.
1069
1081
  def add_osdeps_overrides(osdeps_name, package: osdeps_name, packages: [], force: false)
1070
- if package
1071
- packages << package
1072
- end
1082
+ packages << package if package
1073
1083
  packages.each { |pkg_name| resolve_package_name(pkg_name) }
1074
1084
  @osdeps_overrides[osdeps_name.to_s] = Hash[packages: packages, force: force]
1075
1085
  end
@@ -1086,7 +1096,8 @@ module Autoproj
1086
1096
  #
1087
1097
  # Helper for {#expand_package_selection}
1088
1098
  def update_selection(selection, user_selection_string, name, weak)
1089
- source_packages, osdeps = Array.new, Array.new
1099
+ source_packages = Array.new
1100
+ osdeps = Array.new
1090
1101
  resolve_package_name(name).each do |type, resolved_name|
1091
1102
  if type == :package
1092
1103
  source_packages << resolved_name
@@ -1094,10 +1105,10 @@ module Autoproj
1094
1105
  osdeps << resolved_name
1095
1106
  end
1096
1107
  end
1097
- if !source_packages.empty?
1108
+ unless source_packages.empty?
1098
1109
  selection.select(user_selection_string, source_packages, osdep: false, weak: weak)
1099
1110
  end
1100
- if !osdeps.empty?
1111
+ unless osdeps.empty?
1101
1112
  selection.select(user_selection_string, osdeps, osdep: true, weak: weak)
1102
1113
  end
1103
1114
  end
@@ -1113,7 +1124,7 @@ module Autoproj
1113
1124
  result = PackageSelection.new
1114
1125
 
1115
1126
  all_selected_packages = self.all_selected_packages.to_set
1116
- all_source_package_names = self.all_package_names
1127
+ all_source_package_names = all_package_names
1117
1128
  all_osdeps_package_names = os_package_resolver.all_package_names
1118
1129
  selection.each do |sel|
1119
1130
  match_pkg_name = Regexp.new(Regexp.quote(sel))
@@ -1145,25 +1156,21 @@ module Autoproj
1145
1156
  all_matches.partition { |_, exact_match| exact_match }
1146
1157
  selected_partial_matches, not_selected_partial_matches =
1147
1158
  partial_matches.partition { |pkg_name, _| all_selected_packages.include?(pkg_name) }
1148
- if result.has_match_for?(sel)
1149
- not_selected_partial_matches.clear
1150
- end
1159
+ not_selected_partial_matches.clear if result.has_match_for?(sel)
1151
1160
 
1152
- matches = [exact_matches, selected_partial_matches, not_selected_partial_matches].
1153
- find { |m| !m.empty? }
1154
- if matches
1155
- matches.each do |pkg_name, _|
1156
- update_selection(result, sel, pkg_name, true)
1157
- end
1161
+ matches =
1162
+ [exact_matches, selected_partial_matches, not_selected_partial_matches]
1163
+ .find { |m| !m.empty? }
1164
+
1165
+ matches&.each do |pkg_name, _|
1166
+ update_selection(result, sel, pkg_name, true)
1158
1167
  end
1159
1168
  end
1160
1169
 
1161
- if filter
1162
- result.filter_excluded_and_ignored_packages(self)
1163
- end
1170
+ result.filter_excluded_and_ignored_packages(self) if filter
1164
1171
 
1165
1172
  nonresolved = selection - result.matches.keys
1166
- return result, nonresolved
1173
+ [result, nonresolved]
1167
1174
  end
1168
1175
 
1169
1176
  attr_reader :moved_packages
@@ -1206,9 +1213,7 @@ module Autoproj
1206
1213
  # Declare that we should reuse the autoproj installation present at the
1207
1214
  # given path
1208
1215
  def reuse(workspace_root)
1209
- if reused_installations.any? { |mnf| mnf.path == workspace_root }
1210
- return
1211
- end
1216
+ return if reused_installations.any? { |mnf| mnf.path == workspace_root }
1212
1217
 
1213
1218
  manifest = InstallationManifest.from_workspace_root(workspace_root)
1214
1219
  manifest.load
@@ -1221,14 +1226,16 @@ module Autoproj
1221
1226
 
1222
1227
  def self.manifest
1223
1228
  Autoproj.warn_deprecated(
1224
- __method__, "use workspace.manifest instead")
1229
+ __method__, "use workspace.manifest instead"
1230
+ )
1225
1231
 
1226
1232
  workspace.manifest
1227
1233
  end
1228
1234
 
1229
1235
  def self.osdeps
1230
1236
  Autoproj.warn_deprecated(
1231
- __method__, "use workspace.os_package_resolver or workspace.os_package_installer instead")
1237
+ __method__, "use workspace.os_package_resolver or workspace.os_package_installer instead"
1238
+ )
1232
1239
 
1233
1240
  workspace.os_package_resolver
1234
1241
  end
@@ -43,9 +43,7 @@ module Autoproj
43
43
 
44
44
  # Remove a package from this metapackage
45
45
  def remove(pkg)
46
- if pkg.respond_to?(:name)
47
- pkg = pkg.name
48
- end
46
+ pkg = pkg.name if pkg.respond_to?(:name)
49
47
  packages_by_name.delete(pkg)
50
48
  end
51
49
 
@@ -60,9 +58,7 @@ module Autoproj
60
58
  #
61
59
  # @param [String,#name] pkg the package or package name
62
60
  def include?(pkg)
63
- if !pkg.respond_to?(:to_str)
64
- pkg = pkg.name
65
- end
61
+ pkg = pkg.name unless pkg.respond_to?(:to_str)
66
62
  packages_by_name.has_key?(pkg)
67
63
  end
68
64
 
@@ -2,9 +2,9 @@ module Autoproj
2
2
  module Ops
3
3
  # Shamelessly stolen from ActiveSupport
4
4
  def self.atomic_write(file_name, temp_dir = Dir.tmpdir)
5
- require 'tempfile' unless defined?(Tempfile)
6
- require 'fileutils' unless defined?(FileUtils)
7
-
5
+ require "tempfile" unless defined?(Tempfile)
6
+ require "fileutils" unless defined?(FileUtils)
7
+
8
8
  temp_file = Tempfile.new(File.basename(file_name), temp_dir)
9
9
  yield temp_file
10
10
  temp_file.flush
@@ -12,15 +12,16 @@ module Autoproj
12
12
  rescue NotImplementedError
13
13
  end
14
14
  temp_file.close
15
-
15
+
16
16
  begin
17
17
  # Get original file permissions
18
18
  old_stat = File.stat(file_name)
19
19
  rescue Errno::ENOENT
20
20
  # No old permissions, write a temp file to determine the defaults
21
21
  check_name = File.join(
22
- File.dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}")
23
- File.open(check_name, "w") { }
22
+ File.dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"
23
+ )
24
+ File.open(check_name, "w") {}
24
25
  old_stat = File.stat(check_name)
25
26
  File.unlink(check_name)
26
27
  end