autoproj 2.15.0 → 2.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/autoproj.gemspec +2 -0
- data/bin/autoproj_bootstrap +44 -22
- data/bin/autoproj_install +44 -22
- data/lib/autoproj/autobuild.rb +4 -0
- data/lib/autoproj/autobuild_extensions/dsl.rb +26 -0
- data/lib/autoproj/autobuild_extensions/python.rb +18 -0
- data/lib/autoproj/configuration.rb +2 -3
- data/lib/autoproj/ops/configuration.rb +76 -48
- data/lib/autoproj/ops/import.rb +3 -1
- data/lib/autoproj/ops/install.rb +44 -22
- data/lib/autoproj/package_managers/apt_dpkg_manager.rb +9 -1
- data/lib/autoproj/package_managers/bundler_manager.rb +37 -17
- data/lib/autoproj/package_managers/pip_manager.rb +6 -14
- data/lib/autoproj/package_managers/shell_script_manager.rb +19 -7
- data/lib/autoproj/package_manifest.rb +5 -52
- data/lib/autoproj/python.rb +26 -14
- data/lib/autoproj/repository_managers/apt.rb +1 -1
- data/lib/autoproj/ros_condition_parser.rb +84 -0
- data/lib/autoproj/ros_package_manifest.rb +125 -0
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj.rb +3 -1
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637e55569497703d3288f3d36fe316c204238c65f32e566811223a4bc9028b44
|
4
|
+
data.tar.gz: d55c78b10017e3e9e4b42e879edea1478baaff3c80705eddeca69156c84accf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b6a24e168732906376569b34ba8a3ce562988d3ce4fcb4bb0eafd0e22726b76fe9fcb0f4dbfc4b7b306d2d6683c7e534f2d8d1e7ae1aebdd2bc4404c6fe21fe
|
7
|
+
data.tar.gz: 14252a325369a374459ce7115ffba28937e58e64e635e15fc1f1295f6208b2ec38c272799f66b1115668a81b30a3334c27375739e15ddcfa3e29ed4119535343
|
data/autoproj.gemspec
CHANGED
@@ -29,7 +29,9 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_runtime_dependency "backports", "~> 3.0"
|
30
30
|
s.add_runtime_dependency "bundler"
|
31
31
|
s.add_runtime_dependency "concurrent-ruby", "~> 1.1"
|
32
|
+
s.add_runtime_dependency "parslet"
|
32
33
|
s.add_runtime_dependency "rb-inotify" if RbConfig::CONFIG["target_os"] =~ /linux/
|
34
|
+
s.add_runtime_dependency "rgl", "~> 0.5.7"
|
33
35
|
s.add_runtime_dependency "thor", "~> 1.0"
|
34
36
|
s.add_runtime_dependency "tty-color", "~> 0.5.0"
|
35
37
|
s.add_runtime_dependency "tty-prompt", "~> 0.21.0"
|
data/bin/autoproj_bootstrap
CHANGED
@@ -172,16 +172,23 @@ module Autoproj
|
|
172
172
|
attr_writer :local
|
173
173
|
|
174
174
|
# The user-wide place where RubyGems installs gems
|
175
|
-
def dot_gem_dir
|
176
|
-
|
175
|
+
def self.dot_gem_dir
|
176
|
+
if Gem.respond_to?(:data_home) # Debian 11+
|
177
|
+
File.join(Gem.data_home, "gem")
|
178
|
+
else
|
179
|
+
File.join(Gem.user_home, ".gem")
|
180
|
+
end
|
177
181
|
end
|
178
182
|
|
179
183
|
# The version and platform-specific suffix under {#dot_gem_dir}
|
180
184
|
#
|
181
185
|
# This is also the suffix used by bundler to install gems
|
182
|
-
def
|
183
|
-
@
|
184
|
-
|
186
|
+
def self.gems_path_suffix
|
187
|
+
@gems_path_suffix ||=
|
188
|
+
Pathname
|
189
|
+
.new(Gem.user_dir)
|
190
|
+
.relative_path_from(Pathname.new(dot_gem_dir))
|
191
|
+
.to_s
|
185
192
|
end
|
186
193
|
|
187
194
|
# The path into which the workspace's gems should be installed
|
@@ -196,13 +203,13 @@ module Autoproj
|
|
196
203
|
#
|
197
204
|
# @return [String]
|
198
205
|
def gems_gem_home
|
199
|
-
File.join(gems_install_path,
|
206
|
+
File.join(gems_install_path, self.class.gems_path_suffix)
|
200
207
|
end
|
201
208
|
# Sets where the workspace's gems should be installed
|
202
209
|
#
|
203
210
|
# @param [String] path the absolute path that should be given to
|
204
211
|
# bundler. The gems themselves will be installed in the
|
205
|
-
# {
|
212
|
+
# {.gems_path_suffix} subdirectory under this
|
206
213
|
|
207
214
|
private def xdg_var(varname, default)
|
208
215
|
if (env = ENV[varname]) && !env.empty?
|
@@ -439,32 +446,42 @@ module Autoproj
|
|
439
446
|
lockfile = File.join(dot_autoproj, "Gemfile.lock")
|
440
447
|
FileUtils.rm lockfile if File.exist?(lockfile)
|
441
448
|
|
442
|
-
|
449
|
+
run_bundler(bundler, "config", "set", "--local", "path", gems_install_path,
|
450
|
+
bundler_version: bundler_version)
|
451
|
+
run_bundler(bundler, "config", "set", "--local", "shebang", Gem.ruby,
|
452
|
+
bundler_version: bundler_version)
|
453
|
+
|
454
|
+
install_args = ["--gemfile=#{autoproj_gemfile_path}"]
|
455
|
+
install_args << "--local" if local?
|
456
|
+
run_bundler(bundler, "install", *install_args,
|
457
|
+
bundler_version: bundler_version)
|
443
458
|
|
444
|
-
opts = Array.new
|
445
|
-
opts << "--local" if local?
|
446
|
-
opts << "--path=#{gems_install_path}"
|
447
459
|
shims_path = File.join(dot_autoproj, "bin")
|
460
|
+
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
|
461
|
+
bundler_version: bundler_version)
|
462
|
+
self.class.rewrite_shims(
|
463
|
+
shims_path, ruby_executable, root_dir,
|
464
|
+
autoproj_gemfile_path, gems_gem_home
|
465
|
+
)
|
466
|
+
end
|
467
|
+
|
468
|
+
class BundlerFailed < RuntimeError; end
|
469
|
+
|
470
|
+
def run_bundler(bundler, *args, bundler_version: self.bundler_version)
|
471
|
+
clean_env = env_for_child.dup
|
448
472
|
|
449
473
|
version_arg = []
|
450
474
|
version_arg << "_#{bundler_version}_" if bundler_version
|
451
475
|
|
452
476
|
result = system(
|
453
|
-
clean_env,
|
454
|
-
|
455
|
-
"--gemfile=#{autoproj_gemfile_path}",
|
456
|
-
"--shebang=#{Gem.ruby}",
|
457
|
-
"--binstubs=#{shims_path}",
|
458
|
-
*opts, chdir: dot_autoproj
|
477
|
+
clean_env, Gem.ruby, bundler, *version_arg,
|
478
|
+
*args, chdir: dot_autoproj
|
459
479
|
)
|
460
480
|
|
461
481
|
unless result
|
462
|
-
|
463
|
-
|
482
|
+
raise BundlerFailed,
|
483
|
+
"FAILED: bundler #{args.join(', ')} in #{dot_autoproj}"
|
464
484
|
end
|
465
|
-
ensure
|
466
|
-
self.class.rewrite_shims(shims_path, ruby_executable,
|
467
|
-
root_dir, autoproj_gemfile_path, gems_gem_home)
|
468
485
|
end
|
469
486
|
|
470
487
|
EXCLUDED_FROM_SHIMS = %w[rake thor].freeze
|
@@ -491,6 +508,7 @@ module Autoproj
|
|
491
508
|
bin_shim = File.join(shim_path, bin_name)
|
492
509
|
bin_script_lines = File.readlines(bin_script)
|
493
510
|
next if has_autoproj_preamble?(bin_script_lines)
|
511
|
+
next unless ruby_script?(bin_script_lines)
|
494
512
|
|
495
513
|
File.open(bin_shim, "w") do |io|
|
496
514
|
if bin_name == "bundler" || bin_name == "bundle"
|
@@ -505,6 +523,10 @@ module Autoproj
|
|
505
523
|
end
|
506
524
|
end
|
507
525
|
|
526
|
+
def self.ruby_script?(script_lines)
|
527
|
+
script_lines.first =~ /\#\s*!(.*ruby.*)/
|
528
|
+
end
|
529
|
+
|
508
530
|
def self.new_style_bundler_binstub?(script_lines)
|
509
531
|
script_lines.any? { |l| l =~ /This file was generated by Bundler/ }
|
510
532
|
end
|
data/bin/autoproj_install
CHANGED
@@ -172,16 +172,23 @@ module Autoproj
|
|
172
172
|
attr_writer :local
|
173
173
|
|
174
174
|
# The user-wide place where RubyGems installs gems
|
175
|
-
def dot_gem_dir
|
176
|
-
|
175
|
+
def self.dot_gem_dir
|
176
|
+
if Gem.respond_to?(:data_home) # Debian 11+
|
177
|
+
File.join(Gem.data_home, "gem")
|
178
|
+
else
|
179
|
+
File.join(Gem.user_home, ".gem")
|
180
|
+
end
|
177
181
|
end
|
178
182
|
|
179
183
|
# The version and platform-specific suffix under {#dot_gem_dir}
|
180
184
|
#
|
181
185
|
# This is also the suffix used by bundler to install gems
|
182
|
-
def
|
183
|
-
@
|
184
|
-
|
186
|
+
def self.gems_path_suffix
|
187
|
+
@gems_path_suffix ||=
|
188
|
+
Pathname
|
189
|
+
.new(Gem.user_dir)
|
190
|
+
.relative_path_from(Pathname.new(dot_gem_dir))
|
191
|
+
.to_s
|
185
192
|
end
|
186
193
|
|
187
194
|
# The path into which the workspace's gems should be installed
|
@@ -196,13 +203,13 @@ module Autoproj
|
|
196
203
|
#
|
197
204
|
# @return [String]
|
198
205
|
def gems_gem_home
|
199
|
-
File.join(gems_install_path,
|
206
|
+
File.join(gems_install_path, self.class.gems_path_suffix)
|
200
207
|
end
|
201
208
|
# Sets where the workspace's gems should be installed
|
202
209
|
#
|
203
210
|
# @param [String] path the absolute path that should be given to
|
204
211
|
# bundler. The gems themselves will be installed in the
|
205
|
-
# {
|
212
|
+
# {.gems_path_suffix} subdirectory under this
|
206
213
|
|
207
214
|
private def xdg_var(varname, default)
|
208
215
|
if (env = ENV[varname]) && !env.empty?
|
@@ -439,32 +446,42 @@ module Autoproj
|
|
439
446
|
lockfile = File.join(dot_autoproj, "Gemfile.lock")
|
440
447
|
FileUtils.rm lockfile if File.exist?(lockfile)
|
441
448
|
|
442
|
-
|
449
|
+
run_bundler(bundler, "config", "set", "--local", "path", gems_install_path,
|
450
|
+
bundler_version: bundler_version)
|
451
|
+
run_bundler(bundler, "config", "set", "--local", "shebang", Gem.ruby,
|
452
|
+
bundler_version: bundler_version)
|
453
|
+
|
454
|
+
install_args = ["--gemfile=#{autoproj_gemfile_path}"]
|
455
|
+
install_args << "--local" if local?
|
456
|
+
run_bundler(bundler, "install", *install_args,
|
457
|
+
bundler_version: bundler_version)
|
443
458
|
|
444
|
-
opts = Array.new
|
445
|
-
opts << "--local" if local?
|
446
|
-
opts << "--path=#{gems_install_path}"
|
447
459
|
shims_path = File.join(dot_autoproj, "bin")
|
460
|
+
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
|
461
|
+
bundler_version: bundler_version)
|
462
|
+
self.class.rewrite_shims(
|
463
|
+
shims_path, ruby_executable, root_dir,
|
464
|
+
autoproj_gemfile_path, gems_gem_home
|
465
|
+
)
|
466
|
+
end
|
467
|
+
|
468
|
+
class BundlerFailed < RuntimeError; end
|
469
|
+
|
470
|
+
def run_bundler(bundler, *args, bundler_version: self.bundler_version)
|
471
|
+
clean_env = env_for_child.dup
|
448
472
|
|
449
473
|
version_arg = []
|
450
474
|
version_arg << "_#{bundler_version}_" if bundler_version
|
451
475
|
|
452
476
|
result = system(
|
453
|
-
clean_env,
|
454
|
-
|
455
|
-
"--gemfile=#{autoproj_gemfile_path}",
|
456
|
-
"--shebang=#{Gem.ruby}",
|
457
|
-
"--binstubs=#{shims_path}",
|
458
|
-
*opts, chdir: dot_autoproj
|
477
|
+
clean_env, Gem.ruby, bundler, *version_arg,
|
478
|
+
*args, chdir: dot_autoproj
|
459
479
|
)
|
460
480
|
|
461
481
|
unless result
|
462
|
-
|
463
|
-
|
482
|
+
raise BundlerFailed,
|
483
|
+
"FAILED: bundler #{args.join(', ')} in #{dot_autoproj}"
|
464
484
|
end
|
465
|
-
ensure
|
466
|
-
self.class.rewrite_shims(shims_path, ruby_executable,
|
467
|
-
root_dir, autoproj_gemfile_path, gems_gem_home)
|
468
485
|
end
|
469
486
|
|
470
487
|
EXCLUDED_FROM_SHIMS = %w[rake thor].freeze
|
@@ -491,6 +508,7 @@ module Autoproj
|
|
491
508
|
bin_shim = File.join(shim_path, bin_name)
|
492
509
|
bin_script_lines = File.readlines(bin_script)
|
493
510
|
next if has_autoproj_preamble?(bin_script_lines)
|
511
|
+
next unless ruby_script?(bin_script_lines)
|
494
512
|
|
495
513
|
File.open(bin_shim, "w") do |io|
|
496
514
|
if bin_name == "bundler" || bin_name == "bundle"
|
@@ -505,6 +523,10 @@ module Autoproj
|
|
505
523
|
end
|
506
524
|
end
|
507
525
|
|
526
|
+
def self.ruby_script?(script_lines)
|
527
|
+
script_lines.first =~ /\#\s*!(.*ruby.*)/
|
528
|
+
end
|
529
|
+
|
508
530
|
def self.new_style_bundler_binstub?(script_lines)
|
509
531
|
script_lines.any? { |l| l =~ /This file was generated by Bundler/ }
|
510
532
|
end
|
data/lib/autoproj/autobuild.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "autoproj/autobuild_extensions/package"
|
2
|
+
require "autoproj/autobuild_extensions/python"
|
2
3
|
require "autoproj/autobuild_extensions/archive_importer"
|
3
4
|
require "autoproj/autobuild_extensions/git"
|
4
5
|
require "autoproj/autobuild_extensions/svn"
|
@@ -16,3 +17,6 @@ end
|
|
16
17
|
Autobuild::SVN.class_eval do
|
17
18
|
prepend Autoproj::AutobuildExtensions::SVN
|
18
19
|
end
|
20
|
+
Autobuild::Python.class_eval do
|
21
|
+
prepend Autoproj::AutobuildExtensions::Python
|
22
|
+
end
|
@@ -20,6 +20,28 @@ module Autoproj
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class << self
|
24
|
+
attr_writer :custom_package_handlers
|
25
|
+
|
26
|
+
def custom_package_handlers
|
27
|
+
@custom_package_handlers ||= []
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.each_custom_package_handler(&block)
|
32
|
+
return enum_for(__method__) unless block_given?
|
33
|
+
|
34
|
+
custom_package_handlers.each do |handler|
|
35
|
+
block.call(handler)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Registers a block that will be called to determine a package
|
40
|
+
# handler for the package in full_path.
|
41
|
+
def self.custom_package_handler(&block)
|
42
|
+
custom_package_handlers << block
|
43
|
+
end
|
44
|
+
|
23
45
|
# @api private
|
24
46
|
#
|
25
47
|
# Helper method that extracts the package name from a Rake-style package
|
@@ -112,6 +134,10 @@ module Autoproj
|
|
112
134
|
|
113
135
|
# Tries to find a handler automatically for 'full_path'
|
114
136
|
def self.package_handler_for(full_path)
|
137
|
+
each_custom_package_handler do |handler|
|
138
|
+
pair = handler.call(full_path)
|
139
|
+
return pair if pair
|
140
|
+
end
|
115
141
|
pyglob = File.join(File.basename(full_path), "*.py")
|
116
142
|
if !Dir.enum_for(:glob, File.join(full_path, "*.orogen")).to_a.empty?
|
117
143
|
["orogen_package", full_path]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Autoproj
|
4
|
+
module AutobuildExtensions
|
5
|
+
# Extension for Autobuild::Python
|
6
|
+
module Python
|
7
|
+
def activate_python
|
8
|
+
Autoproj::Python.setup_python_configuration_options(ws: ws)
|
9
|
+
Autoproj::Python.assert_python_activated(ws: ws)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_environment
|
13
|
+
activate_python
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -270,13 +270,12 @@ module Autoproj
|
|
270
270
|
|
271
271
|
# The user-wide place where RubyGems installs gems
|
272
272
|
def self.dot_gem_dir
|
273
|
-
|
273
|
+
Ops::Install.dot_gem_dir
|
274
274
|
end
|
275
275
|
|
276
276
|
# The Ruby platform and version-specific subdirectory used by bundler and rubygem
|
277
277
|
def self.gems_path_suffix
|
278
|
-
|
279
|
-
.relative_path_from(Pathname.new(dot_gem_dir)).to_s
|
278
|
+
Ops::Install.gems_path_suffix
|
280
279
|
end
|
281
280
|
|
282
281
|
# The gem install root into which the workspace gems are installed
|
@@ -1,9 +1,68 @@
|
|
1
|
+
require "rgl/adjacency"
|
2
|
+
require "rgl/dot"
|
3
|
+
require "rgl/topsort"
|
4
|
+
|
1
5
|
module Autoproj
|
2
6
|
module Ops
|
3
7
|
#--
|
4
8
|
# NOTE: indentation is wrong to let git track the history properly
|
5
9
|
#+++
|
6
10
|
|
11
|
+
# PackageSetHierachy be used to build the hierarchy of package set
|
12
|
+
# imports, as directed acyclic graph (DAG)
|
13
|
+
# so that they can be (topologically) sorted according to their
|
14
|
+
# dependencies
|
15
|
+
class PackageSetHierarchy
|
16
|
+
attr_reader :dag
|
17
|
+
|
18
|
+
def initialize(package_sets, root_pkg_set)
|
19
|
+
@dag = RGL::DirectedAdjacencyGraph.new
|
20
|
+
|
21
|
+
package_sets.each do |p|
|
22
|
+
p.imports.each do |dep|
|
23
|
+
@dag.add_edge dep, p
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@dag.add_vertex root_pkg_set
|
28
|
+
import_order = root_pkg_set.imports.to_a
|
29
|
+
import_order.each_with_index do |p, index|
|
30
|
+
if index + 1 < import_order.size
|
31
|
+
@dag.add_edge p, import_order[index + 1]
|
32
|
+
@dag.add_edge p, root_pkg_set
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def verify_acyclic
|
38
|
+
return if @dag.acyclic?
|
39
|
+
|
40
|
+
Autoproj.fatal "The package sets form (a) cycle(s)"
|
41
|
+
@dag.cycles.each_with_index do |cycle, index|
|
42
|
+
Autoproj.fatal "== Cycle #{index}"
|
43
|
+
(cycle + cycle[0, 1]).each_cons(2) do |a, b|
|
44
|
+
if b.imports.include?(a)
|
45
|
+
Autoproj.fatal " #{b.name} depends on #{a.name} in its source.yml"
|
46
|
+
else
|
47
|
+
Autoproj.fatal " #{b.name} is after #{a.name} in the package_sets section of the manifest"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
raise ConfigError.new "cycles in package set dependencies"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Flatten the hierarchy, a establish a sorting
|
56
|
+
def flatten
|
57
|
+
@dag.topsort_iterator.to_a
|
58
|
+
end
|
59
|
+
|
60
|
+
# Write the hierarchy to an image (png) file
|
61
|
+
def to_png(path)
|
62
|
+
@dag.write_to_graphic_file("png", path.gsub(".png", ""))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
7
66
|
# Implementation of the operations to manage the configuration
|
8
67
|
class Configuration
|
9
68
|
attr_reader :ws
|
@@ -160,7 +219,6 @@ module Autoproj
|
|
160
219
|
def load_package_set(vcs, options, imported_from)
|
161
220
|
pkg_set = PackageSet.new(ws, vcs)
|
162
221
|
pkg_set.auto_imports = options[:auto_imports]
|
163
|
-
ws.load_if_present(pkg_set, pkg_set.local_dir, "init.rb")
|
164
222
|
pkg_set.load_description_file
|
165
223
|
if imported_from
|
166
224
|
pkg_set.imported_from << imported_from
|
@@ -314,57 +372,20 @@ module Autoproj
|
|
314
372
|
to_s
|
315
373
|
end
|
316
374
|
|
375
|
+
# Sort the package sets by dependency order
|
376
|
+
# Package sets that have no dependencies come first,
|
377
|
+
# the local package set (by main configuration) last
|
317
378
|
def sort_package_sets_by_import_order(package_sets, root_pkg_set)
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
# topological order, in the user-provided order. Each package is
|
322
|
-
# considered in turn, and added at the earliest place that fits
|
323
|
-
# the dependencies
|
324
|
-
topological = Array.new
|
325
|
-
queue = (package_sets.to_a + [root_pkg_set]).uniq
|
326
|
-
until queue.empty?
|
327
|
-
last_size = queue.size
|
328
|
-
pending = queue.dup
|
329
|
-
queue = Array.new
|
330
|
-
until pending.empty?
|
331
|
-
pkg_set = pending.shift
|
332
|
-
if pkg_set.imports.any? { |imported_set| !topological.include?(imported_set) }
|
333
|
-
queue.push(pkg_set)
|
334
|
-
else
|
335
|
-
topological << pkg_set
|
336
|
-
end
|
337
|
-
end
|
338
|
-
if queue.size == last_size
|
339
|
-
raise ArgumentError, "cannot resolve the dependencies between package sets. There seem to be a cycle amongst #{queue.map(&:name).sort.join(', ')}"
|
340
|
-
end
|
341
|
-
end
|
379
|
+
c = PackageSetHierarchy.new(package_sets, root_pkg_set)
|
380
|
+
c.verify_acyclic
|
381
|
+
sorted_pkg_sets = c.flatten
|
342
382
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
until to_insert.empty?
|
347
|
-
pkg_set = to_insert.shift
|
348
|
-
dependencies = pkg_set.imports.dup
|
349
|
-
if dependencies.empty?
|
350
|
-
result.unshift(pkg_set)
|
351
|
-
else
|
352
|
-
i = result.find_index do |p|
|
353
|
-
dependencies.delete(p)
|
354
|
-
dependencies.empty?
|
355
|
-
end
|
356
|
-
result.insert(i + 1, pkg_set)
|
357
|
-
end
|
383
|
+
if sorted_pkg_sets.last != root_pkg_set
|
384
|
+
raise InternalError, "Failed to sort the package sets: the " \
|
385
|
+
"root package set should be last, but is not #{sorted_pkg_sets.map(&:name)}"
|
358
386
|
end
|
359
387
|
|
360
|
-
|
361
|
-
# - it should be last
|
362
|
-
# - it should be present only once
|
363
|
-
if result.last != root_pkg_set
|
364
|
-
raise InternalError, "failed to sort the package sets: the root package set should be last, but is not"
|
365
|
-
end
|
366
|
-
|
367
|
-
result
|
388
|
+
sorted_pkg_sets
|
368
389
|
end
|
369
390
|
|
370
391
|
def load_package_sets(
|
@@ -620,11 +641,18 @@ module Autoproj
|
|
620
641
|
root_pkg_set.imports.each do |pkg_set|
|
621
642
|
pkg_set.explicit = true
|
622
643
|
end
|
644
|
+
|
645
|
+
# sort packages, main package is the last
|
623
646
|
package_sets = sort_package_sets_by_import_order(package_sets, root_pkg_set)
|
624
647
|
ws.manifest.reset_package_sets
|
625
648
|
package_sets.each do |pkg_set|
|
626
649
|
ws.manifest.register_package_set(pkg_set)
|
627
650
|
end
|
651
|
+
|
652
|
+
ws.manifest.each_package_set do |pkg_set|
|
653
|
+
ws.load_if_present(pkg_set, pkg_set.local_dir, "init.rb")
|
654
|
+
end
|
655
|
+
|
628
656
|
failures
|
629
657
|
end
|
630
658
|
end
|
data/lib/autoproj/ops/import.rb
CHANGED
@@ -467,7 +467,9 @@ module Autoproj
|
|
467
467
|
|
468
468
|
raise failures.first if !keep_going && !failures.empty?
|
469
469
|
|
470
|
-
install_internal_dependencies_for(
|
470
|
+
install_internal_dependencies_for(
|
471
|
+
*all_processed_packages, install_only: import_options[:checkout_only]
|
472
|
+
)
|
471
473
|
finalize_package_load(all_processed_packages, auto_exclude: auto_exclude)
|
472
474
|
|
473
475
|
all_enabled_osdeps = selection.each_osdep_package_name.to_set
|
data/lib/autoproj/ops/install.rb
CHANGED
@@ -162,16 +162,23 @@ module Autoproj
|
|
162
162
|
attr_writer :local
|
163
163
|
|
164
164
|
# The user-wide place where RubyGems installs gems
|
165
|
-
def dot_gem_dir
|
166
|
-
|
165
|
+
def self.dot_gem_dir
|
166
|
+
if Gem.respond_to?(:data_home) # Debian 11+
|
167
|
+
File.join(Gem.data_home, "gem")
|
168
|
+
else
|
169
|
+
File.join(Gem.user_home, ".gem")
|
170
|
+
end
|
167
171
|
end
|
168
172
|
|
169
173
|
# The version and platform-specific suffix under {#dot_gem_dir}
|
170
174
|
#
|
171
175
|
# This is also the suffix used by bundler to install gems
|
172
|
-
def
|
173
|
-
@
|
174
|
-
|
176
|
+
def self.gems_path_suffix
|
177
|
+
@gems_path_suffix ||=
|
178
|
+
Pathname
|
179
|
+
.new(Gem.user_dir)
|
180
|
+
.relative_path_from(Pathname.new(dot_gem_dir))
|
181
|
+
.to_s
|
175
182
|
end
|
176
183
|
|
177
184
|
# The path into which the workspace's gems should be installed
|
@@ -186,13 +193,13 @@ module Autoproj
|
|
186
193
|
#
|
187
194
|
# @return [String]
|
188
195
|
def gems_gem_home
|
189
|
-
File.join(gems_install_path,
|
196
|
+
File.join(gems_install_path, self.class.gems_path_suffix)
|
190
197
|
end
|
191
198
|
# Sets where the workspace's gems should be installed
|
192
199
|
#
|
193
200
|
# @param [String] path the absolute path that should be given to
|
194
201
|
# bundler. The gems themselves will be installed in the
|
195
|
-
# {
|
202
|
+
# {.gems_path_suffix} subdirectory under this
|
196
203
|
|
197
204
|
private def xdg_var(varname, default)
|
198
205
|
if (env = ENV[varname]) && !env.empty?
|
@@ -429,32 +436,42 @@ module Autoproj
|
|
429
436
|
lockfile = File.join(dot_autoproj, "Gemfile.lock")
|
430
437
|
FileUtils.rm lockfile if File.exist?(lockfile)
|
431
438
|
|
432
|
-
|
439
|
+
run_bundler(bundler, "config", "set", "--local", "path", gems_install_path,
|
440
|
+
bundler_version: bundler_version)
|
441
|
+
run_bundler(bundler, "config", "set", "--local", "shebang", Gem.ruby,
|
442
|
+
bundler_version: bundler_version)
|
443
|
+
|
444
|
+
install_args = ["--gemfile=#{autoproj_gemfile_path}"]
|
445
|
+
install_args << "--local" if local?
|
446
|
+
run_bundler(bundler, "install", *install_args,
|
447
|
+
bundler_version: bundler_version)
|
433
448
|
|
434
|
-
opts = Array.new
|
435
|
-
opts << "--local" if local?
|
436
|
-
opts << "--path=#{gems_install_path}"
|
437
449
|
shims_path = File.join(dot_autoproj, "bin")
|
450
|
+
run_bundler(bundler, "binstubs", "--all", "--force", "--path", shims_path,
|
451
|
+
bundler_version: bundler_version)
|
452
|
+
self.class.rewrite_shims(
|
453
|
+
shims_path, ruby_executable, root_dir,
|
454
|
+
autoproj_gemfile_path, gems_gem_home
|
455
|
+
)
|
456
|
+
end
|
457
|
+
|
458
|
+
class BundlerFailed < RuntimeError; end
|
459
|
+
|
460
|
+
def run_bundler(bundler, *args, bundler_version: self.bundler_version)
|
461
|
+
clean_env = env_for_child.dup
|
438
462
|
|
439
463
|
version_arg = []
|
440
464
|
version_arg << "_#{bundler_version}_" if bundler_version
|
441
465
|
|
442
466
|
result = system(
|
443
|
-
clean_env,
|
444
|
-
|
445
|
-
"--gemfile=#{autoproj_gemfile_path}",
|
446
|
-
"--shebang=#{Gem.ruby}",
|
447
|
-
"--binstubs=#{shims_path}",
|
448
|
-
*opts, chdir: dot_autoproj
|
467
|
+
clean_env, Gem.ruby, bundler, *version_arg,
|
468
|
+
*args, chdir: dot_autoproj
|
449
469
|
)
|
450
470
|
|
451
471
|
unless result
|
452
|
-
|
453
|
-
|
472
|
+
raise BundlerFailed,
|
473
|
+
"FAILED: bundler #{args.join(', ')} in #{dot_autoproj}"
|
454
474
|
end
|
455
|
-
ensure
|
456
|
-
self.class.rewrite_shims(shims_path, ruby_executable,
|
457
|
-
root_dir, autoproj_gemfile_path, gems_gem_home)
|
458
475
|
end
|
459
476
|
|
460
477
|
EXCLUDED_FROM_SHIMS = %w[rake thor].freeze
|
@@ -481,6 +498,7 @@ module Autoproj
|
|
481
498
|
bin_shim = File.join(shim_path, bin_name)
|
482
499
|
bin_script_lines = File.readlines(bin_script)
|
483
500
|
next if has_autoproj_preamble?(bin_script_lines)
|
501
|
+
next unless ruby_script?(bin_script_lines)
|
484
502
|
|
485
503
|
File.open(bin_shim, "w") do |io|
|
486
504
|
if bin_name == "bundler" || bin_name == "bundle"
|
@@ -495,6 +513,10 @@ module Autoproj
|
|
495
513
|
end
|
496
514
|
end
|
497
515
|
|
516
|
+
def self.ruby_script?(script_lines)
|
517
|
+
script_lines.first =~ /\#\s*!(.*ruby.*)/
|
518
|
+
end
|
519
|
+
|
498
520
|
def self.new_style_bundler_binstub?(script_lines)
|
499
521
|
script_lines.any? { |l| l =~ /This file was generated by Bundler/ }
|
500
522
|
end
|