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