autoproj 2.12.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) 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 +6 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +2 -2
  14. data/bin/autoproj_bootstrap +186 -183
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +185 -182
  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 +61 -44
  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 +27 -27
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +18 -10
  31. data/lib/autoproj/cli/cache.rb +51 -8
  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 +18 -13
  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 +217 -205
  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 +48 -55
  52. data/lib/autoproj/cli/status.rb +56 -44
  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 +104 -51
  57. data/lib/autoproj/cli/utility.rb +14 -12
  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 +78 -85
  64. data/lib/autoproj/default.osdeps +29 -3
  65. data/lib/autoproj/environment.rb +42 -23
  66. data/lib/autoproj/exceptions.rb +9 -3
  67. data/lib/autoproj/find_workspace.rb +20 -25
  68. data/lib/autoproj/git_server_configuration.rb +40 -44
  69. data/lib/autoproj/gitorious.rb +1 -1
  70. data/lib/autoproj/installation_manifest.rb +64 -29
  71. data/lib/autoproj/local_package_set.rb +13 -11
  72. data/lib/autoproj/manifest.rb +145 -135
  73. data/lib/autoproj/metapackage.rb +2 -6
  74. data/lib/autoproj/ops/atomic_write.rb +7 -6
  75. data/lib/autoproj/ops/build.rb +4 -6
  76. data/lib/autoproj/ops/cache.rb +64 -53
  77. data/lib/autoproj/ops/cached_env.rb +7 -6
  78. data/lib/autoproj/ops/configuration.rb +511 -506
  79. data/lib/autoproj/ops/import.rb +90 -61
  80. data/lib/autoproj/ops/install.rb +179 -175
  81. data/lib/autoproj/ops/loader.rb +77 -76
  82. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  83. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  84. data/lib/autoproj/ops/snapshot.rb +250 -247
  85. data/lib/autoproj/ops/tools.rb +76 -78
  86. data/lib/autoproj/ops/watch.rb +6 -6
  87. data/lib/autoproj/ops/which.rb +17 -14
  88. data/lib/autoproj/options.rb +13 -2
  89. data/lib/autoproj/os_package_installer.rb +102 -92
  90. data/lib/autoproj/os_package_query.rb +7 -13
  91. data/lib/autoproj/os_package_resolver.rb +189 -140
  92. data/lib/autoproj/os_repository_installer.rb +4 -4
  93. data/lib/autoproj/os_repository_resolver.rb +8 -6
  94. data/lib/autoproj/package_definition.rb +12 -13
  95. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +46 -31
  96. data/lib/autoproj/package_managers/bundler_manager.rb +156 -118
  97. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  98. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  99. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  100. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  101. data/lib/autoproj/package_managers/manager.rb +8 -3
  102. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  103. data/lib/autoproj/package_managers/pip_manager.rb +37 -27
  104. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  105. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  106. data/lib/autoproj/package_managers/shell_script_manager.rb +66 -36
  107. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  108. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  109. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  110. data/lib/autoproj/package_manifest.rb +66 -53
  111. data/lib/autoproj/package_selection.rb +187 -187
  112. data/lib/autoproj/package_set.rb +128 -114
  113. data/lib/autoproj/python.rb +285 -0
  114. data/lib/autoproj/query_base.rb +20 -14
  115. data/lib/autoproj/reporter.rb +19 -19
  116. data/lib/autoproj/repository_managers/apt.rb +101 -67
  117. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  118. data/lib/autoproj/shell_completion.rb +16 -13
  119. data/lib/autoproj/source_package_query.rb +29 -36
  120. data/lib/autoproj/system.rb +32 -21
  121. data/lib/autoproj/test.rb +131 -106
  122. data/lib/autoproj/variable_expansion.rb +10 -10
  123. data/lib/autoproj/vcs_definition.rb +53 -37
  124. data/lib/autoproj/version.rb +1 -1
  125. data/lib/autoproj/workspace.rb +162 -117
  126. data/lib/autoproj/zsh_completion.rb +8 -9
  127. data/lib/autoproj.rb +53 -53
  128. data/samples/autoproj/init.rb +1 -2
  129. metadata +62 -72
  130. data/.travis.yml +0 -22
@@ -32,17 +32,15 @@ module Autoproj
32
32
  # If the values listed in +definitions+ also contain configuration
33
33
  # variables, they do not get expanded
34
34
  def self.single_expansion(data, definitions)
35
- if !data.respond_to?(:to_str)
36
- return data
37
- end
35
+ return data unless data.respond_to?(:to_str)
38
36
 
39
37
  data = data.gsub(/(.|^)\$(\w+)/) do |constant_name|
40
38
  prefix = constant_name[0, 1]
41
- if prefix == "\\"
42
- next(constant_name[1..-1])
43
- end
39
+ next(constant_name[1..-1]) if prefix == "\\"
40
+
44
41
  if prefix == "$"
45
- prefix, constant_name = "", constant_name[1..-1]
42
+ prefix = ""
43
+ constant_name = constant_name[1..-1]
46
44
  else
47
45
  constant_name = constant_name[2..-1]
48
46
  end
@@ -75,12 +73,15 @@ module Autoproj
75
73
  if contains_expansion?(value)
76
74
  raise ConfigError.new, "some expansions are not defined in #{value.inspect}"
77
75
  end
76
+
78
77
  value
79
78
  end
80
79
  end
81
80
 
82
81
  # True if the given string contains expansions
83
- def self.contains_expansion?(string); string =~ /\$/ end
82
+ def self.contains_expansion?(string)
83
+ string.respond_to?(:to_str) && string.to_str =~ /\$/
84
+ end
84
85
 
85
86
  def self.resolve_one_constant(name, value, result, definitions)
86
87
  result[name] ||= single_expansion(value, result) do |missing_name|
@@ -95,7 +96,7 @@ module Autoproj
95
96
  # refers to variables defined in +constants+
96
97
  def self.resolve_constant_definitions(constants, definitions = Hash.new)
97
98
  definitions = definitions.merge(constants)
98
-
99
+
99
100
  all_resolutions = Hash.new
100
101
  resolution_cache = Hash.new
101
102
  constants.each do |key, value|
@@ -104,4 +105,3 @@ module Autoproj
104
105
  all_resolutions
105
106
  end
106
107
  end
107
-
@@ -33,12 +33,14 @@ module Autoproj
33
33
  HistoryEntry = Struct.new :package_set, :vcs
34
34
  RawEntry = Struct.new :package_set, :file, :vcs
35
35
 
36
- def initialize(type, url, vcs_options, from: nil, raw: Array.new, history: Array.new)
37
- if !raw.respond_to?(:to_ary)
36
+ def initialize(type, url, vcs_options, from: nil, raw: [], history: [])
37
+ unless raw.respond_to?(:to_ary)
38
38
  raise ArgumentError, "wrong format for the raw field (#{raw.inspect})"
39
39
  end
40
40
 
41
- @type, @url, @options = type, url, vcs_options
41
+ @type = type
42
+ @url = url
43
+ @options = vcs_options
42
44
  if type != "none" && type != "local" && !Autobuild.respond_to?(type)
43
45
  raise ConfigError.new, "version control #{type} is unknown to autoproj"
44
46
  end
@@ -49,17 +51,17 @@ module Autoproj
49
51
 
50
52
  # Create a null VCS object
51
53
  def self.none
52
- from_raw(type: 'none')
54
+ from_raw({ type: "none" })
53
55
  end
54
56
 
55
57
  # Whether there is actually a version control definition
56
58
  def none?
57
- @type == 'none'
59
+ @type == "none"
58
60
  end
59
61
 
60
62
  # Whether this points to a local directory
61
63
  def local?
62
- @type == 'local'
64
+ @type == "local"
63
65
  end
64
66
 
65
67
  # Converts self to a Hash description that could be passed to {.from_raw}
@@ -83,7 +85,7 @@ module Autoproj
83
85
  if !new.has_key?(:type) || (type == new[:type])
84
86
  new = to_hash.merge(new)
85
87
  new_raw = self.raw + raw
86
- new_history = self.history
88
+ new_history = history
87
89
  end
88
90
  self.class.from_raw(new, from: from, history: new_history, raw: new_raw)
89
91
  end
@@ -135,15 +137,15 @@ module Autoproj
135
137
  raise ArgumentError, "invalid syntax"
136
138
  elsif plain.size == 1
137
139
  short_url = plain.first
138
- vcs, *url = short_url.split(':')
140
+ vcs, *url = short_url.split(":")
139
141
 
140
142
  # Check if VCS is a known version control system or source handler
141
143
  # shortcut. If it is not, look for a local directory called
142
144
  # short_url
143
145
  if Autobuild.respond_to?(vcs)
144
- spec.merge!(type: vcs, url: url.join(':'))
146
+ spec.merge!(type: vcs, url: url.join(":"))
145
147
  elsif Autoproj.has_source_handler?(vcs)
146
- spec = Autoproj.call_source_handler(vcs, url.join(':'), spec)
148
+ spec = Autoproj.call_source_handler(vcs, url.join(":"), spec)
147
149
  else
148
150
  source_dir =
149
151
  if Pathname.new(short_url).absolute?
@@ -151,18 +153,22 @@ module Autoproj
151
153
  elsif base_dir
152
154
  File.expand_path(short_url, base_dir)
153
155
  else
154
- raise ArgumentError, "VCS path '#{short_url}' is relative and no base_dir was given"
156
+ raise ArgumentError,
157
+ "VCS path '#{short_url}' is relative and no "\
158
+ "base_dir was given"
155
159
  end
156
- if !File.directory?(source_dir)
157
- raise ArgumentError, "'#{short_url}' is neither a remote source specification, nor an existing local directory"
160
+ unless File.directory?(source_dir)
161
+ raise ArgumentError,
162
+ "'#{short_url}' is neither a remote source "\
163
+ "specification, nor an existing local directory"
158
164
  end
159
- spec.merge!(type: 'local', url: source_dir)
165
+ spec.merge!(type: "local", url: source_dir)
160
166
  end
161
167
  end
162
168
 
163
169
  spec, vcs_options = Kernel.filter_options spec, type: nil, url: nil
164
170
  spec.merge!(vcs_options)
165
- if !spec[:url]
171
+ unless spec[:url]
166
172
  # Verify that none of the keys are source handlers. If it is the
167
173
  # case, convert
168
174
  filtered_spec = Hash.new
@@ -182,7 +188,7 @@ module Autoproj
182
188
  #
183
189
  # Converts a raw spec (a hash, really) into a nicely formatted string
184
190
  def self.raw_spec_to_s(spec)
185
- "{ #{spec.sort_by(&:first).map { |k, v| "#{k}: #{v}" }.join(", ")} }"
191
+ "{ #{spec.sort_by(&:first).map { |k, v| "#{k}: #{v}" }.join(', ')} }"
186
192
  end
187
193
 
188
194
  # Converts a 'raw' VCS representation to a normalized hash.
@@ -195,21 +201,31 @@ module Autoproj
195
201
  # @return [VCSDefinition]
196
202
  # @raise ArgumentError if the raw specification does not match an
197
203
  # expected format
198
- def self.from_raw(spec, from: nil, raw: Array.new, history: Array.new)
204
+ def self.from_raw(spec, from: nil, raw: [], history: [])
199
205
  normalized_spec = normalize_vcs_hash(spec)
200
- if !(type = normalized_spec.delete(:type))
201
- raise ArgumentError, "the source specification #{raw_spec_to_s(spec)} normalizes into #{raw_spec_to_s(normalized_spec)}, which does not have a VCS type"
202
- elsif !(url = normalized_spec.delete(:url))
203
- if type != 'none'
204
- raise ArgumentError, "the source specification #{raw_spec_to_s(spec)} normalizes into #{raw_spec_to_s(normalized_spec)}, which does not have a URL. Only VCS of type 'none' do not require one"
205
- end
206
+ unless (type = normalized_spec.delete(:type))
207
+ raise ArgumentError,
208
+ "the source specification #{raw_spec_to_s(spec)} normalizes "\
209
+ "into #{raw_spec_to_s(normalized_spec)}, "\
210
+ "which does not have a VCS type"
211
+ end
212
+
213
+ if !(url = normalized_spec.delete(:url)) && type != "none"
214
+ raise ArgumentError,
215
+ "the source specification #{raw_spec_to_s(spec)} normalizes "\
216
+ "into #{raw_spec_to_s(normalized_spec)}, "\
217
+ "which does not have a URL. "\
218
+ "Only VCS of type 'none' do not require one"
206
219
  end
207
220
 
208
- VCSDefinition.new(type, url, normalized_spec, from: from, history: history, raw: raw)
221
+ VCSDefinition.new(
222
+ type, url, normalized_spec, from: from, history: history, raw: raw
223
+ )
209
224
  end
210
225
 
211
226
  def ==(other_vcs)
212
- return false if !other_vcs.kind_of?(VCSDefinition)
227
+ return false unless other_vcs.kind_of?(VCSDefinition)
228
+
213
229
  if local?
214
230
  other_vcs.local? && url == other_vcs.url
215
231
  elsif other_vcs.local?
@@ -233,22 +249,21 @@ module Autoproj
233
249
  to_hash == other_vcs.to_hash
234
250
  end
235
251
 
236
- ABSOLUTE_PATH_OR_URI = /^([\w+]+:\/)?\/|^[:\w]+\@|^(\w+\@)?[\w\.-]+:/
252
+ ABSOLUTE_PATH_OR_URI = /^([\w+]+:\/)?\/|^[:\w]+@|^(\w+@)?[\w.-]+:/
237
253
 
238
254
  def self.to_absolute_url(url, root_dir)
239
- if url && url !~ ABSOLUTE_PATH_OR_URI
240
- url = File.expand_path(url, root_dir)
241
- end
255
+ url = File.expand_path(url, root_dir) if url && url !~ ABSOLUTE_PATH_OR_URI
242
256
  url
243
257
  end
244
258
 
245
259
  # Whether the underlying package needs to be imported
246
260
  def needs_import?
247
- type != 'none' && type != 'local'
261
+ type != "none" && type != "local"
248
262
  end
249
263
 
250
264
  def overrides_key
251
265
  return if none?
266
+
252
267
  if local?
253
268
  "local:#{url}"
254
269
  else
@@ -261,7 +276,7 @@ module Autoproj
261
276
  #
262
277
  # @return [Autobuild::Importer,nil] the autobuild importer
263
278
  def create_autobuild_importer
264
- return if !needs_import?
279
+ return unless needs_import?
265
280
 
266
281
  importer = Autobuild.send(type, url, options)
267
282
  if importer.respond_to?(:declare_alternate_repository)
@@ -269,6 +284,7 @@ module Autoproj
269
284
  package_set = entry.package_set
270
285
  vcs = entry.vcs
271
286
  next if !package_set || package_set.main?
287
+
272
288
  importer.declare_alternate_repository(package_set.name, vcs.url, vcs.options)
273
289
  end
274
290
  end
@@ -281,8 +297,8 @@ module Autoproj
281
297
  "none"
282
298
  else
283
299
  desc = "#{type}:#{url}"
284
- if !options.empty?
285
- desc = "#{desc} #{options.to_a.sort_by { |key, _| key.to_s }.map { |key, value| "#{key}=#{value}" }.join(" ")}"
300
+ unless options.empty?
301
+ desc = "#{desc} #{options.to_a.sort_by { |key, _| key.to_s }.map { |key, value| "#{key}=#{value}" }.join(' ')}"
286
302
  end
287
303
  desc
288
304
  end
@@ -304,10 +320,10 @@ module Autoproj
304
320
  # definition as a hash
305
321
  def self.call_source_handler(vcs, url, options)
306
322
  handler = @custom_source_handlers[vcs.to_s]
307
- if !handler
308
- raise ArgumentError, "there is no source handler for #{vcs}"
323
+ if handler
324
+ handler.call(url, **options)
309
325
  else
310
- return handler.call(url, options)
326
+ raise ArgumentError, "there is no source handler for #{vcs}"
311
327
  end
312
328
  end
313
329
 
@@ -333,7 +349,7 @@ module Autoproj
333
349
  # @yieldparam [Hash] the rest of the VCS hash
334
350
  # @return [Hash] a VCS hash with the information expanded
335
351
  def self.add_source_handler(name, &handler)
336
- @custom_source_handlers[name.to_s] = lambda(&handler)
352
+ @custom_source_handlers[name.to_s] = handler
337
353
  end
338
354
 
339
355
  # Deregister a source handler defined with {.add_source_handler}
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "2.12.0"
2
+ VERSION = "2.15.0"
3
3
  end