autoproj 1.13.7 → 2.0.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gemtest +0 -0
- data/Manifest.txt +27 -21
- data/Rakefile +4 -6
- data/bin/alocate +5 -1
- data/bin/amake +3 -53
- data/bin/aup +3 -50
- data/bin/autoproj +3 -264
- data/bin/autoproj_bootstrap +294 -349
- data/bin/autoproj_bootstrap.in +27 -3
- data/lib/autoproj.rb +23 -1
- data/lib/autoproj/autobuild.rb +51 -89
- data/lib/autoproj/base.rb +0 -9
- data/lib/autoproj/build_option.rb +1 -3
- data/lib/autoproj/cli.rb +1 -0
- data/lib/autoproj/cli/base.rb +155 -0
- data/lib/autoproj/cli/bootstrap.rb +119 -0
- data/lib/autoproj/cli/build.rb +72 -0
- data/lib/autoproj/cli/cache.rb +31 -0
- data/lib/autoproj/cli/clean.rb +37 -0
- data/lib/autoproj/cli/commit.rb +41 -0
- data/lib/autoproj/cli/doc.rb +22 -0
- data/lib/autoproj/cli/envsh.rb +22 -0
- data/lib/autoproj/cli/inspection_tool.rb +73 -0
- data/lib/autoproj/cli/locate.rb +96 -0
- data/lib/autoproj/cli/log.rb +26 -0
- data/lib/autoproj/cli/main.rb +249 -0
- data/lib/autoproj/cli/main_test.rb +57 -0
- data/lib/autoproj/cli/osdeps.rb +30 -0
- data/lib/autoproj/cli/query.rb +43 -0
- data/lib/autoproj/cli/reconfigure.rb +19 -0
- data/lib/autoproj/cli/reset.rb +7 -32
- data/lib/autoproj/cli/show.rb +219 -0
- data/lib/autoproj/cli/snapshot.rb +1 -1
- data/lib/autoproj/cli/status.rb +149 -0
- data/lib/autoproj/cli/switch_config.rb +28 -0
- data/lib/autoproj/cli/tag.rb +9 -35
- data/lib/autoproj/cli/test.rb +34 -55
- data/lib/autoproj/cli/update.rb +158 -0
- data/lib/autoproj/cli/versions.rb +32 -69
- data/lib/autoproj/configuration.rb +95 -34
- data/lib/autoproj/default.osdeps +25 -35
- data/lib/autoproj/environment.rb +85 -63
- data/lib/autoproj/exceptions.rb +50 -0
- data/lib/autoproj/gitorious.rb +11 -9
- data/lib/autoproj/manifest.rb +199 -231
- data/lib/autoproj/metapackage.rb +0 -8
- data/lib/autoproj/ops/build.rb +1 -17
- data/lib/autoproj/ops/configuration.rb +92 -90
- data/lib/autoproj/ops/import.rb +222 -0
- data/lib/autoproj/ops/loader.rb +18 -8
- data/lib/autoproj/ops/main_config_switcher.rb +45 -73
- data/lib/autoproj/ops/snapshot.rb +5 -10
- data/lib/autoproj/ops/tools.rb +10 -44
- data/lib/autoproj/options.rb +35 -6
- data/lib/autoproj/osdeps.rb +97 -68
- data/lib/autoproj/package_selection.rb +39 -20
- data/lib/autoproj/package_set.rb +26 -24
- data/lib/autoproj/reporter.rb +91 -0
- data/lib/autoproj/system.rb +50 -149
- data/lib/autoproj/variable_expansion.rb +32 -6
- data/lib/autoproj/vcs_definition.rb +57 -17
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +550 -0
- data/test/ops/test_snapshot.rb +26 -0
- data/test/test_package.rb +30 -0
- data/test/test_vcs_definition.rb +46 -0
- metadata +55 -50
- data/bin/autolocate +0 -3
- data/bin/autoproj-bootstrap +0 -68
- data/bin/autoproj-cache +0 -18
- data/bin/autoproj-clean +0 -13
- data/bin/autoproj-commit +0 -10
- data/bin/autoproj-create-set +0 -118
- data/bin/autoproj-doc +0 -28
- data/bin/autoproj-envsh +0 -14
- data/bin/autoproj-list +0 -69
- data/bin/autoproj-locate +0 -85
- data/bin/autoproj-log +0 -5
- data/bin/autoproj-query +0 -82
- data/bin/autoproj-reset +0 -13
- data/bin/autoproj-show +0 -192
- data/bin/autoproj-snapshot +0 -27
- data/bin/autoproj-switch-config +0 -24
- data/bin/autoproj-tag +0 -13
- data/bin/autoproj-test +0 -31
- data/bin/autoproj-versions +0 -20
- data/bin/autoproj_stress_test +0 -40
- data/lib/autoproj/cmdline.rb +0 -1649
@@ -0,0 +1,57 @@
|
|
1
|
+
module Autoproj
|
2
|
+
module CLI
|
3
|
+
class MainTest < Thor
|
4
|
+
default_command 'exec'
|
5
|
+
|
6
|
+
desc 'enable [PACKAGES]', 'enable tests for the given packages (or for all packages if none are given)'
|
7
|
+
option :deps, default: false,
|
8
|
+
desc: 'controls whether the dependencies of the packages given on the command line should be enabled as well (the default is not)'
|
9
|
+
def enable(*packages)
|
10
|
+
require 'autoproj/cli/test'
|
11
|
+
Autoproj.report(silent: true) do
|
12
|
+
cli = Test.new
|
13
|
+
args = cli.validate_options(packages, options)
|
14
|
+
cli.enable(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'disable [PACKAGES]', 'disable tests for the given packages (or for all packages if none are given)'
|
19
|
+
option :deps, default: false,
|
20
|
+
desc: 'controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)'
|
21
|
+
def disable(*packages)
|
22
|
+
require 'autoproj/cli/test'
|
23
|
+
Autoproj.report(silent: true) do
|
24
|
+
cli = Test.new
|
25
|
+
args = cli.validate_options(packages, options)
|
26
|
+
cli.disable(*args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'list [PACKAGES]', 'show test enable/disable status for the given packages (or all packages if none are given)'
|
31
|
+
option :deps, default: false,
|
32
|
+
desc: 'controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)'
|
33
|
+
def list(*packages)
|
34
|
+
require 'autoproj/cli/test'
|
35
|
+
Autoproj.report(silent: true) do
|
36
|
+
cli = Test.new
|
37
|
+
args = cli.validate_options(packages, options)
|
38
|
+
cli.list(*args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'exec [PACKAGES]', 'execute the tests for the given packages, or all if no packages are given on the command line'
|
43
|
+
option :deps, default: false,
|
44
|
+
desc: 'controls whether to execute the tests of the dependencies of the packages given on the command line (the default is not)'
|
45
|
+
def exec(*packages)
|
46
|
+
require 'autoproj/cli/test'
|
47
|
+
Autoproj.report do
|
48
|
+
cli = Test.new
|
49
|
+
args = cli.validate_options(packages, options)
|
50
|
+
cli.run(*args)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'autoproj/cli/inspection_tool'
|
2
|
+
|
3
|
+
module Autoproj
|
4
|
+
module CLI
|
5
|
+
class OSDeps < InspectionTool
|
6
|
+
def validate_options(package_names, options = Hash.new)
|
7
|
+
package_names, options = super
|
8
|
+
|
9
|
+
initialize_and_load
|
10
|
+
if package_names.empty?
|
11
|
+
package_names = ws.manifest.default_packages(false)
|
12
|
+
end
|
13
|
+
|
14
|
+
return package_names, options
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(user_selection, options = Hash.new)
|
18
|
+
_, osdep_packages, resolved_selection, _ =
|
19
|
+
finalize_setup(user_selection,
|
20
|
+
recursive: false,
|
21
|
+
ignore_non_imported_packages: true)
|
22
|
+
|
23
|
+
ws.osdeps.install(
|
24
|
+
osdep_packages,
|
25
|
+
install_only: !options[:update])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'autoproj'
|
2
|
+
require 'autoproj/cli/inspection_tool'
|
3
|
+
|
4
|
+
module Autoproj
|
5
|
+
module CLI
|
6
|
+
class Query < InspectionTool
|
7
|
+
def run(query_string, options = Hash.new)
|
8
|
+
initialize_and_load
|
9
|
+
finalize_setup([])
|
10
|
+
query = Autoproj::Query.parse_query(query_string.first)
|
11
|
+
|
12
|
+
packages =
|
13
|
+
if options[:search_all]
|
14
|
+
ws.manifest.packages.to_a
|
15
|
+
else
|
16
|
+
ws.manifest.all_selected_packages.map do |pkg_name|
|
17
|
+
[pkg_name, ws.manifest.packages[pkg_name]]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
matches = packages.map do |name, pkg_def|
|
22
|
+
if priority = query.match(pkg_def)
|
23
|
+
[priority, name]
|
24
|
+
end
|
25
|
+
end.compact
|
26
|
+
|
27
|
+
fields = Hash.new
|
28
|
+
matches = matches.sort
|
29
|
+
matches.each do |priority, name|
|
30
|
+
pkg = ws.manifest.find_autobuild_package(name)
|
31
|
+
fields['SRCDIR'] = pkg.srcdir
|
32
|
+
fields['PREFIX'] = pkg.prefix
|
33
|
+
fields['NAME'] = name
|
34
|
+
fields['PRIORITY'] = priority
|
35
|
+
|
36
|
+
value = Autoproj.expand(options[:format] || "$NAME", fields)
|
37
|
+
puts value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'autoproj/cli/base'
|
2
|
+
module Autoproj
|
3
|
+
module CLI
|
4
|
+
class Reconfigure < Base
|
5
|
+
def run(args, options = Hash.new)
|
6
|
+
ws.setup
|
7
|
+
ws.config.reconfigure!
|
8
|
+
options.each do |k, v|
|
9
|
+
ws.config.set k, v, true
|
10
|
+
end
|
11
|
+
ws.load_package_sets
|
12
|
+
ws.setup_all_package_directories
|
13
|
+
ws.finalize_package_setup
|
14
|
+
ws.config.save
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
data/lib/autoproj/cli/reset.rb
CHANGED
@@ -1,37 +1,10 @@
|
|
1
1
|
require 'autoproj/cli'
|
2
|
+
require 'autoproj/cli/update'
|
2
3
|
require 'autoproj/cli/versions'
|
3
4
|
|
4
5
|
module Autoproj
|
5
6
|
module CLI
|
6
|
-
class Reset
|
7
|
-
include Ops::Tools
|
8
|
-
|
9
|
-
attr_reader :manifest
|
10
|
-
|
11
|
-
def initialize(manifest)
|
12
|
-
@manifest = manifest
|
13
|
-
end
|
14
|
-
|
15
|
-
def parse_options(args)
|
16
|
-
options = Hash[]
|
17
|
-
parser = OptionParser.new do |opt|
|
18
|
-
opt.banner = ["autoproj reset COMMIT_ID", "resets the current autoproj installation to the state saved in the given commit ID"].join("\n")
|
19
|
-
opt.on "--freeze", "freezes the project at the requested version" do
|
20
|
-
options[:freeze] = true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
common_options(parser)
|
24
|
-
remaining = parser.parse(args)
|
25
|
-
if remaining.empty?
|
26
|
-
puts parser
|
27
|
-
raise InvalidArguments, "expected a reference (tag or log ID) as argument and got nothing"
|
28
|
-
elsif remaining.size > 1
|
29
|
-
puts parser
|
30
|
-
raise InvalidArguments, "expected only the tag name as argument"
|
31
|
-
end
|
32
|
-
return remaining.first, options
|
33
|
-
end
|
34
|
-
|
7
|
+
class Reset < InspectionTool
|
35
8
|
def run(ref_name, options)
|
36
9
|
pkg = manifest.main_package_set.create_autobuild_package
|
37
10
|
importer = pkg.importer
|
@@ -48,7 +21,7 @@ module Autoproj
|
|
48
21
|
|
49
22
|
# Checkout the version file
|
50
23
|
versions_file = File.join(
|
51
|
-
OVERRIDES_DIR,
|
24
|
+
Workspace::OVERRIDES_DIR,
|
52
25
|
Versions::DEFAULT_VERSIONS_FILE_BASENAME)
|
53
26
|
begin
|
54
27
|
file_data = importer.show(pkg, ref_name, versions_file)
|
@@ -58,11 +31,13 @@ module Autoproj
|
|
58
31
|
FileUtils.rm_f old_versions_path
|
59
32
|
FileUtils.cp versions_path, old_versions_path
|
60
33
|
end
|
61
|
-
FileUtils.mkdir_p File.join(Autoproj.config_dir, OVERRIDES_DIR)
|
34
|
+
FileUtils.mkdir_p File.join(Autoproj.config_dir, Workspace::OVERRIDES_DIR)
|
62
35
|
File.open(versions_path, 'w') do |io|
|
63
36
|
io.write file_data
|
64
37
|
end
|
65
|
-
|
38
|
+
|
39
|
+
update = CLI::Update.new
|
40
|
+
run_args = update.run([], reset: true)
|
66
41
|
|
67
42
|
ensure
|
68
43
|
if !options[:freeze]
|
@@ -0,0 +1,219 @@
|
|
1
|
+
require 'autoproj'
|
2
|
+
require 'autoproj/cli/inspection_tool'
|
3
|
+
|
4
|
+
module Autoproj
|
5
|
+
module CLI
|
6
|
+
class Show < InspectionTool
|
7
|
+
def run(user_selection, options = Hash.new)
|
8
|
+
options = Kernel.validate_options options,
|
9
|
+
mainline: false
|
10
|
+
|
11
|
+
initialize_and_load(mainline: options.delete(:mainline))
|
12
|
+
default_packages = ws.manifest.default_packages
|
13
|
+
|
14
|
+
source_packages, osdep_packages, * =
|
15
|
+
finalize_setup(user_selection,
|
16
|
+
recursive: false,
|
17
|
+
ignore_non_imported_packages: true)
|
18
|
+
|
19
|
+
if source_packages.empty? && osdep_packages.empty?
|
20
|
+
Autoproj.error "no packages or OS packages match #{user_selection.join(" ")}"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
load_all_available_package_manifests
|
24
|
+
revdeps = ws.manifest.compute_revdeps
|
25
|
+
|
26
|
+
source_packages.each do |pkg_name|
|
27
|
+
display_source_package(pkg_name, default_packages, revdeps)
|
28
|
+
end
|
29
|
+
osdep_packages.each do |pkg_name|
|
30
|
+
display_osdep_package(pkg_name, default_packages, revdeps)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def display_source_package(pkg_name, default_packages, revdeps)
|
35
|
+
puts Autoproj.color("source package #{pkg_name}", :bold)
|
36
|
+
pkg = ws.manifest.find_autobuild_package(pkg_name)
|
37
|
+
if !File.directory?(pkg.srcdir)
|
38
|
+
puts Autobuild.color(" this package is not checked out yet, the dependency information will probably be incomplete", :magenta)
|
39
|
+
end
|
40
|
+
puts " source definition"
|
41
|
+
ws.manifest.load_package_manifest(pkg_name)
|
42
|
+
vcs = ws.manifest.find_package(pkg_name).vcs
|
43
|
+
|
44
|
+
fragments = []
|
45
|
+
if !vcs
|
46
|
+
fragments << ["has no VCS definition", []]
|
47
|
+
elsif vcs.raw
|
48
|
+
first = true
|
49
|
+
fragments << [nil, vcs_to_array(vcs)]
|
50
|
+
vcs.raw.each do |pkg_set, vcs_info|
|
51
|
+
pkg_set = if pkg_set then pkg_set.name
|
52
|
+
end
|
53
|
+
|
54
|
+
title = if first
|
55
|
+
"first match: in #{pkg_set}"
|
56
|
+
else "overriden in #{pkg_set}"
|
57
|
+
end
|
58
|
+
first = false
|
59
|
+
fragments << [title, vcs_to_array(vcs_info)]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
fragments.each do |title, elements|
|
63
|
+
if title
|
64
|
+
puts " #{title}"
|
65
|
+
elements.each do |key, value|
|
66
|
+
puts " #{key}: #{value}"
|
67
|
+
end
|
68
|
+
else
|
69
|
+
elements.each do |key, value|
|
70
|
+
puts " #{key}: #{value}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
display_common_information(pkg_name, default_packages, revdeps)
|
76
|
+
|
77
|
+
puts " directly depends on: #{pkg.dependencies.sort.join(", ")}"
|
78
|
+
puts " optionally depends on: #{pkg.optional_dependencies.sort.join(", ")}"
|
79
|
+
puts " dependencies on OS packages: #{pkg.os_packages.sort.join(", ")}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def display_osdep_package(pkg_name, default_packages, revdeps)
|
83
|
+
puts Autoproj.color("the osdep '#{pkg_name}'", :bold)
|
84
|
+
ws.osdeps.resolve_os_dependencies([pkg_name]).each do |manager, packages|
|
85
|
+
puts " #{manager.names.first}: #{packages.map { |*subnames| subnames.join(" ") }.join(", ")}"
|
86
|
+
end
|
87
|
+
|
88
|
+
display_common_information(pkg_name, default_packages, revdeps)
|
89
|
+
end
|
90
|
+
|
91
|
+
def display_common_information(pkg_name, default_packages, revdeps)
|
92
|
+
if default_packages.include?(pkg_name)
|
93
|
+
layout_selection = default_packages.selection[pkg_name]
|
94
|
+
if layout_selection.include?(pkg_name) && layout_selection.size == 1
|
95
|
+
puts " is directly selected by the manifest"
|
96
|
+
else
|
97
|
+
layout_selection = layout_selection.dup
|
98
|
+
layout_selection.delete(pkg_name)
|
99
|
+
puts " is directly selected by the manifest via #{layout_selection.to_a.join(", ")}"
|
100
|
+
end
|
101
|
+
else
|
102
|
+
puts " is not directly selected by the manifest"
|
103
|
+
end
|
104
|
+
if ws.manifest.ignored?(pkg_name)
|
105
|
+
puts " is ignored"
|
106
|
+
end
|
107
|
+
if ws.manifest.excluded?(pkg_name)
|
108
|
+
puts " is excluded: #{Autoproj.manifest.exclusion_reason(pkg_name)}"
|
109
|
+
end
|
110
|
+
|
111
|
+
pkg_revdeps = revdeps[pkg_name].to_a
|
112
|
+
all_revdeps = compute_all_revdeps(pkg_revdeps, revdeps)
|
113
|
+
if pkg_revdeps.empty?
|
114
|
+
puts " no reverse dependencies"
|
115
|
+
else
|
116
|
+
puts " direct reverse dependencies: #{pkg_revdeps.sort.join(", ")}"
|
117
|
+
puts " recursive reverse dependencies: #{all_revdeps.sort.join(", ")}"
|
118
|
+
end
|
119
|
+
|
120
|
+
selections = Set.new
|
121
|
+
all_revdeps = all_revdeps.to_a.sort
|
122
|
+
all_revdeps.each do |revdep_parent_name|
|
123
|
+
if default_packages.include?(revdep_parent_name)
|
124
|
+
selections |= default_packages.selection[revdep_parent_name]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
if !selections.empty?
|
129
|
+
puts " selected by way of"
|
130
|
+
selections.each do |root_pkg|
|
131
|
+
paths = find_selection_path(root_pkg, pkg_name)
|
132
|
+
if paths.empty?
|
133
|
+
puts " FAILED"
|
134
|
+
else
|
135
|
+
paths.sort.uniq.each do |p|
|
136
|
+
puts " #{p.join(">")}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def find_selection_path(from, to)
|
144
|
+
if from == to
|
145
|
+
return [[from]]
|
146
|
+
end
|
147
|
+
|
148
|
+
all_paths = Array.new
|
149
|
+
ws.manifest.resolve_package_set(from).each do |pkg_name|
|
150
|
+
path = if pkg_name == from then []
|
151
|
+
else [pkg_name]
|
152
|
+
end
|
153
|
+
|
154
|
+
pkg = ws.manifest.find_autobuild_package(pkg_name)
|
155
|
+
pkg.dependencies.each do |dep_pkg_name|
|
156
|
+
if result = find_selection_path(dep_pkg_name, to)
|
157
|
+
all_paths.concat(result.map { |p| path + p })
|
158
|
+
end
|
159
|
+
end
|
160
|
+
if pkg.os_packages.include?(to)
|
161
|
+
all_paths << (path + [to])
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Now filter common trailing subpaths
|
166
|
+
all_paths = all_paths.sort_by(&:size)
|
167
|
+
filtered_paths = Array.new
|
168
|
+
while !all_paths.empty?
|
169
|
+
path = all_paths.shift
|
170
|
+
filtered_paths << path
|
171
|
+
size = path.size
|
172
|
+
all_paths.delete_if do |p|
|
173
|
+
p[-size..-1] == path
|
174
|
+
end
|
175
|
+
end
|
176
|
+
filtered_paths.map { |p| [from] + p }
|
177
|
+
end
|
178
|
+
|
179
|
+
def vcs_to_array(vcs)
|
180
|
+
if vcs.kind_of?(Hash)
|
181
|
+
options = vcs.dup
|
182
|
+
type = options.delete('type')
|
183
|
+
url = options.delete('url')
|
184
|
+
else
|
185
|
+
options = vcs.options
|
186
|
+
type = vcs.type
|
187
|
+
url = vcs.url
|
188
|
+
end
|
189
|
+
|
190
|
+
value = []
|
191
|
+
if type
|
192
|
+
value << ['type', type]
|
193
|
+
end
|
194
|
+
if url
|
195
|
+
value << ['url', url]
|
196
|
+
end
|
197
|
+
value = value.concat(options.to_a.sort_by { |k, _| k.to_s })
|
198
|
+
value.map do |key, value|
|
199
|
+
if value.respond_to?(:to_str) && File.file?(value) && value =~ /^\//
|
200
|
+
value = Pathname.new(value).relative_path_from(Pathname.new(Autoproj.root_dir))
|
201
|
+
end
|
202
|
+
[key, value]
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def compute_all_revdeps(pkg_revdeps, revdeps)
|
207
|
+
pkg_revdeps = pkg_revdeps.dup
|
208
|
+
all_revdeps = Array.new
|
209
|
+
while !pkg_revdeps.empty?
|
210
|
+
parent_name = pkg_revdeps.shift
|
211
|
+
next if all_revdeps.include?(parent_name)
|
212
|
+
all_revdeps << parent_name
|
213
|
+
pkg_revdeps.concat(revdeps[parent_name].to_a)
|
214
|
+
end
|
215
|
+
all_revdeps
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'autoproj/cli/inspection_tool'
|
2
|
+
|
3
|
+
module Autoproj
|
4
|
+
module CLI
|
5
|
+
class Status < InspectionTool
|
6
|
+
def validate_options(packages, options)
|
7
|
+
packages, options = super
|
8
|
+
if options[:dep].nil? && packages.empty?
|
9
|
+
options[:dep] = true
|
10
|
+
end
|
11
|
+
return packages, options
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(user_selection, options = Hash.new)
|
15
|
+
initialize_and_load(mainline: options[:mainline])
|
16
|
+
packages, *, config_selected = finalize_setup(
|
17
|
+
user_selection,
|
18
|
+
recursive: options[:dep],
|
19
|
+
ignore_non_imported_packages: true)
|
20
|
+
|
21
|
+
if options[:config].nil?
|
22
|
+
options[:config] = user_selection.empty? || config_selected
|
23
|
+
end
|
24
|
+
|
25
|
+
if packages.empty?
|
26
|
+
Autoproj.error "no packages or OS packages match #{user_selection.join(" ")}"
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
if options[:config]
|
31
|
+
pkg_sets = ws.manifest.each_package_set.map(&:create_autobuild_package)
|
32
|
+
if !pkg_sets.empty?
|
33
|
+
Autoproj.message("autoproj: displaying status of configuration", :bold)
|
34
|
+
display_status(pkg_sets, only_local: options[:only_local])
|
35
|
+
STDERR.puts
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Autoproj.message("autoproj: displaying status of packages", :bold)
|
40
|
+
packages = packages.sort.map do |pkg_name|
|
41
|
+
ws.manifest.find_autobuild_package(pkg_name)
|
42
|
+
end
|
43
|
+
display_status(packages, only_local: options[:only_local])
|
44
|
+
end
|
45
|
+
|
46
|
+
StatusResult = Struct.new :uncommitted, :local, :remote
|
47
|
+
def display_status(packages, options = Hash.new)
|
48
|
+
result = StatusResult.new
|
49
|
+
|
50
|
+
sync_packages = ""
|
51
|
+
packages.each do |pkg|
|
52
|
+
lines = []
|
53
|
+
|
54
|
+
pkg_name = pkg.autoproj_name
|
55
|
+
|
56
|
+
if !pkg.importer
|
57
|
+
lines << Autoproj.color(" is a local-only package (no VCS)", :bold, :red)
|
58
|
+
elsif !pkg.importer.respond_to?(:status)
|
59
|
+
lines << Autoproj.color(" the #{pkg.importer.class.name.gsub(/.*::/, '')} importer does not support status display", :bold, :red)
|
60
|
+
elsif !File.directory?(pkg.srcdir)
|
61
|
+
lines << Autoproj.color(" is not imported yet", :magenta)
|
62
|
+
else
|
63
|
+
status = begin pkg.importer.status(pkg, options[:only_local])
|
64
|
+
rescue Interrupt
|
65
|
+
raise
|
66
|
+
rescue Exception => e
|
67
|
+
lines << Autoproj.color(" failed to fetch status information (#{e})", :red)
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
if status
|
72
|
+
if status.uncommitted_code
|
73
|
+
lines << Autoproj.color(" contains uncommitted modifications", :red)
|
74
|
+
result.uncommitted = true
|
75
|
+
end
|
76
|
+
|
77
|
+
case status.status
|
78
|
+
when Autobuild::Importer::Status::UP_TO_DATE
|
79
|
+
if !status.uncommitted_code
|
80
|
+
if sync_packages.size > 80
|
81
|
+
Autoproj.message "#{sync_packages},"
|
82
|
+
sync_packages = ""
|
83
|
+
end
|
84
|
+
msg = if sync_packages.empty?
|
85
|
+
pkg_name
|
86
|
+
else
|
87
|
+
", #{pkg_name}"
|
88
|
+
end
|
89
|
+
STDERR.print msg
|
90
|
+
sync_packages = "#{sync_packages}#{msg}"
|
91
|
+
next
|
92
|
+
else
|
93
|
+
lines << Autoproj.color(" local and remote are in sync", :green)
|
94
|
+
end
|
95
|
+
when Autobuild::Importer::Status::ADVANCED
|
96
|
+
result.local = true
|
97
|
+
lines << Autoproj.color(" local contains #{status.local_commits.size} commit that remote does not have:", :blue)
|
98
|
+
status.local_commits.each do |line|
|
99
|
+
lines << Autoproj.color(" #{line}", :blue)
|
100
|
+
end
|
101
|
+
when Autobuild::Importer::Status::SIMPLE_UPDATE
|
102
|
+
result.remote = true
|
103
|
+
lines << Autoproj.color(" remote contains #{status.remote_commits.size} commit that local does not have:", :magenta)
|
104
|
+
status.remote_commits.each do |line|
|
105
|
+
lines << Autoproj.color(" #{line}", :magenta)
|
106
|
+
end
|
107
|
+
when Autobuild::Importer::Status::NEEDS_MERGE
|
108
|
+
result.local = true
|
109
|
+
result.remote = true
|
110
|
+
lines << " local and remote have diverged with respectively #{status.local_commits.size} and #{status.remote_commits.size} commits each"
|
111
|
+
lines << Autoproj.color(" -- local commits --", :blue)
|
112
|
+
status.local_commits.each do |line|
|
113
|
+
lines << Autoproj.color(" #{line}", :blue)
|
114
|
+
end
|
115
|
+
lines << Autoproj.color(" -- remote commits --", :magenta)
|
116
|
+
status.remote_commits.each do |line|
|
117
|
+
lines << Autoproj.color(" #{line}", :magenta)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if !sync_packages.empty?
|
124
|
+
Autoproj.message("#{sync_packages}: #{Autoproj.color("local and remote are in sync", :green)}")
|
125
|
+
sync_packages = ""
|
126
|
+
end
|
127
|
+
|
128
|
+
STDERR.print
|
129
|
+
|
130
|
+
if lines.size == 1
|
131
|
+
Autoproj.message "#{pkg_name}: #{lines.first}"
|
132
|
+
else
|
133
|
+
Autoproj.message "#{pkg_name}:"
|
134
|
+
lines.each do |l|
|
135
|
+
Autoproj.message l
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
if !sync_packages.empty?
|
140
|
+
Autoproj.message("#{sync_packages}: #{Autoproj.color("local and remote are in sync", :green)}")
|
141
|
+
sync_packages = ""
|
142
|
+
end
|
143
|
+
return result
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|