autoproj 2.14.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 +5 -7
- data/bin/amake +4 -4
- data/bin/aup +4 -4
- data/bin/autoproj +3 -3
- data/bin/autoproj_bootstrap +185 -182
- data/bin/autoproj_bootstrap.in +7 -8
- data/bin/autoproj_install +184 -181
- 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 +38 -34
- 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 +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 +213 -204
- 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 +45 -39
- 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 +35 -37
- data/lib/autoproj/cli/utility.rb +11 -10
- 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 +77 -84
- data/lib/autoproj/environment.rb +28 -13
- 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 +132 -130
- 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 +511 -506
- data/lib/autoproj/ops/import.rb +73 -63
- data/lib/autoproj/ops/install.rb +178 -174
- 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 +10 -10
- data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
- 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 +20 -22
- 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 +32 -22
- 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 +27 -26
- data/lib/autoproj/package_selection.rb +187 -187
- data/lib/autoproj/package_set.rb +127 -113
- data/lib/autoproj/python.rb +55 -55
- 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 +127 -104
- data/lib/autoproj/variable_expansion.rb +7 -9
- data/lib/autoproj/vcs_definition.rb +35 -32
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +123 -107
- data/lib/autoproj/zsh_completion.rb +8 -9
- data/lib/autoproj.rb +53 -55
- data/samples/autoproj/init.rb +1 -2
- metadata +53 -51
- data/.travis.yml +0 -24
@@ -27,29 +27,29 @@ module Autoproj
|
|
27
27
|
# of GEM_PATH
|
28
28
|
def initialize_environment
|
29
29
|
env = ws.env
|
30
|
-
env.original_env[
|
31
|
-
(env[
|
30
|
+
env.original_env["GEM_PATH"] =
|
31
|
+
(env["GEM_PATH"] || "").split(File::PATH_SEPARATOR).find_all do |p|
|
32
32
|
!Autoproj.in_autoproj_installation?(p)
|
33
33
|
end.join(File::PATH_SEPARATOR)
|
34
|
-
env.inherit
|
35
|
-
env.init_from_env
|
34
|
+
env.inherit "GEM_PATH"
|
35
|
+
env.init_from_env "GEM_PATH"
|
36
36
|
|
37
|
-
orig_gem_path = env.original_env[
|
38
|
-
env.system_env[
|
39
|
-
env.original_env[
|
37
|
+
orig_gem_path = env.original_env["GEM_PATH"].split(File::PATH_SEPARATOR)
|
38
|
+
env.system_env["GEM_PATH"] = Gem.default_path
|
39
|
+
env.original_env["GEM_PATH"] = orig_gem_path.join(File::PATH_SEPARATOR)
|
40
40
|
|
41
41
|
ws.config.each_reused_autoproj_installation do |p|
|
42
|
-
p_gems = File.join(p,
|
42
|
+
p_gems = File.join(p, ".gems")
|
43
43
|
if File.directory?(p_gems)
|
44
|
-
env.push_path
|
45
|
-
env.push_path
|
44
|
+
env.push_path "GEM_PATH", p_gems
|
45
|
+
env.push_path "PATH", File.join(p_gems, "bin")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
@gem_home = (ENV[
|
50
|
-
env.push_path
|
51
|
-
env.set
|
52
|
-
env.push_path
|
49
|
+
@gem_home = (ENV["AUTOPROJ_GEM_HOME"] || File.join(ws.root_dir, ".gems"))
|
50
|
+
env.push_path "GEM_PATH", gem_home
|
51
|
+
env.set "GEM_HOME", gem_home
|
52
|
+
env.push_path "PATH", "#{gem_home}/bin"
|
53
53
|
|
54
54
|
# Now, reset the directories in our own RubyGems instance
|
55
55
|
Gem.paths = env.resolved_env
|
@@ -59,47 +59,47 @@ module Autoproj
|
|
59
59
|
|
60
60
|
# Override the gem home detected by {initialize_environment}, or set
|
61
61
|
# it in cases where calling {initialize_environment} is not possible
|
62
|
-
|
63
|
-
|
62
|
+
class << self
|
63
|
+
attr_writer :gem_home
|
64
64
|
end
|
65
65
|
|
66
66
|
# A global cache directory that should be used to avoid
|
67
67
|
# re-downloading gems
|
68
68
|
def self.cache_dir
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
return unless (dir = ENV["AUTOBUILD_CACHE_DIR"])
|
70
|
+
|
71
|
+
dir = File.join(dir, "gems")
|
72
|
+
FileUtils.mkdir_p dir
|
73
|
+
dir
|
74
74
|
end
|
75
75
|
|
76
76
|
def self.use_cache_dir
|
77
77
|
# If there is a cache directory, make sure .gems/cache points to
|
78
78
|
# it (there are no programmatic ways to override this)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
return unless (cache = cache_dir)
|
80
|
+
|
81
|
+
gem_cache_dir = File.join(gem_home, "cache")
|
82
|
+
if !File.symlink?(gem_cache_dir) || File.readlink(gem_cache_dir) != cache
|
83
|
+
FileUtils.mkdir_p gem_home
|
84
|
+
FileUtils.rm_rf gem_cache_dir
|
85
|
+
Autoproj.create_symlink(cache, gem_cache_dir)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
# Return the directory in which RubyGems package should be installed
|
90
|
-
|
91
|
-
|
90
|
+
class << self
|
91
|
+
attr_reader :gem_home
|
92
92
|
end
|
93
93
|
|
94
94
|
@gem_home = nil
|
95
|
-
|
95
|
+
|
96
96
|
# Returns the set of default options that are added to gem
|
97
97
|
#
|
98
98
|
# By default, we add --no-user-install to un-break distributions
|
99
99
|
# like Arch that set --user-install by default (thus disabling the
|
100
100
|
# role of GEM_HOME)
|
101
101
|
def self.default_install_options
|
102
|
-
@default_install_options ||= [
|
102
|
+
@default_install_options ||= ["--no-user-install", "--no-format-executable"]
|
103
103
|
end
|
104
104
|
|
105
105
|
def initialize(ws)
|
@@ -115,7 +115,7 @@ module Autoproj
|
|
115
115
|
attr_reader :installed_gems
|
116
116
|
|
117
117
|
def gem_fetcher
|
118
|
-
|
118
|
+
unless @gem_fetcher
|
119
119
|
Autoproj.message " looking for RubyGems updates"
|
120
120
|
@gem_fetcher = Gem::SpecFetcher.fetcher
|
121
121
|
end
|
@@ -123,35 +123,29 @@ module Autoproj
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def guess_gem_program
|
126
|
-
if Autobuild.programs[
|
127
|
-
return Autobuild.programs['gem']
|
128
|
-
end
|
126
|
+
return Autobuild.programs["gem"] if Autobuild.programs["gem"]
|
129
127
|
|
130
|
-
ruby_bin = RbConfig::CONFIG[
|
131
|
-
ruby_bindir = RbConfig::CONFIG[
|
128
|
+
ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
|
129
|
+
ruby_bindir = RbConfig::CONFIG["bindir"]
|
132
130
|
|
133
|
-
candidates = [
|
134
|
-
if ruby_bin =~ /^ruby(.+)$/
|
135
|
-
candidates << "gem#{$1}"
|
136
|
-
end
|
131
|
+
candidates = ["gem"]
|
132
|
+
candidates << "gem#{$1}" if ruby_bin =~ /^ruby(.+)$/
|
137
133
|
|
138
134
|
candidates.each do |gem_name|
|
139
135
|
if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
|
140
|
-
Autobuild.programs[
|
136
|
+
Autobuild.programs["gem"] = gem_full_path
|
141
137
|
return
|
142
138
|
end
|
143
139
|
end
|
144
140
|
|
145
|
-
raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(
|
141
|
+
raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
|
146
142
|
end
|
147
143
|
|
148
144
|
def build_gem_cmdlines(gems)
|
149
145
|
with_version, without_version = gems.partition { |name, v| v }
|
150
146
|
|
151
147
|
cmdlines = []
|
152
|
-
|
153
|
-
cmdlines << without_version.flatten
|
154
|
-
end
|
148
|
+
cmdlines << without_version.flatten unless without_version.empty?
|
155
149
|
with_version.each do |name, v|
|
156
150
|
cmdlines << [name, "-v", v]
|
157
151
|
end
|
@@ -160,17 +154,17 @@ module Autoproj
|
|
160
154
|
|
161
155
|
def pristine(gems)
|
162
156
|
guess_gem_program
|
163
|
-
base_cmdline = [Autobuild.tool_in_path(
|
157
|
+
base_cmdline = [Autobuild.tool_in_path("ruby", env: ws.env), "-S", Autobuild.tool("gem")]
|
164
158
|
cmdlines = [
|
165
|
-
[*base_cmdline,
|
159
|
+
[*base_cmdline, "clean"]
|
166
160
|
]
|
167
161
|
cmdlines += build_gem_cmdlines(gems).map do |line|
|
168
162
|
base_cmdline + ["pristine", "--extensions"] + line
|
169
163
|
end
|
170
164
|
if gems_interaction(gems, cmdlines)
|
171
|
-
Autoproj.message " restoring RubyGems: #{gems.map { |g| g.join(
|
165
|
+
Autoproj.message " restoring RubyGems: #{gems.map { |g| g.join(' ') }.sort.join(', ')}"
|
172
166
|
cmdlines.each do |c|
|
173
|
-
Autobuild::Subprocess.run
|
167
|
+
Autobuild::Subprocess.run "autoproj", "osdeps", *c
|
174
168
|
end
|
175
169
|
end
|
176
170
|
end
|
@@ -178,25 +172,21 @@ module Autoproj
|
|
178
172
|
def install(gems)
|
179
173
|
guess_gem_program
|
180
174
|
|
181
|
-
base_cmdline = [Autobuild.tool_in_path(
|
182
|
-
|
183
|
-
base_cmdline << '--no-rdoc' << '--no-ri'
|
184
|
-
end
|
175
|
+
base_cmdline = [Autobuild.tool_in_path("ruby", env: ws.env), "-S", Autobuild.tool("gem"), "install", *GemManager.default_install_options]
|
176
|
+
base_cmdline << "--no-rdoc" << "--no-ri" unless GemManager.with_doc
|
185
177
|
|
186
|
-
if GemManager.with_prerelease
|
187
|
-
base_cmdline << "--prerelease"
|
188
|
-
end
|
178
|
+
base_cmdline << "--prerelease" if GemManager.with_prerelease
|
189
179
|
|
190
180
|
cmdlines = build_gem_cmdlines(gems).map do |line|
|
191
181
|
base_cmdline + line
|
192
182
|
end
|
193
183
|
if gems_interaction(gems, cmdlines)
|
194
|
-
Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(
|
184
|
+
Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(' ') }.sort.join(', ')}"
|
195
185
|
|
196
186
|
cmdlines.each do |c|
|
197
|
-
Autobuild::Subprocess.run
|
198
|
-
|
199
|
-
|
187
|
+
Autobuild::Subprocess.run "autoproj", "osdeps", *c,
|
188
|
+
env: Hash["GEM_HOME" => Gem.paths.home,
|
189
|
+
"GEM_PATH" => Gem.paths.path.join(":")]
|
200
190
|
end
|
201
191
|
gems.each do |name, v|
|
202
192
|
installed_gems << name
|
@@ -209,14 +199,14 @@ module Autoproj
|
|
209
199
|
# installed, or that can be upgraded
|
210
200
|
def filter_uptodate_packages(gems, options = Hash.new)
|
211
201
|
options = validate_options options,
|
212
|
-
|
202
|
+
install_only: !Autobuild.do_update
|
213
203
|
|
214
204
|
# Don't install gems that are already there ...
|
215
205
|
gems = gems.dup
|
216
206
|
gems.delete_if do |name, version|
|
217
207
|
next(true) if installed_gems.include?(name)
|
218
208
|
|
219
|
-
version_requirements = Gem::Requirement.new(version ||
|
209
|
+
version_requirements = Gem::Requirement.new(version || ">= 0")
|
220
210
|
installed =
|
221
211
|
if Gem::Specification.respond_to?(:find_by_name)
|
222
212
|
begin
|
@@ -236,14 +226,16 @@ module Autoproj
|
|
236
226
|
non_prerelease = gem_fetcher.find_matching(dep, true, true).map(&:first)
|
237
227
|
if GemManager.with_prerelease
|
238
228
|
prerelease = gem_fetcher.find_matching(dep, false, true, true).map(&:first)
|
239
|
-
else
|
229
|
+
else
|
230
|
+
prerelease = Array.new
|
240
231
|
end
|
241
|
-
(non_prerelease + prerelease)
|
242
|
-
map { |n, v, _| [n, v] }
|
232
|
+
(non_prerelease + prerelease)
|
233
|
+
.map { |n, v, _| [n, v] }
|
243
234
|
|
244
235
|
else # Post RubyGems-2.0
|
245
236
|
type = if GemManager.with_prerelease then :complete
|
246
|
-
else
|
237
|
+
else
|
238
|
+
:released
|
247
239
|
end
|
248
240
|
|
249
241
|
gem_fetcher.detect(type) do |tuple|
|
@@ -252,7 +244,7 @@ module Autoproj
|
|
252
244
|
end
|
253
245
|
installed_version = installed.map(&:version).max
|
254
246
|
available_version = available.map { |_, v| v }.max
|
255
|
-
|
247
|
+
unless available_version
|
256
248
|
if version
|
257
249
|
raise ConfigError.new, "cannot find any gem with the name '#{name}' and version #{version}"
|
258
250
|
else
|
@@ -288,22 +280,22 @@ module Autoproj
|
|
288
280
|
# We're not supposed to install rubygem packages but silent is not
|
289
281
|
# set, so display information about them anyway
|
290
282
|
puts <<-EOMSG
|
291
|
-
#{Autoproj.color(
|
292
|
-
#{Autoproj.color(
|
283
|
+
#{Autoproj.color('The build process and/or the packages require some Ruby Gems to be installed', :bold)}
|
284
|
+
#{Autoproj.color('and you required autoproj to not do it itself', :bold)}
|
293
285
|
You can use the --all or --ruby options to autoproj osdeps to install these
|
294
286
|
packages anyway, and/or change to the osdeps handling mode by running an
|
295
287
|
autoproj operation with the --reconfigure option as for instance
|
296
288
|
autoproj build --reconfigure
|
297
|
-
|
289
|
+
#{' '}
|
298
290
|
The following command line can be used to install them manually
|
299
|
-
|
300
|
-
#{cmdlines.map { |c| c.join(
|
301
|
-
|
291
|
+
#{' '}
|
292
|
+
#{cmdlines.map { |c| c.join(' ') }.join("\n ")}
|
293
|
+
#{' '}
|
302
294
|
Autoproj expects these Gems to be installed in #{GemManager.gem_home} This can
|
303
295
|
be overridden by setting the AUTOPROJ_GEM_HOME environment variable manually
|
304
296
|
|
305
297
|
EOMSG
|
306
|
-
print " #{Autoproj.color(
|
298
|
+
print " #{Autoproj.color('Press ENTER to continue ', :bold)}"
|
307
299
|
|
308
300
|
STDOUT.flush
|
309
301
|
STDIN.readline
|
@@ -313,4 +305,3 @@ module Autoproj
|
|
313
305
|
end
|
314
306
|
end
|
315
307
|
end
|
316
|
-
|
@@ -5,8 +5,8 @@ module Autoproj
|
|
5
5
|
class HomebrewManager < ShellScriptManager
|
6
6
|
def initialize(ws)
|
7
7
|
super(ws, true,
|
8
|
-
%w
|
9
|
-
%w
|
8
|
+
%w[brew install],
|
9
|
+
%w[brew install],
|
10
10
|
false)
|
11
11
|
end
|
12
12
|
|
@@ -16,7 +16,7 @@ module Autoproj
|
|
16
16
|
packages = packages.uniq
|
17
17
|
command_line = "brew info --json=v1 #{packages.join(' ')}"
|
18
18
|
result = Autoproj.bundler_with_unbundled_env do
|
19
|
-
(Autobuild::Subprocess.run
|
19
|
+
(Autobuild::Subprocess.run "autoproj", "osdeps", command_line).first
|
20
20
|
end
|
21
21
|
|
22
22
|
begin
|
@@ -53,4 +53,3 @@ module Autoproj
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
@@ -11,10 +11,16 @@ module Autoproj
|
|
11
11
|
attr_reader :ws
|
12
12
|
|
13
13
|
attr_writer :enabled
|
14
|
-
|
14
|
+
|
15
|
+
def enabled?
|
16
|
+
!!@enabled
|
17
|
+
end
|
15
18
|
|
16
19
|
attr_writer :silent
|
17
|
-
|
20
|
+
|
21
|
+
def silent?
|
22
|
+
!!@silent
|
23
|
+
end
|
18
24
|
|
19
25
|
# Whether this package manager should be called even if no packages
|
20
26
|
# should be installed
|
@@ -68,4 +74,3 @@ module Autoproj
|
|
68
74
|
end
|
69
75
|
end
|
70
76
|
end
|
71
|
-
|
@@ -5,10 +5,9 @@ module Autoproj
|
|
5
5
|
class PacmanManager < ShellScriptManager
|
6
6
|
def initialize(ws)
|
7
7
|
super(ws, true,
|
8
|
-
%w
|
9
|
-
%w
|
8
|
+
%w[pacman -Sy --needed],
|
9
|
+
%w[pacman -Sy --needed --noconfirm])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "autoproj/python"
|
2
2
|
|
3
3
|
module Autoproj
|
4
4
|
module PackageManagers
|
@@ -7,14 +7,14 @@ module Autoproj
|
|
7
7
|
attr_reader :installed_pips
|
8
8
|
|
9
9
|
def initialize_environment
|
10
|
-
ws.env.set
|
11
|
-
ws.env.add_path
|
10
|
+
ws.env.set "PYTHONUSERBASE", pip_home
|
11
|
+
ws.env.add_path "PATH", File.join(pip_home, "bin")
|
12
12
|
end
|
13
13
|
|
14
14
|
# Return the directory where python packages are installed to.
|
15
15
|
# The actual path is pip_home/lib/pythonx.y/site-packages.
|
16
16
|
def pip_home
|
17
|
-
ws.env[
|
17
|
+
ws.env["AUTOPROJ_PYTHONUSERBASE"] || File.join(ws.prefix_dir, "pip")
|
18
18
|
end
|
19
19
|
|
20
20
|
def initialize(ws)
|
@@ -23,43 +23,42 @@ module Autoproj
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def os_dependencies
|
26
|
-
super + [
|
26
|
+
super + ["pip"]
|
27
27
|
end
|
28
28
|
|
29
29
|
def guess_pip_program
|
30
|
-
unless ws.config.has_value_for?(
|
31
|
-
|
30
|
+
unless ws.config.has_value_for?("USE_PYTHON")
|
31
|
+
Autoproj::Python.setup_python_configuration_options(ws: ws)
|
32
32
|
end
|
33
|
-
unless ws.config.get(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
unless ws.config.get("USE_PYTHON")
|
34
|
+
raise ConfigError,
|
35
|
+
"Your current package selection requires the use of pip, but" \
|
36
|
+
" the use of python is either unspecified or has been denied,"\
|
37
|
+
" see setting of USE_PYTHON in your workspace configuration." \
|
38
|
+
" Either remove all packages depending on pip packages " \
|
39
|
+
" from the workspace layout (manifest) or " \
|
40
|
+
" call 'autoproj reconfigure' to change the setting."
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
Autobuild.programs[
|
45
|
-
Autobuild.programs[
|
44
|
+
Autobuild.programs["pip"] = "pip" unless Autobuild.programs["pip"]
|
45
|
+
Autobuild.programs["pip"]
|
46
46
|
end
|
47
47
|
|
48
|
-
# rubocop:disable Lint/UnusedMethodArgument
|
49
48
|
def install(pips, filter_uptodate_packages: false, install_only: false)
|
50
49
|
guess_pip_program
|
51
50
|
pips = [pips] if pips.is_a?(String)
|
52
51
|
|
53
|
-
base_cmdline = [Autobuild.tool(
|
52
|
+
base_cmdline = [Autobuild.tool("pip"), "install", "--user"]
|
54
53
|
|
55
54
|
cmdlines = [base_cmdline + pips]
|
56
55
|
|
57
56
|
if pips_interaction(cmdlines)
|
58
57
|
Autoproj.message " installing/updating Python dependencies:" \
|
59
|
-
|
58
|
+
" #{pips.sort.join(', ')}"
|
60
59
|
|
61
60
|
cmdlines.each do |c|
|
62
|
-
Autobuild::Subprocess.run
|
61
|
+
Autobuild::Subprocess.run "autoproj", "osdeps", *c,
|
63
62
|
env: ws.env.resolved_env
|
64
63
|
end
|
65
64
|
|
@@ -68,7 +67,6 @@ module Autoproj
|
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
71
|
-
# rubocop:enable Lint/UnusedMethodArgument
|
72
70
|
|
73
71
|
def pips_interaction(cmdlines)
|
74
72
|
if OSPackageInstaller.force_osdeps
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module Autoproj
|
2
2
|
module PackageManagers
|
3
|
-
|
3
|
+
# Package manager interface for systems that use pkg (i.e. FreeBSD) as
|
4
4
|
# their package manager
|
5
5
|
class PkgManager < ShellScriptManager
|
6
6
|
def initialize(ws)
|
7
7
|
super(ws, true,
|
8
|
-
%w
|
9
|
-
%w
|
8
|
+
%w[pkg install -y],
|
9
|
+
%w[pkg install -y])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
@@ -5,31 +5,30 @@ module Autoproj
|
|
5
5
|
class ShellScriptManager < Manager
|
6
6
|
def self.execute(command_line, with_locking, with_root, env: Autobuild.env)
|
7
7
|
if with_locking
|
8
|
-
File.open(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sleep 5
|
15
|
-
end
|
16
|
-
return execute(command_line, false, with_root, env: env)
|
17
|
-
ensure
|
18
|
-
lock_io.flock(File::LOCK_UN)
|
8
|
+
File.open("/tmp/autoproj_osdeps_lock", "w") do |lock_io|
|
9
|
+
until lock_io.flock(File::LOCK_EX | File::LOCK_NB)
|
10
|
+
Autoproj.message " waiting for other autoproj "\
|
11
|
+
"instances to finish their osdeps "\
|
12
|
+
"installation"
|
13
|
+
sleep 5
|
19
14
|
end
|
15
|
+
return execute(command_line, false, with_root, env: env)
|
16
|
+
ensure
|
17
|
+
lock_io.flock(File::LOCK_UN)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
21
|
if with_root
|
24
|
-
sudo = Autobuild.tool_in_path(
|
22
|
+
sudo = Autobuild.tool_in_path("sudo", env: env)
|
25
23
|
command_line = [sudo, *command_line]
|
26
24
|
end
|
27
25
|
|
28
|
-
Autobuild::Subprocess.run
|
26
|
+
Autobuild::Subprocess.run "autoproj", "osdeps", *command_line
|
29
27
|
end
|
30
28
|
|
31
29
|
# Overrides the {#needs_locking?} flag
|
32
30
|
attr_writer :needs_locking
|
31
|
+
|
33
32
|
# Whether two autoproj instances can run this package manager at the
|
34
33
|
# same time
|
35
34
|
#
|
@@ -45,6 +44,7 @@ module Autoproj
|
|
45
44
|
|
46
45
|
# Overrides the {#needs_root?} flag
|
47
46
|
attr_writer :needs_root
|
47
|
+
|
48
48
|
# Whether this package manager needs root access.
|
49
49
|
#
|
50
50
|
# This declares if the command line(s) for this package manager
|
@@ -90,7 +90,7 @@ module Autoproj
|
|
90
90
|
# @param [Boolean] needs_root if the command lines should be started
|
91
91
|
# as root or not. See {#needs_root?}
|
92
92
|
def initialize(ws, needs_locking, user_install_cmd,
|
93
|
-
|
93
|
+
auto_install_cmd, needs_root = true)
|
94
94
|
super(ws)
|
95
95
|
@needs_locking = needs_locking
|
96
96
|
@user_install_cmd = user_install_cmd
|
@@ -108,10 +108,11 @@ module Autoproj
|
|
108
108
|
# If given, it overrides the default value stored in
|
109
109
|
# {#user_install_cmd]
|
110
110
|
def generate_user_os_script(os_packages,
|
111
|
-
|
111
|
+
user_install_cmd: self.user_install_cmd)
|
112
112
|
if user_install_cmd
|
113
|
-
user_install_cmd
|
114
|
-
else
|
113
|
+
generate_script(user_install_cmd, os_packages)
|
114
|
+
else
|
115
|
+
generate_auto_os_script(os_packages)
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
@@ -125,8 +126,15 @@ module Autoproj
|
|
125
126
|
# If given, it overrides the default value stored in
|
126
127
|
# {#auto_install_cmd]
|
127
128
|
def generate_auto_os_script(os_packages,
|
128
|
-
|
129
|
-
auto_install_cmd
|
129
|
+
auto_install_cmd: self.auto_install_cmd)
|
130
|
+
generate_script(auto_install_cmd, os_packages)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Helper for {#generate_user_os_script} and {#generate_auto_os_script}
|
134
|
+
def generate_script(cmd, args)
|
135
|
+
cmd = cmd.join(" ")
|
136
|
+
args = args.join("' '")
|
137
|
+
"#{cmd} #{args}"
|
130
138
|
end
|
131
139
|
|
132
140
|
# Handles interaction with the user
|
@@ -152,7 +160,9 @@ module Autoproj
|
|
152
160
|
|
153
161
|
#{Autoproj.color('The build process and/or the packages require some other software to be installed', :bold)}
|
154
162
|
#{Autoproj.color('and you required autoproj to not install them itself', :bold)}
|
155
|
-
#{
|
163
|
+
#{unless respond_to?(:filter_uptodate_packages)
|
164
|
+
Autoproj.color('\nIf these packages are already installed, simply ignore this message\n', :red)
|
165
|
+
end}
|
156
166
|
The following packages are available as OS dependencies, i.e. as prebuilt
|
157
167
|
packages provided by your distribution / operating system. You will have to
|
158
168
|
install them manually if they are not already installed
|
@@ -183,8 +193,8 @@ module Autoproj
|
|
183
193
|
# packages. See the option in {#generate_auto_os_script}
|
184
194
|
# @return [Boolean] true if packages got installed, false otherwise
|
185
195
|
def install(packages, filter_uptodate_packages: false, install_only: false,
|
186
|
-
|
187
|
-
|
196
|
+
auto_install_cmd: self.auto_install_cmd,
|
197
|
+
user_install_cmd: self.user_install_cmd)
|
188
198
|
return if packages.empty?
|
189
199
|
|
190
200
|
handled_os = ws.supported_operating_system?
|
@@ -10,8 +10,8 @@ module Autoproj
|
|
10
10
|
|
11
11
|
def osdeps_interaction_unknown_os(osdeps)
|
12
12
|
puts <<-EOMSG
|
13
|
-
#{Autoproj.color(
|
14
|
-
#{Autoproj.color(
|
13
|
+
#{Autoproj.color('The build process requires some other software packages to be installed on our operating system', :bold)}
|
14
|
+
#{Autoproj.color('If they are already installed, simply ignore this message', :red)}
|
15
15
|
|
16
16
|
#{osdeps.to_a.sort.join("\n ")}
|
17
17
|
|
@@ -25,18 +25,15 @@ module Autoproj
|
|
25
25
|
|
26
26
|
def install(osdeps)
|
27
27
|
if silent?
|
28
|
-
|
28
|
+
false
|
29
29
|
else
|
30
30
|
osdeps = osdeps.to_set
|
31
31
|
osdeps -= @installed_osdeps
|
32
|
-
|
33
|
-
result = osdeps_interaction_unknown_os(osdeps)
|
34
|
-
end
|
32
|
+
result = osdeps_interaction_unknown_os(osdeps) unless osdeps.empty?
|
35
33
|
@installed_osdeps |= osdeps
|
36
|
-
|
34
|
+
result
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
42
|
-
|