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
@@ -4,8 +4,8 @@ module Autoproj
4
4
  class YumManager < ShellScriptManager
5
5
  def initialize(ws)
6
6
  super(ws, true,
7
- %w{yum install},
8
- %w{yum install -y})
7
+ %w[yum install],
8
+ %w[yum install -y])
9
9
  end
10
10
 
11
11
  def filter_uptodate_packages(packages)
@@ -17,15 +17,17 @@ module Autoproj
17
17
  line = line.strip
18
18
  if line =~ /package (.*) is not installed/
19
19
  package_name = $1
20
- if !packages.include?(package_name) # something is wrong, fallback to installing everything
20
+ unless packages.include?(package_name) # something is wrong, fallback to installing everything
21
21
  return packages
22
22
  end
23
+
23
24
  new_packages << package_name
24
- else
25
+ else
25
26
  package_name = line.strip
26
- if !packages.include?(package_name) # something is wrong, fallback to installing everything
27
+ unless packages.include?(package_name) # something is wrong, fallback to installing everything
27
28
  return packages
28
29
  end
30
+
29
31
  installed_packages << package_name
30
32
  end
31
33
  end
@@ -33,21 +35,17 @@ module Autoproj
33
35
  end
34
36
 
35
37
  def install(packages, filter_uptodate_packages: false, install_only: false)
36
- if filter_uptodate_packages
37
- packages = filter_uptodate_packages(packages)
38
- end
38
+ packages = filter_uptodate_packages(packages) if filter_uptodate_packages
39
39
 
40
40
  patterns, packages = packages.partition { |pkg| pkg =~ /^@/ }
41
41
  patterns = patterns.map { |str| str[1..-1] }
42
42
  result = false
43
- if !patterns.empty?
43
+ unless patterns.empty?
44
44
  result |= super(patterns,
45
- auto_install_cmd: %w{yum groupinstall -y},
46
- user_install_cmd: %w{yum groupinstall})
47
- end
48
- if !packages.empty?
49
- result |= super(packages)
45
+ auto_install_cmd: %w[yum groupinstall -y],
46
+ user_install_cmd: %w[yum groupinstall])
50
47
  end
48
+ result |= super(packages) unless packages.empty?
51
49
  if result
52
50
  # Invalidate caching of installed packages, as we just
53
51
  # installed new packages !
@@ -57,4 +55,3 @@ module Autoproj
57
55
  end
58
56
  end
59
57
  end
60
-
@@ -1,21 +1,21 @@
1
1
  module Autoproj
2
2
  module PackageManagers
3
- #Package manger for OpenSuse and Suse (untested)
3
+ # Package manger for OpenSuse and Suse (untested)
4
4
  class ZypperManager < ShellScriptManager
5
5
  def initialize(ws)
6
6
  super(ws, true,
7
- %w{zypper install},
8
- %w{zypper -n install})
7
+ %w[zypper install],
8
+ %w[zypper -n install])
9
9
  end
10
10
 
11
11
  def filter_uptodate_packages(packages)
12
12
  `LANG=C rpm -q --whatprovides '#{packages.join("' '")}'`
13
13
  has_all_pkgs = $?.success?
14
14
 
15
- if !has_all_pkgs
16
- return packages # let zypper filter, we need root now anyways
17
- else
18
- return []
15
+ if has_all_pkgs
16
+ []
17
+ else
18
+ packages # let zypper filter, we need root now anyways
19
19
  end
20
20
  end
21
21
 
@@ -27,14 +27,12 @@ module Autoproj
27
27
  patterns, packages = packages.partition { |pkg| pkg =~ /^@/ }
28
28
  patterns = patterns.map { |str| str[1..-1] }
29
29
  result = false
30
- if !patterns.empty?
30
+ unless patterns.empty?
31
31
  result |= super(patterns,
32
- auto_install_cmd: %w{zypper --non-interactive install --type pattern},
33
- user_install_cmd: %w{zypper install --type pattern})
34
- end
35
- if !packages.empty?
36
- result |= super(packages)
32
+ auto_install_cmd: %w[zypper --non-interactive install --type pattern],
33
+ user_install_cmd: %w[zypper install --type pattern])
37
34
  end
35
+ result |= super(packages) unless packages.empty?
38
36
  if result
39
37
  # Invalidate caching of installed packages, as we just
40
38
  # installed new packages !
@@ -44,4 +42,3 @@ module Autoproj
44
42
  end
45
43
  end
46
44
  end
47
-
@@ -31,13 +31,13 @@ module Autoproj
31
31
  # @return [PackageManifest]
32
32
  # @see load
33
33
  def self.parse(package, contents,
34
- path: '<loaded from string>', loader_class: Loader)
34
+ path: "<loaded from string>", loader_class: Loader)
35
35
  manifest = PackageManifest.new(package, path)
36
36
  loader = loader_class.new(path, manifest)
37
37
  begin
38
38
  REXML::Document.parse_stream(contents, loader)
39
39
  rescue REXML::ParseException => e
40
- raise Autobuild::PackageException.new(package.name, 'prepare'),
40
+ raise Autobuild::PackageException.new(package.name, "prepare"),
41
41
  "invalid #{file}: #{e.message}"
42
42
  end
43
43
  manifest
@@ -185,52 +185,53 @@ module Autoproj
185
185
  end
186
186
 
187
187
  def parse_depend_tag(tag_name, attributes, modes: [], optional: false)
188
- package = attributes['package'] || attributes['name']
188
+ package = attributes["package"] || attributes["name"]
189
189
  unless package
190
190
  raise InvalidPackageManifest,
191
191
  "found '#{tag_name}' tag in #{path} "\
192
192
  "without a 'package' attribute"
193
193
  end
194
194
 
195
- if (tag_modes = attributes['modes'])
196
- modes += tag_modes.split(',')
195
+ if (tag_modes = attributes["modes"])
196
+ modes += tag_modes.split(",")
197
197
  end
198
198
 
199
199
  manifest.add_dependency(
200
200
  package,
201
- optional: optional || (attributes['optional'] == '1'),
202
- modes: modes)
201
+ optional: optional || (attributes["optional"] == "1"),
202
+ modes: modes
203
+ )
203
204
  end
204
205
 
205
206
  def parse_contact_field(text)
206
- text.strip.split(',').map do |str|
207
- name, email = str.split('/').map(&:strip)
207
+ text.strip.split(",").map do |str|
208
+ name, email = str.split("/").map(&:strip)
208
209
  email = nil if email&.empty?
209
210
  ContactInfo.new(name, email)
210
211
  end
211
212
  end
212
213
 
213
- TEXT_FIELDS = Set['url', 'license', 'version', 'description']
214
- AUTHOR_FIELDS = Set['author', 'maintainer', 'rock_maintainer']
214
+ TEXT_FIELDS = Set["url", "license", "version", "description"]
215
+ AUTHOR_FIELDS = Set["author", "maintainer", "rock_maintainer"]
215
216
 
216
217
  def toplevel_tag_start(name, attributes)
217
- if name == 'depend'
218
+ if name == "depend"
218
219
  parse_depend_tag(name, attributes)
219
- elsif name == 'depend_optional'
220
+ elsif name == "depend_optional"
220
221
  parse_depend_tag(name, attributes, optional: true)
221
- elsif name == 'rosdep'
222
+ elsif name == "rosdep"
222
223
  parse_depend_tag(name, attributes)
223
224
  elsif name =~ /^(\w+)_depend$/
224
225
  parse_depend_tag(name, attributes, modes: [$1])
225
- elsif name == 'description'
226
- if (brief = attributes['brief'])
226
+ elsif name == "description"
227
+ if (brief = attributes["brief"])
227
228
  manifest.brief_description = brief
228
229
  end
229
- @tag_text = ''
230
+ @tag_text = ""
230
231
  elsif TEXT_FIELDS.include?(name) || AUTHOR_FIELDS.include?(name)
231
- @tag_text = ''
232
- elsif name == 'tags'
233
- @tag_text = ''
232
+ @tag_text = ""
233
+ elsif name == "tags"
234
+ @tag_text = ""
234
235
  else
235
236
  @tag_text = nil
236
237
  end
@@ -242,8 +243,8 @@ module Autoproj
242
243
  elsif TEXT_FIELDS.include?(name)
243
244
  field = @tag_text.strip
244
245
  manifest.send("#{name}=", field) unless field.empty?
245
- elsif name == 'tags'
246
- manifest.tags.concat(@tag_text.strip.split(',').map(&:strip))
246
+ elsif name == "tags"
247
+ manifest.tags.concat(@tag_text.strip.split(",").map(&:strip))
247
248
  end
248
249
  @tag_text = nil
249
250
  end
@@ -261,12 +262,12 @@ module Autoproj
261
262
 
262
263
  def toplevel_tag_start(name, attributes)
263
264
  if DEPEND_TAGS.include?(name)
264
- @tag_text = ''
265
+ @tag_text = ""
265
266
  elsif TEXT_FIELDS.include?(name)
266
- @tag_text = ''
267
+ @tag_text = ""
267
268
  elsif AUTHOR_FIELDS.include?(name)
268
- @author_email = attributes['email']
269
- @tag_text = ''
269
+ @author_email = attributes["email"]
270
+ @tag_text = ""
270
271
  else
271
272
  @tag_text = nil
272
273
  end
@@ -1,222 +1,222 @@
1
1
  module Autoproj
2
- # Class holding information about which packages have been selected, and
3
- # why. It is used to decide whether some non-availability of packages
4
- # are errors or simply warnings (i.e. if the user really wants a given
5
- # package, or merely might be adding it by accident)
6
- class PackageSelection
7
- include Enumerable
8
-
9
- # The set of matches, i.e. a mapping from a user-provided string to
10
- # the set of packages it selected
11
- attr_reader :matches
12
- # The set of selected packages, as a hash of the package name to the
13
- # set of user-provided strings that caused that package to be
14
- # selected
15
- attr_reader :selection
16
- # A flag that tells #filter_excluded_and_ignored_packages whether
17
- # the a given package selection is weak or not.
18
- #
19
- # If true, a selection that have some excluded packages will not
20
- # generate an error. Otherwise (the default), an error is generated
21
- attr_reader :weak_dependencies
22
- # After a call to #filter_excluded_and_ignored_packages, this
23
- # contains the set of package exclusions that have been ignored
24
- # because the corresponding metapackage has a weak dependency policy
25
- attr_reader :exclusions
26
- # After a call to #filter_excluded_and_ignored_packages, this
27
- # contains the set of package ignores that have been ignored because
28
- # the corresponding metapackage has a weak dependency policy
29
- attr_reader :ignores
30
- # The set of source packages that have been selected
31
- attr_reader :source_packages
32
- # The set of osdeps that have been selected
33
- attr_reader :osdeps
34
-
35
- def initialize
36
- @selection = Hash.new { |h, k| h[k] = Set.new }
37
- @matches = Hash.new { |h, k| h[k] = Set.new }
38
- @weak_dependencies = Hash.new
39
- @ignores = Hash.new { |h, k| h[k] = Set.new }
40
- @exclusions = Hash.new { |h, k| h[k] = Set.new }
41
- @source_packages = Set.new
42
- @osdeps = Set.new
43
- end
2
+ # Class holding information about which packages have been selected, and
3
+ # why. It is used to decide whether some non-availability of packages
4
+ # are errors or simply warnings (i.e. if the user really wants a given
5
+ # package, or merely might be adding it by accident)
6
+ class PackageSelection
7
+ include Enumerable
8
+
9
+ # The set of matches, i.e. a mapping from a user-provided string to
10
+ # the set of packages it selected
11
+ attr_reader :matches
12
+ # The set of selected packages, as a hash of the package name to the
13
+ # set of user-provided strings that caused that package to be
14
+ # selected
15
+ attr_reader :selection
16
+ # A flag that tells #filter_excluded_and_ignored_packages whether
17
+ # the a given package selection is weak or not.
18
+ #
19
+ # If true, a selection that have some excluded packages will not
20
+ # generate an error. Otherwise (the default), an error is generated
21
+ attr_reader :weak_dependencies
22
+ # After a call to #filter_excluded_and_ignored_packages, this
23
+ # contains the set of package exclusions that have been ignored
24
+ # because the corresponding metapackage has a weak dependency policy
25
+ attr_reader :exclusions
26
+ # After a call to #filter_excluded_and_ignored_packages, this
27
+ # contains the set of package ignores that have been ignored because
28
+ # the corresponding metapackage has a weak dependency policy
29
+ attr_reader :ignores
30
+ # The set of source packages that have been selected
31
+ attr_reader :source_packages
32
+ # The set of osdeps that have been selected
33
+ attr_reader :osdeps
34
+
35
+ def initialize
36
+ @selection = Hash.new { |h, k| h[k] = Set.new }
37
+ @matches = Hash.new { |h, k| h[k] = Set.new }
38
+ @weak_dependencies = Hash.new
39
+ @ignores = Hash.new { |h, k| h[k] = Set.new }
40
+ @exclusions = Hash.new { |h, k| h[k] = Set.new }
41
+ @source_packages = Set.new
42
+ @osdeps = Set.new
43
+ end
44
44
 
45
- def include?(pkg_name)
46
- selection.has_key?(pkg_name)
47
- end
45
+ def include?(pkg_name)
46
+ selection.has_key?(pkg_name)
47
+ end
48
48
 
49
- def empty?
50
- selection.empty?
51
- end
49
+ def empty?
50
+ selection.empty?
51
+ end
52
52
 
53
- # Test if a package is in the ignore list
54
- #
55
- # @param [String] pkg_name Name of the package
56
- # @return [Bool] true, if package is in the ignore list, false
57
- # otherwise
58
- def ignored?(pkg_name)
59
- ignores.include?(pkg_name)
60
- end
53
+ # Test if a package is in the ignore list
54
+ #
55
+ # @param [String] pkg_name Name of the package
56
+ # @return [Bool] true, if package is in the ignore list, false
57
+ # otherwise
58
+ def ignored?(pkg_name)
59
+ ignores.include?(pkg_name)
60
+ end
61
61
 
62
- # Test if a package is in the exclusions list
63
- #
64
- # @param [String] pkg_name Name of the package
65
- # @return [Bool] true, if package is in the exclusion list, false
66
- # otherwise
67
- def excluded?(pkg_name)
68
- exclusions.include?(pkg_name)
69
- end
62
+ # Test if a package is in the exclusions list
63
+ #
64
+ # @param [String] pkg_name Name of the package
65
+ # @return [Bool] true, if package is in the exclusion list, false
66
+ # otherwise
67
+ def excluded?(pkg_name)
68
+ exclusions.include?(pkg_name)
69
+ end
70
70
 
71
- # Returns the source packages selected explicitely or through
72
- # dependencies
73
- #
74
- # @param [Manifest] manifest
75
- # @return [Array<PackageDefinition>]
76
- def all_selected_source_packages(manifest)
77
- names = Set.new
78
- roots = each_source_package_name.to_set
79
- roots.each do |pkg_name|
80
- manifest.find_autobuild_package(pkg_name).all_dependencies(names)
81
- end
82
- names.merge(roots).map do |pkg_name|
83
- manifest.find_package_definition(pkg_name)
84
- end
71
+ # Returns the source packages selected explicitely or through
72
+ # dependencies
73
+ #
74
+ # @param [Manifest] manifest
75
+ # @return [Array<PackageDefinition>]
76
+ def all_selected_source_packages(manifest)
77
+ names = Set.new
78
+ roots = each_source_package_name.to_set
79
+ roots.each do |pkg_name|
80
+ manifest.find_autobuild_package(pkg_name).all_dependencies(names)
85
81
  end
86
-
87
- # Returns the source packages selected explicitely or through
88
- # dependencies
89
- #
90
- # @param [Manifest] manifest
91
- # @return [Array<String>]
92
- def all_selected_osdep_packages(manifest)
93
- all_sources = all_selected_source_packages(manifest)
94
- from_source = all_sources.each_with_object(Set.new) do |pkg, s|
95
- s.merge(pkg.autobuild.os_packages)
96
- end
97
- from_source | osdeps
82
+ names.merge(roots).map do |pkg_name|
83
+ manifest.find_package_definition(pkg_name)
98
84
  end
85
+ end
99
86
 
100
- def each(&block)
101
- Autoproj.warn_deprecated "PackageSelection#each", "use PackageSelection#each_source_package_name instead", 0
102
- each_source_package_name(&block)
103
- end
87
+ # Returns the source packages selected explicitely or through
88
+ # dependencies
89
+ #
90
+ # @param [Manifest] manifest
91
+ # @return [Array<String>]
92
+ def all_selected_osdep_packages(manifest)
93
+ all_sources = all_selected_source_packages(manifest)
94
+ from_source = all_sources.each_with_object(Set.new) do |pkg, s|
95
+ s.merge(pkg.autobuild.os_packages)
96
+ end
97
+ from_source | osdeps
98
+ end
104
99
 
105
- def each_package_name(&block)
106
- return enum_for(__method__) if !block
107
- each_source_package_name(&block)
108
- each_osdep_package_name(&block)
109
- end
100
+ def each(&block)
101
+ Autoproj.warn_deprecated "PackageSelection#each", "use PackageSelection#each_source_package_name instead", 0
102
+ each_source_package_name(&block)
103
+ end
110
104
 
111
- def selected_source_package?(pkg)
112
- source_packages.include?(pkg.name)
113
- end
105
+ def each_package_name(&block)
106
+ return enum_for(__method__) unless block
114
107
 
115
- def each_source_package_name(&block)
116
- source_packages.each(&block)
117
- end
108
+ each_source_package_name(&block)
109
+ each_osdep_package_name(&block)
110
+ end
118
111
 
119
- def each_osdep_package_name(&block)
120
- osdeps.each(&block)
121
- end
112
+ def selected_source_package?(pkg)
113
+ source_packages.include?(pkg.name)
114
+ end
122
115
 
123
- def packages
124
- Autoproj.warn_deprecated "PackageSelection#packages", "use PackageSelection#source_packages instead", 0
125
- source_packages
126
- end
116
+ def each_source_package_name(&block)
117
+ source_packages.each(&block)
118
+ end
127
119
 
128
- def select(sel, packages, *_backward, weak: false, osdep: false)
129
- unless _backward.empty?
130
- Autoproj.warn_deprecated "calling PackageSelection#select with a boolean as third argument", "use e.g. weak: true instead", 0
131
- weak = _backward.first
132
- end
120
+ def each_osdep_package_name(&block)
121
+ osdeps.each(&block)
122
+ end
133
123
 
134
- packages = Array(packages).to_set
135
- matches[sel].merge(packages)
136
- packages.each do |pkg_name|
137
- selection[pkg_name] << sel
138
- end
139
- if osdep
140
- osdeps.merge(packages)
141
- else
142
- source_packages.merge(packages)
143
- end
124
+ def packages
125
+ Autoproj.warn_deprecated "PackageSelection#packages", "use PackageSelection#source_packages instead", 0
126
+ source_packages
127
+ end
144
128
 
145
- weak_dependencies[sel] = weak
129
+ def select(sel, packages, *_backward, weak: false, osdep: false)
130
+ unless _backward.empty?
131
+ Autoproj.warn_deprecated "calling PackageSelection#select with a boolean as third argument", "use e.g. weak: true instead", 0
132
+ weak = _backward.first
146
133
  end
147
134
 
148
- def initialize_copy(old)
149
- old.selection.each do |pkg_name, set|
150
- @selection[pkg_name] = set.dup
151
- end
152
- old.matches.each do |sel, set|
153
- @matches[sel] = set.dup
154
- end
155
- @source_packages = old.source_packages.dup
156
- @osdeps = old.osdeps.dup
135
+ packages = Array(packages).to_set
136
+ matches[sel].merge(packages)
137
+ packages.each do |pkg_name|
138
+ selection[pkg_name] << sel
157
139
  end
158
-
159
- def has_match_for?(sel)
160
- matches.has_key?(sel)
140
+ if osdep
141
+ osdeps.merge(packages)
142
+ else
143
+ source_packages.merge(packages)
161
144
  end
162
145
 
163
- def match_for(sel)
164
- matches[sel]
146
+ weak_dependencies[sel] = weak
147
+ end
148
+
149
+ def initialize_copy(old)
150
+ old.selection.each do |pkg_name, set|
151
+ @selection[pkg_name] = set.dup
152
+ end
153
+ old.matches.each do |sel, set|
154
+ @matches[sel] = set.dup
165
155
  end
156
+ @source_packages = old.source_packages.dup
157
+ @osdeps = old.osdeps.dup
158
+ end
166
159
 
167
- # Remove packages that are explicitely excluded and/or ignored
168
- #
169
- # Raise an error if an explicit selection expands only to an
170
- # excluded package, and display a warning for ignored packages
171
- def filter_excluded_and_ignored_packages(manifest)
172
- matches.each do |sel, expansion|
173
- excluded, other = expansion.partition { |pkg_name| manifest.excluded?(pkg_name) }
174
- ignored, ok = other.partition { |pkg_name| manifest.ignored?(pkg_name) }
175
-
176
- if !excluded.empty? && (!weak_dependencies[sel] || (ok.empty? && ignored.empty?))
177
- exclusions = excluded.map do |pkg_name|
178
- [pkg_name, manifest.exclusion_reason(pkg_name)]
179
- end
180
- base_msg = "#{sel} is selected in the manifest or on the command line"
181
- if exclusions.size == 1
182
- reason = exclusions[0][1]
183
- if sel == exclusions[0][0]
184
- raise ExcludedSelection.new(sel), "#{base_msg}, but it is excluded from the build: #{reason}"
185
- elsif weak_dependencies[sel]
186
- raise ExcludedSelection.new(sel), "#{base_msg}, but it expands to #{exclusions.map(&:first).join(", ")}, which is excluded from the build: #{reason}"
187
- else
188
- raise ExcludedSelection.new(sel), "#{base_msg}, but its dependency #{exclusions.map(&:first).join(", ")} is excluded from the build: #{reason}"
189
- end
160
+ def has_match_for?(sel)
161
+ matches.has_key?(sel)
162
+ end
163
+
164
+ def match_for(sel)
165
+ matches[sel]
166
+ end
167
+
168
+ # Remove packages that are explicitely excluded and/or ignored
169
+ #
170
+ # Raise an error if an explicit selection expands only to an
171
+ # excluded package, and display a warning for ignored packages
172
+ def filter_excluded_and_ignored_packages(manifest)
173
+ matches.each do |sel, expansion|
174
+ excluded, other = expansion.partition { |pkg_name| manifest.excluded?(pkg_name) }
175
+ ignored, ok = other.partition { |pkg_name| manifest.ignored?(pkg_name) }
176
+
177
+ if !excluded.empty? && (!weak_dependencies[sel] || (ok.empty? && ignored.empty?))
178
+ exclusions = excluded.map do |pkg_name|
179
+ [pkg_name, manifest.exclusion_reason(pkg_name)]
180
+ end
181
+ base_msg = "#{sel} is selected in the manifest or on the command line"
182
+ if exclusions.size == 1
183
+ reason = exclusions[0][1]
184
+ if sel == exclusions[0][0]
185
+ raise ExcludedSelection.new(sel), "#{base_msg}, but it is excluded from the build: #{reason}"
190
186
  elsif weak_dependencies[sel]
191
- raise ExcludedSelection.new(sel), "#{base_msg}, but expands to #{exclusions.map(&:first).join(", ")}, and all these packages are excluded from the build:\n #{exclusions.map { |e_name, e_reason| "#{e_name}: #{e_reason}" }.join("\n ")}"
187
+ raise ExcludedSelection.new(sel), "#{base_msg}, but it expands to #{exclusions.map(&:first).join(', ')}, which is excluded from the build: #{reason}"
192
188
  else
193
- raise ExcludedSelection.new(sel), "#{base_msg}, but it requires #{exclusions.map(&:first).join(", ")}, and all these packages are excluded from the build:\n #{exclusions.map { |e_name, e_reason| "#{e_name}: #{e_reason}" }.join("\n ")}"
189
+ raise ExcludedSelection.new(sel), "#{base_msg}, but its dependency #{exclusions.map(&:first).join(', ')} is excluded from the build: #{reason}"
194
190
  end
191
+ elsif weak_dependencies[sel]
192
+ raise ExcludedSelection.new(sel), "#{base_msg}, but expands to #{exclusions.map(&:first).join(', ')}, and all these packages are excluded from the build:\n #{exclusions.map { |e_name, e_reason| "#{e_name}: #{e_reason}" }.join("\n ")}"
195
193
  else
196
- self.exclusions[sel] |= excluded.to_set.dup
197
- self.ignores[sel] |= ignored.to_set.dup
198
- end
199
-
200
- excluded = excluded.to_set
201
- ignored = ignored.to_set
202
- expansion.delete_if do |pkg_name|
203
- ignored.include?(pkg_name) || excluded.include?(pkg_name)
194
+ raise ExcludedSelection.new(sel), "#{base_msg}, but it requires #{exclusions.map(&:first).join(', ')}, and all these packages are excluded from the build:\n #{exclusions.map { |e_name, e_reason| "#{e_name}: #{e_reason}" }.join("\n ")}"
204
195
  end
196
+ else
197
+ self.exclusions[sel] |= excluded.to_set.dup
198
+ ignores[sel] |= ignored.to_set.dup
205
199
  end
206
200
 
207
- source_packages.delete_if do |pkg_name|
208
- manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
209
- end
210
- osdeps.delete_if do |pkg_name|
211
- manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
212
- end
213
- selection.delete_if do |pkg_name, _|
214
- manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
215
- end
216
- matches.delete_if do |key, sel|
217
- sel.empty?
201
+ excluded = excluded.to_set
202
+ ignored = ignored.to_set
203
+ expansion.delete_if do |pkg_name|
204
+ ignored.include?(pkg_name) || excluded.include?(pkg_name)
218
205
  end
219
206
  end
207
+
208
+ source_packages.delete_if do |pkg_name|
209
+ manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
210
+ end
211
+ osdeps.delete_if do |pkg_name|
212
+ manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
213
+ end
214
+ selection.delete_if do |pkg_name, _|
215
+ manifest.excluded?(pkg_name) || manifest.ignored?(pkg_name)
216
+ end
217
+ matches.delete_if do |key, sel|
218
+ sel.empty?
219
+ end
220
220
  end
221
+ end
221
222
  end
222
-