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
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "open3"
|
4
|
+
require "pathname"
|
5
|
+
require "open-uri"
|
6
6
|
|
7
7
|
module Autoproj
|
8
8
|
module RepositoryManagers
|
@@ -13,14 +13,14 @@ module Autoproj
|
|
13
13
|
attr_reader :sources_dir
|
14
14
|
attr_reader :autoproj_sources
|
15
15
|
|
16
|
-
SOURCES_DIR =
|
17
|
-
SOURCE_TYPES = [
|
18
|
-
AUTOPROJ_SOURCES =
|
16
|
+
SOURCES_DIR = "/etc/apt".freeze
|
17
|
+
SOURCE_TYPES = %w[deb deb-src].freeze
|
18
|
+
AUTOPROJ_SOURCES = "/etc/apt/sources.list.d/autoproj.list".freeze
|
19
19
|
|
20
20
|
def initialize(ws, sources_dir: SOURCES_DIR, autoproj_sources: AUTOPROJ_SOURCES)
|
21
21
|
@sources_dir = sources_dir
|
22
22
|
@autoproj_sources = autoproj_sources
|
23
|
-
@source_files = Dir[File.join(sources_dir,
|
23
|
+
@source_files = Dir[File.join(sources_dir, "**", "*.list")]
|
24
24
|
@source_entries = {}
|
25
25
|
|
26
26
|
source_files.each { |file| load_sources_from_file(file) }
|
@@ -28,7 +28,7 @@ module Autoproj
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def os_dependencies
|
31
|
-
super + [
|
31
|
+
super + %w[archive-keyring gnupg apt-transport-https]
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_sources_from_file(file)
|
@@ -45,16 +45,16 @@ module Autoproj
|
|
45
45
|
entry = {}
|
46
46
|
entry[:valid] = false
|
47
47
|
entry[:enabled] = true
|
48
|
-
entry[:source] =
|
49
|
-
entry[:comment] =
|
48
|
+
entry[:source] = ""
|
49
|
+
entry[:comment] = ""
|
50
50
|
|
51
51
|
line.strip!
|
52
|
-
if line.start_with?(
|
52
|
+
if line.start_with?("#")
|
53
53
|
entry[:enabled] = false
|
54
54
|
line = line[1..-1]
|
55
55
|
end
|
56
56
|
|
57
|
-
i = line.index(
|
57
|
+
i = line.index("#")
|
58
58
|
if i&.positive?
|
59
59
|
entry[:comment] = line[(i + 1)..-1].strip
|
60
60
|
line = line[0..(i - 1)]
|
@@ -63,7 +63,7 @@ module Autoproj
|
|
63
63
|
entry[:source] = line.strip
|
64
64
|
chunks = entry[:source].split
|
65
65
|
entry[:valid] = true if SOURCE_TYPES.include?(chunks[0])
|
66
|
-
entry[:source] = chunks.join(
|
66
|
+
entry[:source] = chunks.join(" ")
|
67
67
|
|
68
68
|
if raise_if_invalid && (!entry[:valid] || !entry[:enabled])
|
69
69
|
raise ConfigError, "Invalid source line: #{entry[:source]}"
|
@@ -74,7 +74,7 @@ module Autoproj
|
|
74
74
|
|
75
75
|
def add_source(source, file = nil)
|
76
76
|
file = if file
|
77
|
-
File.join(sources_dir,
|
77
|
+
File.join(sources_dir, "sources.list.d", file)
|
78
78
|
else
|
79
79
|
autoproj_sources
|
80
80
|
end
|
@@ -95,8 +95,8 @@ module Autoproj
|
|
95
95
|
|
96
96
|
def append_entry(contents, entry)
|
97
97
|
unless entry[:enabled]
|
98
|
-
contents <<
|
99
|
-
contents <<
|
98
|
+
contents << "#"
|
99
|
+
contents << " " unless entry[:source].start_with?("#")
|
100
100
|
end
|
101
101
|
|
102
102
|
contents << entry[:source]
|
@@ -105,17 +105,17 @@ module Autoproj
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def enable_entry_in_file(file, enable_entry)
|
108
|
-
contents =
|
108
|
+
contents = ""
|
109
109
|
source_entries[file].each do |entry|
|
110
110
|
entry[:enabled] = true if enable_entry[:source] == entry[:source]
|
111
111
|
append_entry(contents, entry)
|
112
112
|
end
|
113
|
-
run_tee_command([
|
113
|
+
run_tee_command(["sudo", "tee", file], contents)
|
114
114
|
true
|
115
115
|
end
|
116
116
|
|
117
117
|
def add_entry_to_file(file, entry)
|
118
|
-
run_tee_command([
|
118
|
+
run_tee_command(["sudo", "tee", "-a", file], entry[:source])
|
119
119
|
@source_entries[file] ||= []
|
120
120
|
@source_entries[file] << entry
|
121
121
|
true
|
@@ -123,7 +123,7 @@ module Autoproj
|
|
123
123
|
|
124
124
|
def run_tee_command(command, contents)
|
125
125
|
contents = StringIO.new("#{contents}\n")
|
126
|
-
Autobuild::Subprocess.run(
|
126
|
+
Autobuild::Subprocess.run("autoproj", "osrepos", *command, input_streams: [contents])
|
127
127
|
end
|
128
128
|
|
129
129
|
def entry_exist?(new_entry)
|
@@ -140,7 +140,7 @@ module Autoproj
|
|
140
140
|
|
141
141
|
def key_exist?(key)
|
142
142
|
exist = false
|
143
|
-
Open3.popen3({
|
143
|
+
Open3.popen3({ "LANG" => "C" }, "apt-key", "export", key) do |_, _, stderr, wait_thr|
|
144
144
|
success = wait_thr.value.success?
|
145
145
|
stderr = stderr.read
|
146
146
|
has_error = stderr.match(/WARNING: nothing exported/)
|
@@ -151,36 +151,36 @@ module Autoproj
|
|
151
151
|
|
152
152
|
def apt_update
|
153
153
|
Autobuild::Subprocess.run(
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
154
|
+
"autoproj",
|
155
|
+
"osrepos",
|
156
|
+
"sudo",
|
157
|
+
"apt-get",
|
158
|
+
"update"
|
159
159
|
)
|
160
160
|
end
|
161
161
|
|
162
162
|
def add_apt_key(id, origin, type: :keyserver)
|
163
163
|
if type == :keyserver
|
164
164
|
Autobuild::Subprocess.run(
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
165
|
+
"autoproj",
|
166
|
+
"osrepos",
|
167
|
+
"sudo",
|
168
|
+
"apt-key",
|
169
|
+
"adv",
|
170
|
+
"--keyserver",
|
171
171
|
origin,
|
172
|
-
|
172
|
+
"--recv-key",
|
173
173
|
id
|
174
174
|
)
|
175
175
|
else
|
176
176
|
open(origin) do |io|
|
177
177
|
Autobuild::Subprocess.run(
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
178
|
+
"autoproj",
|
179
|
+
"osrepos",
|
180
|
+
"sudo",
|
181
|
+
"apt-key",
|
182
|
+
"add",
|
183
|
+
"-",
|
184
184
|
input_streams: [io]
|
185
185
|
)
|
186
186
|
end
|
@@ -191,24 +191,24 @@ module Autoproj
|
|
191
191
|
|
192
192
|
def filter_installed_definitions(definitions)
|
193
193
|
definitions = definitions.dup.reject do |definition|
|
194
|
-
if definition[
|
195
|
-
_, entry = source_exist?(definition[
|
194
|
+
if definition["type"] == "repo"
|
195
|
+
_, entry = source_exist?(definition["repo"])
|
196
196
|
entry && entry[:enabled]
|
197
197
|
else
|
198
|
-
key_exist?(definition[
|
198
|
+
key_exist?(definition["id"])
|
199
199
|
end
|
200
200
|
end
|
201
201
|
definitions
|
202
202
|
end
|
203
203
|
|
204
204
|
def print_installing_definitions(definitions)
|
205
|
-
repos = definitions.select { |definition| definition[
|
206
|
-
keys = definitions.select { |definition| definition[
|
205
|
+
repos = definitions.select { |definition| definition["type"] == "repo" }
|
206
|
+
keys = definitions.select { |definition| definition["type"] == "key" }
|
207
207
|
|
208
208
|
unless repos.empty?
|
209
|
-
Autoproj.message
|
209
|
+
Autoproj.message " adding apt repositories:"
|
210
210
|
repos.each do |repo|
|
211
|
-
if repo[
|
211
|
+
if repo["file"]
|
212
212
|
Autoproj.message " #{repo['repo']}, file: #{repo['file']}"
|
213
213
|
else
|
214
214
|
Autoproj.message " #{repo['repo']}"
|
@@ -217,9 +217,9 @@ module Autoproj
|
|
217
217
|
end
|
218
218
|
return if keys.empty?
|
219
219
|
|
220
|
-
Autoproj.message
|
220
|
+
Autoproj.message " adding apt keys:"
|
221
221
|
keys.each do |key|
|
222
|
-
if key[
|
222
|
+
if key["keyserver"]
|
223
223
|
Autoproj.message " id: #{key['id']}, keyserver: #{key['keyserver']}"
|
224
224
|
else
|
225
225
|
Autoproj.message " id: #{key['id']}, url: #{key['url']}"
|
@@ -249,27 +249,61 @@ module Autoproj
|
|
249
249
|
# url: 'http://packages.osrfoundation.org/gazebo.key'
|
250
250
|
#
|
251
251
|
def validate_definitions(definitions)
|
252
|
-
invalid_string = 'Invalid apt repository definition'
|
253
252
|
definitions.each do |definition|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
raise ConfigError, "#{invalid_string}: 'file' should be a String" if definition['file'] && !definition['file'].is_a?(String)
|
260
|
-
if definition['file'] && Pathname.new(definition['file']).absolute?
|
261
|
-
raise ConfigError, "#{invalid_string}: 'file' should be a relative to #{File.join(SOURCES_DIR, 'sources.list.d')}"
|
262
|
-
end
|
253
|
+
case definition["type"]
|
254
|
+
when "repo"
|
255
|
+
validate_repo_definition(definition)
|
256
|
+
when "key"
|
257
|
+
validate_key_definition(definition)
|
263
258
|
else
|
264
|
-
raise ConfigError,
|
265
|
-
|
266
|
-
raise ConfigError, "#{invalid_string}: 'url' conflicts with 'keyserver'" if definition['url'] && definition['keyserver']
|
267
|
-
raise ConfigError, "#{invalid_string}: 'url' should be a String" if definition['url'] && !definition['url'].is_a?(String)
|
268
|
-
raise ConfigError, "#{invalid_string}: 'keyserver' should be a String" if definition['keyserver'] && !definition['keyserver'].is_a?(String)
|
259
|
+
raise ConfigError,
|
260
|
+
"#{INVALID_REPO_MESSAGE} type: #{definition['type']}"
|
269
261
|
end
|
270
262
|
end
|
271
263
|
end
|
272
264
|
|
265
|
+
INVALID_REPO_MESSAGE = "Invalid apt repository definition".freeze
|
266
|
+
|
267
|
+
# rubocop:disable Style/GuardClause
|
268
|
+
|
269
|
+
def validate_repo_definition(definition)
|
270
|
+
if definition["repo"].nil?
|
271
|
+
raise ConfigError, "#{INVALID_REPO_MESSAGE}: 'repo' key missing"
|
272
|
+
elsif !definition["repo"].is_a?(String)
|
273
|
+
raise ConfigError,
|
274
|
+
"#{INVALID_REPO_MESSAGE}: 'repo' should be a String"
|
275
|
+
elsif definition["file"] && !definition["file"].is_a?(String)
|
276
|
+
raise ConfigError,
|
277
|
+
"#{INVALID_REPO_MESSAGE}: 'file' should be a String"
|
278
|
+
elsif definition["file"] && Pathname.new(definition["file"]).absolute?
|
279
|
+
raise ConfigError,
|
280
|
+
"#{INVALID_REPO_MESSAGE}: 'file' should be relative "\
|
281
|
+
"to #{File.join(SOURCES_DIR, 'sources.list.d')}"
|
282
|
+
end
|
283
|
+
|
284
|
+
nil
|
285
|
+
end
|
286
|
+
|
287
|
+
def validate_key_definition(definition)
|
288
|
+
if definition["id"].nil?
|
289
|
+
raise ConfigError, "#{INVALID_REPO_MESSAGE}: 'id' key missing"
|
290
|
+
elsif !definition["id"].is_a?(String)
|
291
|
+
raise ConfigError, "#{INVALID_REPO_MESSAGE}: 'id' should be a String"
|
292
|
+
elsif definition["url"] && definition["keyserver"]
|
293
|
+
raise ConfigError,
|
294
|
+
"#{INVALID_REPO_MESSAGE}: 'url' conflicts with 'keyserver'"
|
295
|
+
elsif definition["url"] && !definition["url"].is_a?(String)
|
296
|
+
raise ConfigError, "#{INVALID_REPO_MESSAGE}: 'url' should be a String"
|
297
|
+
elsif definition["keyserver"] && !definition["keyserver"].is_a?(String)
|
298
|
+
raise ConfigError,
|
299
|
+
"#{INVALID_REPO_MESSAGE}: 'keyserver' should be a String"
|
300
|
+
end
|
301
|
+
|
302
|
+
nil
|
303
|
+
end
|
304
|
+
|
305
|
+
# rubocop:enable Style/GuardClause
|
306
|
+
|
273
307
|
def install(definitions)
|
274
308
|
super
|
275
309
|
validate_definitions(definitions)
|
@@ -277,12 +311,12 @@ module Autoproj
|
|
277
311
|
print_installing_definitions(definitions)
|
278
312
|
|
279
313
|
definitions.each do |definition|
|
280
|
-
if definition[
|
281
|
-
add_source(definition[
|
314
|
+
if definition["type"] == "repo"
|
315
|
+
add_source(definition["repo"], definition["file"])
|
282
316
|
else
|
283
|
-
type = definition[
|
317
|
+
type = definition["url"] ? "url" : "keyserver"
|
284
318
|
origin = definition[type]
|
285
|
-
add_apt_key(definition[
|
319
|
+
add_apt_key(definition["id"], origin, type: type.to_sym)
|
286
320
|
end
|
287
321
|
end
|
288
322
|
apt_update unless definitions.empty?
|
@@ -9,9 +9,9 @@ module Autoproj
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def osrepos_interaction_unknown_os
|
12
|
-
Autoproj.message
|
13
|
-
Autoproj.message
|
14
|
-
Autoproj.message
|
12
|
+
Autoproj.message "The build process requires some repositories to be added on our operating system", :bold
|
13
|
+
Autoproj.message "If they are already added, simply ignore this message", :bold
|
14
|
+
Autoproj.message "Press ENTER to continue ", :bold
|
15
15
|
|
16
16
|
STDIN.readline
|
17
17
|
nil
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "autoproj/cli/main"
|
2
|
+
require "erb"
|
3
3
|
|
4
4
|
module Autoproj
|
5
5
|
# Generates shell completion for code for a given Thor subclass
|
@@ -11,14 +11,15 @@ module Autoproj
|
|
11
11
|
# A hash describing the CLI
|
12
12
|
attr_reader :cli_metadata
|
13
13
|
|
14
|
-
TEMPLATES_DIR = File.join(File.dirname(__FILE__),
|
14
|
+
TEMPLATES_DIR = File.join(File.dirname(__FILE__), "templates")
|
15
15
|
|
16
|
-
def initialize(name =
|
16
|
+
def initialize(name = "autoproj", cli: Autoproj::CLI::Main, command: nil)
|
17
17
|
@cli = cli
|
18
18
|
@name = name
|
19
19
|
|
20
20
|
generate_metadata
|
21
21
|
return unless command
|
22
|
+
|
22
23
|
@cli_metadata = subcommand_by_name(*command)
|
23
24
|
@cli_metadata[:name] = "__#{name}"
|
24
25
|
end
|
@@ -48,8 +49,8 @@ module Autoproj
|
|
48
49
|
# leaving disabled for now
|
49
50
|
# TODO: log subcommand needs a custom completer,
|
50
51
|
# leaving disabled for now
|
51
|
-
[
|
52
|
-
|
52
|
+
["bootstrap", "envsh", "reconfigure", "reset", "log", "query",
|
53
|
+
"switch-config", %w[global register], %w[global status],
|
53
54
|
%w[plugin install], %w[plugin remove], %w[plugin list]].each do |command|
|
54
55
|
disable_completion(subcommand_by_name(*command))
|
55
56
|
end
|
@@ -58,7 +59,7 @@ module Autoproj
|
|
58
59
|
def generate
|
59
60
|
template_file = File.join(TEMPLATES_DIR, self.class::MAIN_FUNCTION_TEMPLATE)
|
60
61
|
erb = File.read(template_file)
|
61
|
-
::ERB.new(erb, nil,
|
62
|
+
::ERB.new(erb, nil, "-").result(binding)
|
62
63
|
end
|
63
64
|
|
64
65
|
def subcommand_by_name(*name, metadata: cli_metadata)
|
@@ -73,7 +74,7 @@ module Autoproj
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def populate_help_subcommands(command_metadata = cli_metadata)
|
76
|
-
help_subcommand = subcommand_by_name(
|
77
|
+
help_subcommand = subcommand_by_name("help",
|
77
78
|
metadata: command_metadata)
|
78
79
|
|
79
80
|
if help_subcommand
|
@@ -82,9 +83,11 @@ module Autoproj
|
|
82
83
|
end
|
83
84
|
|
84
85
|
command_metadata[:subcommands].each do |subcommand|
|
85
|
-
next if subcommand[:name] ==
|
86
|
+
next if subcommand[:name] == "help"
|
87
|
+
|
86
88
|
populate_help_subcommands(subcommand)
|
87
89
|
next unless help_subcommand
|
90
|
+
|
88
91
|
help_subcommand[:subcommands] << { name: subcommand[:name],
|
89
92
|
aliases: [],
|
90
93
|
description: subcommand[:description],
|
@@ -98,17 +101,17 @@ module Autoproj
|
|
98
101
|
source = []
|
99
102
|
|
100
103
|
prefix = (prefix + [subcommand[:name]])
|
101
|
-
function_name = prefix.join(
|
104
|
+
function_name = prefix.join("_")
|
102
105
|
depth = prefix.size + 1
|
103
106
|
|
104
107
|
template_file = File.join(TEMPLATES_DIR, self.class::SUBCOMMAND_FUNCTION_TEMPLATE)
|
105
|
-
erb = ::ERB.new(File.read(template_file), nil,
|
108
|
+
erb = ::ERB.new(File.read(template_file), nil, "-")
|
106
109
|
|
107
110
|
source << erb.result(binding)
|
108
111
|
subcommand[:subcommands].each do |subcommand|
|
109
112
|
source << render_subcommand_function(subcommand, prefix: prefix)
|
110
113
|
end
|
111
|
-
source.join("\n").strip
|
114
|
+
"#{source.join("\n").strip}\n"
|
112
115
|
end
|
113
116
|
|
114
117
|
def subcommand_metadata(cli)
|
@@ -158,7 +161,7 @@ module Autoproj
|
|
158
161
|
end
|
159
162
|
|
160
163
|
def hyphenate(s)
|
161
|
-
s.to_s.tr(
|
164
|
+
s.to_s.tr("_", "-")
|
162
165
|
end
|
163
166
|
end
|
164
167
|
end
|
@@ -29,18 +29,18 @@ module Autoproj
|
|
29
29
|
#
|
30
30
|
class SourcePackageQuery < QueryBase
|
31
31
|
ALLOWED_FIELDS = [
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
"autobuild.name",
|
33
|
+
"autobuild.srcdir",
|
34
|
+
"autobuild.class.name",
|
35
|
+
"vcs.type",
|
36
|
+
"vcs.url",
|
37
|
+
"package_set.name"
|
38
38
|
]
|
39
39
|
DEFAULT_FIELDS = {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
"name" => "autobuild.name",
|
41
|
+
"class" => "autobuild.class.name",
|
42
|
+
"vcs" => "vcs.url",
|
43
|
+
"package_set" => "package_set.name"
|
44
44
|
}
|
45
45
|
|
46
46
|
# Match priorities
|
@@ -52,18 +52,18 @@ module Autoproj
|
|
52
52
|
def initialize(fields, value, partial)
|
53
53
|
super(fields, value, partial)
|
54
54
|
|
55
|
-
directories = value.split(
|
56
|
-
|
55
|
+
directories = value.split("/")
|
56
|
+
unless directories.empty?
|
57
57
|
@use_dir_prefix = true
|
58
|
-
rx = directories
|
59
|
-
|
60
|
-
|
58
|
+
rx = directories
|
59
|
+
.map { |d| "#{Regexp.quote(d)}\\w*" }
|
60
|
+
.join("/")
|
61
61
|
rx = Regexp.new(rx, true)
|
62
62
|
@dir_prefix_weak_rx = rx
|
63
63
|
|
64
|
-
rx_strict = directories[0..-2]
|
65
|
-
|
66
|
-
|
64
|
+
rx_strict = directories[0..-2]
|
65
|
+
.map { |d| "#{Regexp.quote(d)}\\w*" }
|
66
|
+
.join("/")
|
67
67
|
rx_strict = Regexp.new("#{rx_strict}/#{Regexp.quote(directories.last)}$", true)
|
68
68
|
@dir_prefix_strong_rx = rx_strict
|
69
69
|
end
|
@@ -95,38 +95,32 @@ module Autoproj
|
|
95
95
|
pkg_value = fields.inject(pkg) { |v, field_name| v.send(field_name) }
|
96
96
|
pkg_value = pkg_value.to_s
|
97
97
|
|
98
|
-
if pkg_value == value
|
99
|
-
return EXACT
|
100
|
-
end
|
98
|
+
return EXACT if pkg_value == value
|
101
99
|
|
102
|
-
|
103
|
-
return
|
104
|
-
end
|
100
|
+
return unless partial?
|
105
101
|
|
106
|
-
if @value_rx === pkg_value
|
107
|
-
return PARTIAL
|
108
|
-
end
|
102
|
+
return PARTIAL if @value_rx === pkg_value
|
109
103
|
|
110
104
|
# Special match for directories: match directory prefixes
|
111
105
|
if use_dir_prefix?
|
112
106
|
if @dir_prefix_strong_rx === pkg_value
|
113
|
-
|
107
|
+
DIR_PREFIX_STRONG
|
114
108
|
elsif @dir_prefix_weak_rx === pkg_value
|
115
|
-
|
109
|
+
DIR_PREFIX_WEAK
|
116
110
|
end
|
117
111
|
end
|
118
112
|
end
|
119
113
|
|
120
114
|
# Parse a single field in a query (i.e. a FIELD[=~]VALUE string)
|
121
115
|
def self.parse(str)
|
122
|
-
if str
|
123
|
-
match_name = parse("autobuild.name~#{str}")
|
124
|
-
match_dir = parse("autobuild.srcdir~#{str}")
|
125
|
-
return Or.new([match_name, match_dir])
|
126
|
-
else
|
116
|
+
if str =~ /[=~]/
|
127
117
|
fields, value, partial =
|
128
118
|
super(str, default_fields: DEFAULT_FIELDS, allowed_fields: ALLOWED_FIELDS)
|
129
|
-
|
119
|
+
new(fields, value, partial)
|
120
|
+
else
|
121
|
+
match_name = parse("autobuild.name~#{str}")
|
122
|
+
match_dir = parse("autobuild.srcdir~#{str}")
|
123
|
+
Or.new([match_name, match_dir])
|
130
124
|
end
|
131
125
|
end
|
132
126
|
end
|
@@ -134,4 +128,3 @@ module Autoproj
|
|
134
128
|
# For backward compatibility
|
135
129
|
Query = SourcePackageQuery
|
136
130
|
end
|
137
|
-
|