autoproj 2.12.1 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +30 -0
- data/.rubocop.yml +79 -91
- data/.rubocop_todo.yml +1473 -0
- data/Gemfile +9 -9
- data/Rakefile +24 -24
- data/autoproj.gemspec +24 -22
- data/bin/alocate +4 -4
- data/bin/alog +6 -7
- data/bin/amake +4 -4
- data/bin/aup +4 -4
- data/bin/autoproj +3 -3
- data/bin/autoproj_bootstrap +225 -200
- data/bin/autoproj_bootstrap.in +7 -8
- data/bin/autoproj_install +224 -199
- data/bin/autoproj_install.in +6 -7
- data/lib/autoproj/aruba_minitest.rb +6 -11
- data/lib/autoproj/autobuild.rb +9 -6
- data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
- data/lib/autoproj/autobuild_extensions/dsl.rb +66 -36
- data/lib/autoproj/autobuild_extensions/git.rb +27 -26
- data/lib/autoproj/autobuild_extensions/package.rb +23 -22
- data/lib/autoproj/autobuild_extensions/python.rb +18 -0
- data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
- data/lib/autoproj/base.rb +1 -1
- data/lib/autoproj/bash_completion.rb +5 -6
- data/lib/autoproj/build_option.rb +22 -24
- data/lib/autoproj/cli/base.rb +26 -26
- data/lib/autoproj/cli/bootstrap.rb +14 -16
- data/lib/autoproj/cli/build.rb +10 -7
- data/lib/autoproj/cli/cache.rb +11 -11
- data/lib/autoproj/cli/clean.rb +10 -10
- data/lib/autoproj/cli/commit.rb +7 -8
- data/lib/autoproj/cli/doc.rb +2 -2
- data/lib/autoproj/cli/envsh.rb +1 -2
- data/lib/autoproj/cli/exec.rb +60 -20
- data/lib/autoproj/cli/inspection_tool.rb +13 -7
- data/lib/autoproj/cli/locate.rb +30 -41
- data/lib/autoproj/cli/log.rb +7 -7
- data/lib/autoproj/cli/main.rb +217 -205
- data/lib/autoproj/cli/main_doc.rb +22 -21
- data/lib/autoproj/cli/main_global.rb +44 -19
- data/lib/autoproj/cli/main_plugin.rb +18 -18
- data/lib/autoproj/cli/main_test.rb +28 -27
- data/lib/autoproj/cli/manifest.rb +7 -7
- data/lib/autoproj/cli/osdeps.rb +12 -11
- data/lib/autoproj/cli/patcher.rb +2 -3
- data/lib/autoproj/cli/query.rb +17 -18
- data/lib/autoproj/cli/reconfigure.rb +1 -2
- data/lib/autoproj/cli/reset.rb +9 -12
- data/lib/autoproj/cli/show.rb +38 -39
- data/lib/autoproj/cli/status.rb +56 -44
- data/lib/autoproj/cli/switch_config.rb +5 -6
- data/lib/autoproj/cli/tag.rb +12 -11
- data/lib/autoproj/cli/test.rb +7 -7
- data/lib/autoproj/cli/update.rb +97 -43
- data/lib/autoproj/cli/utility.rb +14 -12
- data/lib/autoproj/cli/version.rb +42 -40
- data/lib/autoproj/cli/versions.rb +14 -15
- data/lib/autoproj/cli/watch.rb +33 -37
- data/lib/autoproj/cli/which.rb +16 -20
- data/lib/autoproj/cli.rb +4 -2
- data/lib/autoproj/configuration.rb +78 -86
- data/lib/autoproj/default.osdeps +29 -3
- data/lib/autoproj/environment.rb +42 -23
- data/lib/autoproj/exceptions.rb +9 -3
- data/lib/autoproj/find_workspace.rb +20 -25
- data/lib/autoproj/git_server_configuration.rb +40 -44
- data/lib/autoproj/gitorious.rb +1 -1
- data/lib/autoproj/installation_manifest.rb +64 -29
- data/lib/autoproj/local_package_set.rb +13 -11
- data/lib/autoproj/manifest.rb +139 -132
- data/lib/autoproj/metapackage.rb +2 -6
- data/lib/autoproj/ops/atomic_write.rb +7 -6
- data/lib/autoproj/ops/build.rb +4 -6
- data/lib/autoproj/ops/cache.rb +41 -43
- data/lib/autoproj/ops/cached_env.rb +5 -4
- data/lib/autoproj/ops/configuration.rb +519 -507
- data/lib/autoproj/ops/import.rb +88 -63
- data/lib/autoproj/ops/install.rb +218 -192
- data/lib/autoproj/ops/loader.rb +77 -76
- data/lib/autoproj/ops/main_config_switcher.rb +36 -45
- data/lib/autoproj/ops/phase_reporting.rb +4 -4
- data/lib/autoproj/ops/snapshot.rb +250 -247
- data/lib/autoproj/ops/tools.rb +76 -78
- data/lib/autoproj/ops/watch.rb +6 -6
- data/lib/autoproj/ops/which.rb +17 -14
- data/lib/autoproj/options.rb +13 -2
- data/lib/autoproj/os_package_installer.rb +102 -92
- data/lib/autoproj/os_package_query.rb +7 -13
- data/lib/autoproj/os_package_resolver.rb +189 -140
- data/lib/autoproj/os_repository_installer.rb +4 -4
- data/lib/autoproj/os_repository_resolver.rb +8 -6
- data/lib/autoproj/package_definition.rb +12 -13
- data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
- data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
- data/lib/autoproj/package_managers/debian_version.rb +25 -21
- data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
- data/lib/autoproj/package_managers/gem_manager.rb +68 -77
- data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
- data/lib/autoproj/package_managers/manager.rb +8 -3
- data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
- data/lib/autoproj/package_managers/pip_manager.rb +30 -28
- data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
- data/lib/autoproj/package_managers/port_manager.rb +2 -3
- data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
- data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
- data/lib/autoproj/package_managers/yum_manager.rb +12 -15
- data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
- data/lib/autoproj/package_manifest.rb +28 -74
- data/lib/autoproj/package_selection.rb +187 -187
- data/lib/autoproj/package_set.rb +145 -114
- data/lib/autoproj/python.rb +297 -0
- data/lib/autoproj/query_base.rb +20 -14
- data/lib/autoproj/reporter.rb +19 -19
- data/lib/autoproj/repository_managers/apt.rb +102 -68
- data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
- data/lib/autoproj/ros_condition_parser.rb +84 -0
- data/lib/autoproj/ros_package_manifest.rb +125 -0
- data/lib/autoproj/shell_completion.rb +16 -13
- data/lib/autoproj/source_package_query.rb +29 -36
- data/lib/autoproj/system.rb +32 -21
- data/lib/autoproj/test.rb +131 -106
- data/lib/autoproj/variable_expansion.rb +10 -10
- data/lib/autoproj/vcs_definition.rb +53 -37
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +143 -108
- data/lib/autoproj/zsh_completion.rb +8 -9
- data/lib/autoproj.rb +55 -53
- data/samples/autoproj/init.rb +1 -2
- metadata +86 -65
- data/.travis.yml +0 -22
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "tempfile"
|
2
|
+
require "json"
|
3
3
|
|
4
4
|
module Autoproj
|
5
5
|
# Manager for packages provided by external package managers
|
@@ -15,7 +15,8 @@ module Autoproj
|
|
15
15
|
error_t =
|
16
16
|
if defined? Psych::SyntaxError
|
17
17
|
[ArgumentError, Psych::SyntaxError]
|
18
|
-
else
|
18
|
+
else
|
19
|
+
ArgumentError
|
19
20
|
end
|
20
21
|
|
21
22
|
result = new(**options)
|
@@ -28,7 +29,7 @@ module Autoproj
|
|
28
29
|
verify_definitions(data)
|
29
30
|
rescue *error_t => e
|
30
31
|
raise ConfigError.new, "error in #{file_candidate}: "\
|
31
|
-
|
32
|
+
"#{e.message}", e.backtrace
|
32
33
|
end
|
33
34
|
|
34
35
|
result.merge(new(data, file_candidate, **options))
|
@@ -40,19 +41,19 @@ module Autoproj
|
|
40
41
|
attr_reader :ws
|
41
42
|
|
42
43
|
def self.autodetect_ruby_program
|
43
|
-
ruby = RbConfig::CONFIG[
|
44
|
-
ruby_bindir = RbConfig::CONFIG[
|
44
|
+
ruby = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
|
45
|
+
ruby_bindir = RbConfig::CONFIG["bindir"]
|
45
46
|
ruby_executable = File.join(ruby_bindir, ruby)
|
46
|
-
Autobuild.programs[
|
47
|
+
Autobuild.programs["ruby"] = ruby_executable
|
47
48
|
ruby_executable
|
48
49
|
end
|
49
50
|
|
50
|
-
AUTOPROJ_OSDEPS = File.join(__dir__,
|
51
|
+
AUTOPROJ_OSDEPS = File.join(__dir__, "default.osdeps")
|
51
52
|
def self.load_default
|
52
|
-
file = ENV[
|
53
|
+
file = ENV["AUTOPROJ_DEFAULT_OSDEPS"] || AUTOPROJ_OSDEPS
|
53
54
|
unless File.file?(file)
|
54
55
|
Autoproj.warn "#{file} (from AUTOPROJ_DEFAULT_OSDEPS) is not a file, "\
|
55
|
-
|
56
|
+
"falling back to #{AUTOPROJ_OSDEPS}"
|
56
57
|
file = AUTOPROJ_OSDEPS
|
57
58
|
end
|
58
59
|
load(file)
|
@@ -76,14 +77,14 @@ module Autoproj
|
|
76
77
|
#
|
77
78
|
# we need to be able to separate between OS and package manager names.
|
78
79
|
OS_PACKAGE_MANAGERS = {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
"debian" => "apt-dpkg",
|
81
|
+
"gentoo" => "emerge",
|
82
|
+
"arch" => "pacman",
|
83
|
+
"fedora" => "yum",
|
84
|
+
"macos-port" => "macports",
|
85
|
+
"macos-brew" => "brew",
|
86
|
+
"opensuse" => "zypper",
|
87
|
+
"freebsd" => "pkg"
|
87
88
|
}.freeze
|
88
89
|
|
89
90
|
# The information contained in the OSdeps files, as a hash
|
@@ -95,6 +96,7 @@ module Autoproj
|
|
95
96
|
# information in +definitions+ originates. It is a mapping from the
|
96
97
|
# package name to the osdeps file' full path
|
97
98
|
attr_reader :sources
|
99
|
+
|
98
100
|
# Controls whether the package resolver will prefer installing
|
99
101
|
# OS-independent packages (such as e.g. Gems) over their OS-provided
|
100
102
|
# equivalent (e.g. the packaged version of a gem)
|
@@ -110,8 +112,8 @@ module Autoproj
|
|
110
112
|
def os_package_manager=(manager_name)
|
111
113
|
if manager_name && !package_managers.include?(manager_name)
|
112
114
|
raise ArgumentError, "#{manager_name} is not a known "\
|
113
|
-
|
114
|
-
|
115
|
+
"package manager, known managers are "\
|
116
|
+
"#{package_managers.to_a.sort.join(', ')}"
|
115
117
|
end
|
116
118
|
@os_package_manager = manager_name
|
117
119
|
end
|
@@ -123,7 +125,7 @@ module Autoproj
|
|
123
125
|
unless @os_package_manager
|
124
126
|
os_names, = operating_system
|
125
127
|
os_name = os_names.find { |name| OS_PACKAGE_MANAGERS[name] }
|
126
|
-
@os_package_manager = OS_PACKAGE_MANAGERS[os_name] ||
|
128
|
+
@os_package_manager = OS_PACKAGE_MANAGERS[os_name] || "unknown"
|
127
129
|
end
|
128
130
|
@os_package_manager
|
129
131
|
end
|
@@ -139,9 +141,9 @@ module Autoproj
|
|
139
141
|
# The Gem::SpecFetcher object that should be used to query RubyGems, and
|
140
142
|
# install RubyGems packages
|
141
143
|
def initialize(defs = Hash.new, file = nil,
|
142
|
-
|
143
|
-
|
144
|
-
|
144
|
+
operating_system: nil,
|
145
|
+
package_managers: PACKAGE_MANAGERS.dup,
|
146
|
+
os_package_manager: nil)
|
145
147
|
@definitions = defs.to_hash
|
146
148
|
@resolve_package_cache = Hash.new
|
147
149
|
@all_definitions = Hash.new { |h, k| h[k] = Array.new }
|
@@ -209,8 +211,9 @@ module Autoproj
|
|
209
211
|
invalidate_resolve_package_cache
|
210
212
|
|
211
213
|
@sources = sources.merge(info.sources)
|
212
|
-
@all_definitions =
|
213
|
-
|
214
|
+
@all_definitions =
|
215
|
+
all_definitions
|
216
|
+
.merge(info.all_definitions) do |_package_name, all_defs, new_all_defs|
|
214
217
|
all_defs = all_defs.dup
|
215
218
|
new_all_defs = new_all_defs.dup
|
216
219
|
new_all_defs.delete_if do |files, data|
|
@@ -226,7 +229,7 @@ module Autoproj
|
|
226
229
|
#
|
227
230
|
# Warn about a collision (override) detected during #merge
|
228
231
|
def warn_about_merge_collisions(merged_info, suffixes, key,
|
229
|
-
|
232
|
+
_old_value, _new_value)
|
230
233
|
old = source_of(key)
|
231
234
|
new = merged_info.source_of(key)
|
232
235
|
|
@@ -234,27 +237,32 @@ module Autoproj
|
|
234
237
|
|
235
238
|
# Warn if the new osdep definition resolves to a different
|
236
239
|
# set of packages than the old one
|
237
|
-
old_resolved =
|
238
|
-
|
240
|
+
old_resolved =
|
241
|
+
resolve_package(key, resolve_recursive: false)
|
242
|
+
.each_with_object(Hash.new) do |(handler, status, list), osdep_h|
|
239
243
|
osdep_h[handler] = [status, list.dup]
|
240
244
|
end
|
241
|
-
|
242
|
-
|
245
|
+
|
246
|
+
new_resolved =
|
247
|
+
merged_info
|
248
|
+
.resolve_package(key, resolve_recursive: false)
|
249
|
+
.each_with_object(Hash.new) do |(handler, status, list), osdep_h|
|
243
250
|
osdep_h[handler] = [status, list.dup]
|
244
251
|
end
|
252
|
+
|
245
253
|
if old_resolved != new_resolved
|
246
254
|
Autoproj.warn "osdeps definition for #{key}, "\
|
247
|
-
|
255
|
+
"previously defined in #{old} overridden by #{new}:"
|
248
256
|
first = true
|
249
257
|
old_resolved.each do |handler, (_, packages)|
|
250
258
|
Autoproj.warn " #{first ? 'resp. ' : ' '}#{handler}: "\
|
251
|
-
|
259
|
+
"#{packages.map(&:to_s).join(', ')}"
|
252
260
|
first = false
|
253
261
|
end
|
254
262
|
first = true
|
255
263
|
new_resolved.each do |handler, (_, packages)|
|
256
264
|
Autoproj.warn " #{first ? 'and ' : ' '}#{handler}: "\
|
257
|
-
|
265
|
+
"#{packages.map(&:to_s).join(', ')}"
|
258
266
|
first = false
|
259
267
|
end
|
260
268
|
end
|
@@ -264,20 +272,35 @@ module Autoproj
|
|
264
272
|
def self.verify_definitions(hash, path = [])
|
265
273
|
hash.each do |key, value|
|
266
274
|
if value && !key.kind_of?(String)
|
267
|
-
raise ArgumentError,
|
268
|
-
|
269
|
-
|
270
|
-
elsif !value &&
|
275
|
+
raise ArgumentError,
|
276
|
+
"invalid osdeps definition: found an #{key.class} as a key in "\
|
277
|
+
"#{path.join('/')}. Don't forget to put quotes around numbers"
|
278
|
+
elsif !value && key.kind_of?(Hash)
|
271
279
|
verify_definitions(key)
|
280
|
+
elsif !value && key.kind_of?(Array)
|
281
|
+
key.each do |entry|
|
282
|
+
next if entry.respond_to?(:to_str)
|
283
|
+
|
284
|
+
if !entry.respond_to?(:to_hash)
|
285
|
+
raise ArgumentError,
|
286
|
+
"invalid osdeps definition: found #{entry} as a value "\
|
287
|
+
"in #{path.join('/')}. Was expecting a string or a hash"
|
288
|
+
elsif !entry["name"]
|
289
|
+
raise ArgumentError,
|
290
|
+
"invalid osdeps definition: found #{entry} as a value "\
|
291
|
+
"in #{path.join('/')}. Was expecting a 'name' field."
|
292
|
+
end
|
293
|
+
end
|
272
294
|
end
|
273
295
|
next unless value
|
274
296
|
|
275
297
|
if value.kind_of?(Array) || value.kind_of?(Hash)
|
276
298
|
verify_definitions(value, (path + [key]))
|
277
299
|
elsif !value.kind_of?(String)
|
278
|
-
raise ArgumentError,
|
279
|
-
|
280
|
-
|
300
|
+
raise ArgumentError,
|
301
|
+
"invalid osdeps definition: found an #{value.class} as a "\
|
302
|
+
"value in #{path.join('/')}. Don't forget to put "\
|
303
|
+
"quotes around numbers"
|
281
304
|
end
|
282
305
|
end
|
283
306
|
end
|
@@ -292,69 +315,70 @@ module Autoproj
|
|
292
315
|
# system on which we are installed
|
293
316
|
def supported_operating_system?
|
294
317
|
if @supported_operating_system.nil?
|
295
|
-
@supported_operating_system = (os_package_manager !=
|
318
|
+
@supported_operating_system = (os_package_manager != "unknown")
|
296
319
|
end
|
297
320
|
@supported_operating_system
|
298
321
|
end
|
299
322
|
|
300
323
|
def self.guess_operating_system
|
301
|
-
if File.exist?(
|
302
|
-
versions = [File.read(
|
324
|
+
if File.exist?("/etc/debian_version")
|
325
|
+
versions = [File.read("/etc/debian_version").strip]
|
303
326
|
versions = %w[unstable sid] if versions.first =~ /sid/
|
304
|
-
[[
|
305
|
-
elsif File.exist?(
|
306
|
-
release_string = File.read(
|
327
|
+
[["debian"], versions]
|
328
|
+
elsif File.exist?("/etc/redhat-release")
|
329
|
+
release_string = File.read("/etc/redhat-release").strip
|
307
330
|
release_string =~ /(.*) release ([\d.]+)/
|
308
331
|
name = $1.downcase
|
309
332
|
version = $2
|
310
|
-
name =
|
333
|
+
name = "rhel" if name =~ /Red Hat Entreprise/
|
311
334
|
[[name], [version]]
|
312
|
-
elsif File.exist?(
|
313
|
-
release_string = File.read(
|
335
|
+
elsif File.exist?("/etc/gentoo-release")
|
336
|
+
release_string = File.read("/etc/gentoo-release").strip
|
314
337
|
release_string =~ /^.*([^\s]+)$/
|
315
338
|
version = $1
|
316
|
-
[[
|
317
|
-
elsif File.exist?(
|
318
|
-
[[
|
339
|
+
[["gentoo"], [version]]
|
340
|
+
elsif File.exist?("/etc/arch-release")
|
341
|
+
[["arch"], []]
|
319
342
|
elsif Autobuild.macos?
|
320
343
|
version = `sw_vers | head -2 | tail -1`.split(":")[1]
|
321
344
|
manager =
|
322
|
-
ENV[
|
323
|
-
|
345
|
+
ENV["AUTOPROJ_MACOSX_PACKAGE_MANAGER"] ||
|
346
|
+
"macos-brew"
|
324
347
|
unless OS_PACKAGE_MANAGERS.key?(manager)
|
325
348
|
known_managers = OS_PACKAGE_MANAGERS.keys.grep(/^macos/)
|
326
349
|
raise ArgumentError, "#{manager} is not a known MacOSX "\
|
327
|
-
|
328
|
-
|
350
|
+
"package manager. Known package managers are "\
|
351
|
+
"#{known_managers.join(', ')}"
|
329
352
|
end
|
330
353
|
|
331
354
|
managers =
|
332
|
-
if manager ==
|
333
|
-
[manager,
|
334
|
-
else
|
355
|
+
if manager == "macos-port"
|
356
|
+
[manager, "port"]
|
357
|
+
else
|
358
|
+
[manager]
|
335
359
|
end
|
336
|
-
[[*managers,
|
360
|
+
[[*managers, "darwin"], [version.strip]]
|
337
361
|
elsif Autobuild.windows?
|
338
|
-
[[
|
339
|
-
elsif File.exist?(
|
340
|
-
version = File.read(
|
362
|
+
[["windows"], []]
|
363
|
+
elsif File.exist?("/etc/SuSE-release")
|
364
|
+
version = File.read("/etc/SuSE-release").strip
|
341
365
|
version =~ /.*VERSION\s+=\s+([^\s]+)/
|
342
366
|
version = $1
|
343
|
-
[[
|
367
|
+
[["opensuse"], [version.strip]]
|
344
368
|
elsif Autobuild.freebsd?
|
345
369
|
version = `uname -r`.strip.split("-")[0]
|
346
|
-
[[
|
370
|
+
[["freebsd"], [version]]
|
347
371
|
end
|
348
372
|
end
|
349
373
|
|
350
374
|
def self.ensure_derivatives_refer_to_their_parents(names)
|
351
375
|
names = names.dup
|
352
376
|
version_files = Hash[
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
377
|
+
"/etc/debian_version" => "debian",
|
378
|
+
"/etc/redhat-release" => "fedora",
|
379
|
+
"/etc/gentoo-release" => "gentoo",
|
380
|
+
"/etc/arch-release" => "arch",
|
381
|
+
"/etc/SuSE-release" => "opensuse"]
|
358
382
|
version_files.each do |file, name|
|
359
383
|
names << name if File.exist?(file) && !names.include?(name)
|
360
384
|
end
|
@@ -365,7 +389,7 @@ module Autoproj
|
|
365
389
|
# Normalize the names to lowercase
|
366
390
|
names = names.map(&:downcase)
|
367
391
|
versions = versions.map(&:downcase)
|
368
|
-
versions += [
|
392
|
+
versions += ["default"] unless versions.include?("default")
|
369
393
|
[names, versions]
|
370
394
|
end
|
371
395
|
|
@@ -395,13 +419,14 @@ module Autoproj
|
|
395
419
|
#
|
396
420
|
# Examples: ['debian', ['sid', 'unstable']] or ['ubuntu', ['lucid lynx', '10.04']]
|
397
421
|
def self.autodetect_operating_system
|
398
|
-
if (user_os = ENV[
|
422
|
+
if (user_os = ENV["AUTOPROJ_OS"])
|
399
423
|
if user_os.empty?
|
400
424
|
return false
|
401
425
|
else
|
402
|
-
names, versions = user_os.split(
|
426
|
+
names, versions = user_os.split(":")
|
403
427
|
return normalize_os_representation(
|
404
|
-
names.split(
|
428
|
+
names.split(","), versions.split(",")
|
429
|
+
)
|
405
430
|
end
|
406
431
|
end
|
407
432
|
|
@@ -415,8 +440,8 @@ module Autoproj
|
|
415
440
|
# flavour. it seems that "/etc/debian_version" does not contain
|
416
441
|
# "sid" (but "8.0" for example) during the feature freeze
|
417
442
|
# phase...
|
418
|
-
if File.exist?(
|
419
|
-
debian_versions = [File.read(
|
443
|
+
if File.exist?("/etc/debian_version")
|
444
|
+
debian_versions = [File.read("/etc/debian_version").strip]
|
420
445
|
versions = %w[unstable sid] if debian_versions.first =~ /sid/
|
421
446
|
end
|
422
447
|
# otherwise "versions" contains the result it previously had
|
@@ -428,7 +453,7 @@ module Autoproj
|
|
428
453
|
[names, versions]
|
429
454
|
end
|
430
455
|
|
431
|
-
def self.os_from_os_release(filename =
|
456
|
+
def self.os_from_os_release(filename = "/etc/os-release")
|
432
457
|
return unless File.exist?(filename)
|
433
458
|
|
434
459
|
fields = Hash.new
|
@@ -438,21 +463,21 @@ module Autoproj
|
|
438
463
|
fields[$1] = $2
|
439
464
|
elsif !line.empty?
|
440
465
|
Autoproj.warn "could not parse line '#{line.inspect}' "\
|
441
|
-
|
466
|
+
"in /etc/os-release"
|
442
467
|
end
|
443
468
|
end
|
444
469
|
|
445
470
|
names = []
|
446
471
|
versions = []
|
447
|
-
names << fields[
|
448
|
-
versions << fields[
|
449
|
-
version = fields[
|
450
|
-
versions.concat(version.gsub(/[^\w.]/,
|
472
|
+
names << fields["ID"] << fields["ID_LIKE"]
|
473
|
+
versions << fields["VERSION_ID"]
|
474
|
+
version = fields["VERSION"] || ""
|
475
|
+
versions.concat(version.gsub(/[^\w.]/, " ").split(" "))
|
451
476
|
[names.compact.uniq, versions.compact.uniq]
|
452
477
|
end
|
453
478
|
|
454
479
|
def self.os_from_lsb
|
455
|
-
return unless Autobuild.find_in_path(
|
480
|
+
return unless Autobuild.find_in_path("lsb_release")
|
456
481
|
|
457
482
|
distributor = [`lsb_release -i -s`.strip.downcase]
|
458
483
|
codename = `lsb_release -c -s`.strip.downcase
|
@@ -481,7 +506,7 @@ module Autoproj
|
|
481
506
|
# calling {#resolve_package} with resolve_recursive set to false
|
482
507
|
class OSDepRecursiveResolver
|
483
508
|
def self.to_s
|
484
|
-
|
509
|
+
"osdep".freeze
|
485
510
|
end
|
486
511
|
end
|
487
512
|
|
@@ -518,40 +543,43 @@ module Autoproj
|
|
518
543
|
# package managers and os-independent package managers selected by
|
519
544
|
# OS or version
|
520
545
|
if os_names.empty?
|
521
|
-
os_names = [
|
522
|
-
os_versions = [
|
546
|
+
os_names = ["default"]
|
547
|
+
os_versions = ["default"]
|
523
548
|
else
|
524
549
|
os_names = os_names.dup
|
525
550
|
if prefer_indep_over_os_packages?
|
526
|
-
os_names.unshift
|
551
|
+
os_names.unshift "default"
|
527
552
|
else
|
528
|
-
os_names.push
|
553
|
+
os_names.push "default"
|
529
554
|
end
|
530
555
|
end
|
531
556
|
|
532
557
|
result = []
|
533
558
|
found, pkg = partition_osdep_entry(
|
534
559
|
name, dep_def, nil,
|
535
|
-
(package_managers - [os_package_manager]), os_names, os_versions
|
560
|
+
(package_managers - [os_package_manager]), os_names, os_versions
|
561
|
+
)
|
536
562
|
result << [os_package_manager, found, pkg] if found
|
537
563
|
|
538
564
|
package_managers.each do |handler|
|
539
565
|
found, pkg = partition_osdep_entry(
|
540
|
-
name, dep_def, [handler], [], os_names, os_versions
|
566
|
+
name, dep_def, [handler], [], os_names, os_versions
|
567
|
+
)
|
541
568
|
result << [handler, found, pkg] if found
|
542
569
|
end
|
543
570
|
|
544
571
|
# Recursive resolutions
|
545
572
|
found, pkg = partition_osdep_entry(
|
546
|
-
name, dep_def, [
|
573
|
+
name, dep_def, ["osdep"], [], os_names, os_versions
|
574
|
+
)
|
547
575
|
if found
|
548
576
|
if resolve_recursive
|
549
577
|
pkg.each do |pkg_name|
|
550
578
|
resolved = resolve_package(pkg_name)
|
551
579
|
unless resolved
|
552
|
-
raise InvalidRecursiveStatement,
|
553
|
-
|
554
|
-
|
580
|
+
raise InvalidRecursiveStatement,
|
581
|
+
"the '#{name}' osdep refers to another osdep, "\
|
582
|
+
"'#{pkg_name}', which does not seem to exist"
|
555
583
|
end
|
556
584
|
result.concat(resolved)
|
557
585
|
end
|
@@ -560,9 +588,7 @@ module Autoproj
|
|
560
588
|
end
|
561
589
|
end
|
562
590
|
|
563
|
-
result.each
|
564
|
-
args.last.freeze
|
565
|
-
end
|
591
|
+
result.each { |args| args.last.freeze }
|
566
592
|
result.freeze
|
567
593
|
if resolve_recursive
|
568
594
|
resolve_package_cache[name] = result
|
@@ -637,15 +663,20 @@ module Autoproj
|
|
637
663
|
result = []
|
638
664
|
found_keys = Hash.new
|
639
665
|
Array(dep_def).each do |names, values|
|
640
|
-
if
|
666
|
+
if values
|
641
667
|
entry_found, entry_nonexistent, entry_names =
|
642
|
-
|
643
|
-
|
668
|
+
partition_osdep_map_entry(
|
669
|
+
names, values, osdep_name,
|
670
|
+
handler_names, excluded, keys, found_keys, additional_keys
|
671
|
+
)
|
644
672
|
else
|
645
673
|
entry_found, entry_nonexistent, entry_names =
|
646
|
-
|
647
|
-
|
674
|
+
partition_osdep_raw_array_entry(
|
675
|
+
names, osdep_name,
|
676
|
+
handler_names, excluded, keys, additional_keys
|
677
|
+
)
|
648
678
|
end
|
679
|
+
|
649
680
|
found ||= entry_found
|
650
681
|
nonexistent ||= entry_nonexistent
|
651
682
|
result.concat(entry_names)
|
@@ -665,21 +696,22 @@ module Autoproj
|
|
665
696
|
found =
|
666
697
|
if nonexistent then FOUND_NONEXISTENT
|
667
698
|
elsif found then FOUND_PACKAGES
|
668
|
-
else
|
699
|
+
else
|
700
|
+
false
|
669
701
|
end
|
670
702
|
|
671
703
|
[found, result]
|
672
704
|
end
|
673
705
|
|
674
706
|
def partition_osdep_raw_array_entry(names, osdep_name, handler_names,
|
675
|
-
|
707
|
+
excluded, keys, additional_keys)
|
676
708
|
have_handler_names = true if handler_names
|
677
709
|
|
678
710
|
# Raw array of packages. Possible only if we are not at toplevel
|
679
711
|
# (i.e. if we already have a handler)
|
680
|
-
if names ==
|
712
|
+
if names == "ignore"
|
681
713
|
[!have_handler_names, false, []]
|
682
|
-
elsif names ==
|
714
|
+
elsif names == "nonexistent"
|
683
715
|
[false, !have_handler_names, []]
|
684
716
|
elsif !handler_names && names.kind_of?(Array)
|
685
717
|
[true, false, names]
|
@@ -694,14 +726,24 @@ module Autoproj
|
|
694
726
|
[false, false, []]
|
695
727
|
end
|
696
728
|
elsif names.respond_to?(:to_hash)
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
729
|
+
if keys.empty? && additional_keys.empty?
|
730
|
+
if excluded.include?(names["name"])
|
731
|
+
[false, false, []]
|
732
|
+
else
|
733
|
+
[true, false, [names]]
|
734
|
+
end
|
703
735
|
else
|
704
|
-
|
736
|
+
rec_found, rec_result = partition_osdep_entry(
|
737
|
+
osdep_name, names, handler_names, excluded,
|
738
|
+
keys, *additional_keys
|
739
|
+
)
|
740
|
+
if rec_found == FOUND_NONEXISTENT
|
741
|
+
[false, true, rec_result]
|
742
|
+
elsif rec_found == FOUND_PACKAGES
|
743
|
+
[true, false, rec_result]
|
744
|
+
else
|
745
|
+
[false, false, []]
|
746
|
+
end
|
705
747
|
end
|
706
748
|
else
|
707
749
|
[false, false, []]
|
@@ -709,17 +751,21 @@ module Autoproj
|
|
709
751
|
end
|
710
752
|
|
711
753
|
def partition_osdep_map_entry(names, values, osdep_name, handler_names,
|
712
|
-
|
754
|
+
excluded, keys, found_keys, additional_keys)
|
713
755
|
# names could be an array already
|
714
|
-
names = names.split(
|
756
|
+
names = names.split(",") if names.respond_to?(:to_str)
|
715
757
|
result = [false, false, []]
|
716
758
|
|
717
759
|
if handler_names
|
718
|
-
matching_handler =
|
719
|
-
find
|
760
|
+
matching_handler =
|
761
|
+
handler_names.find do |k|
|
762
|
+
names.any? { |name_tag| k == name_tag.downcase }
|
763
|
+
end
|
764
|
+
|
720
765
|
if matching_handler
|
721
766
|
rec_found, rec_result = partition_osdep_entry(
|
722
|
-
osdep_name, values, nil, excluded
|
767
|
+
osdep_name, values, nil, excluded
|
768
|
+
)
|
723
769
|
if rec_found == FOUND_NONEXISTENT
|
724
770
|
result = [false, true, rec_result]
|
725
771
|
elsif rec_found == FOUND_PACKAGES
|
@@ -728,22 +774,23 @@ module Autoproj
|
|
728
774
|
end
|
729
775
|
end
|
730
776
|
|
731
|
-
matching_name = keys
|
732
|
-
|
777
|
+
matching_name = keys
|
778
|
+
.find { |k| names.any? { |name_tag| k == name_tag.downcase } }
|
733
779
|
return result unless matching_name
|
734
780
|
|
735
781
|
rec_found, rec_result = partition_osdep_entry(
|
736
|
-
osdep_name, values, handler_names, excluded, *additional_keys
|
782
|
+
osdep_name, values, handler_names, excluded, *additional_keys
|
783
|
+
)
|
737
784
|
# We only consider the first highest-priority entry,
|
738
785
|
# regardless of whether it has some packages for us or
|
739
786
|
# not
|
740
787
|
idx = keys.index(matching_name)
|
741
|
-
if
|
742
|
-
found_keys[idx] = nil unless found_keys.key?(idx)
|
743
|
-
else
|
788
|
+
if rec_found
|
744
789
|
found_keys[idx] ||= [0, []]
|
745
790
|
found_keys[idx][0] += rec_found
|
746
791
|
found_keys[idx][1].concat(rec_result)
|
792
|
+
else
|
793
|
+
found_keys[idx] = nil unless found_keys.key?(idx)
|
747
794
|
end
|
748
795
|
result
|
749
796
|
end
|
@@ -764,29 +811,31 @@ module Autoproj
|
|
764
811
|
result = resolve_package(name)
|
765
812
|
unless result
|
766
813
|
path = resolve_name(name)
|
767
|
-
raise MissingOSDep.new,
|
768
|
-
|
814
|
+
raise MissingOSDep.new,
|
815
|
+
"there is no osdeps definition for #{path.last} "\
|
816
|
+
"(search tree: #{path.join('->')})"
|
769
817
|
end
|
770
818
|
|
771
819
|
if result.empty?
|
772
820
|
os_names, os_versions = operating_system
|
773
821
|
if os_names.empty?
|
774
|
-
raise MissingOSDep.new,
|
775
|
-
|
776
|
-
|
822
|
+
raise MissingOSDep.new,
|
823
|
+
"there is an osdeps definition for #{name}, but autoproj "\
|
824
|
+
"cannot detect the local operation system"
|
777
825
|
else
|
778
|
-
raise MissingOSDep.new,
|
779
|
-
|
780
|
-
|
781
|
-
|
826
|
+
raise MissingOSDep.new,
|
827
|
+
"there is an osdeps definition for #{name}, but not for "\
|
828
|
+
"this operating system and version resp. "\
|
829
|
+
"#{os_names.join(', ')} and #{os_versions.join(', ')})"
|
782
830
|
end
|
783
831
|
end
|
784
832
|
|
785
833
|
result.each do |handler, status, packages|
|
786
834
|
if status == FOUND_NONEXISTENT
|
787
|
-
raise MissingOSDep.new,
|
788
|
-
|
789
|
-
|
835
|
+
raise MissingOSDep.new,
|
836
|
+
"there is an osdep definition for #{name}, and it "\
|
837
|
+
"explicitely states that this package does not exist "\
|
838
|
+
"on your OS"
|
790
839
|
end
|
791
840
|
if (entry = all_packages.find { |h, _| h == handler })
|
792
841
|
entry[1].concat(packages)
|
@@ -864,12 +913,12 @@ module Autoproj
|
|
864
913
|
end
|
865
914
|
if failed.empty?
|
866
915
|
if resolved.empty?
|
867
|
-
|
916
|
+
IGNORE
|
868
917
|
else
|
869
|
-
|
918
|
+
AVAILABLE
|
870
919
|
end
|
871
920
|
else
|
872
|
-
|
921
|
+
NONEXISTENT
|
873
922
|
end
|
874
923
|
end
|
875
924
|
end
|