autoproj 2.12.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +22 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +6 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +2 -2
  14. data/bin/autoproj_bootstrap +186 -183
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +185 -182
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +5 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +61 -44
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  25. data/lib/autoproj/base.rb +1 -1
  26. data/lib/autoproj/bash_completion.rb +5 -6
  27. data/lib/autoproj/build_option.rb +22 -24
  28. data/lib/autoproj/cli/base.rb +27 -27
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +18 -10
  31. data/lib/autoproj/cli/cache.rb +51 -8
  32. data/lib/autoproj/cli/clean.rb +10 -10
  33. data/lib/autoproj/cli/commit.rb +7 -8
  34. data/lib/autoproj/cli/doc.rb +2 -2
  35. data/lib/autoproj/cli/envsh.rb +1 -2
  36. data/lib/autoproj/cli/exec.rb +60 -20
  37. data/lib/autoproj/cli/inspection_tool.rb +18 -13
  38. data/lib/autoproj/cli/locate.rb +30 -41
  39. data/lib/autoproj/cli/log.rb +7 -7
  40. data/lib/autoproj/cli/main.rb +217 -205
  41. data/lib/autoproj/cli/main_doc.rb +22 -21
  42. data/lib/autoproj/cli/main_global.rb +44 -19
  43. data/lib/autoproj/cli/main_plugin.rb +18 -18
  44. data/lib/autoproj/cli/main_test.rb +28 -27
  45. data/lib/autoproj/cli/manifest.rb +7 -7
  46. data/lib/autoproj/cli/osdeps.rb +12 -11
  47. data/lib/autoproj/cli/patcher.rb +2 -3
  48. data/lib/autoproj/cli/query.rb +17 -18
  49. data/lib/autoproj/cli/reconfigure.rb +1 -2
  50. data/lib/autoproj/cli/reset.rb +9 -12
  51. data/lib/autoproj/cli/show.rb +48 -55
  52. data/lib/autoproj/cli/status.rb +56 -44
  53. data/lib/autoproj/cli/switch_config.rb +5 -6
  54. data/lib/autoproj/cli/tag.rb +12 -11
  55. data/lib/autoproj/cli/test.rb +7 -7
  56. data/lib/autoproj/cli/update.rb +104 -51
  57. data/lib/autoproj/cli/utility.rb +14 -12
  58. data/lib/autoproj/cli/version.rb +42 -40
  59. data/lib/autoproj/cli/versions.rb +14 -15
  60. data/lib/autoproj/cli/watch.rb +33 -37
  61. data/lib/autoproj/cli/which.rb +16 -20
  62. data/lib/autoproj/cli.rb +4 -2
  63. data/lib/autoproj/configuration.rb +78 -85
  64. data/lib/autoproj/default.osdeps +29 -3
  65. data/lib/autoproj/environment.rb +42 -23
  66. data/lib/autoproj/exceptions.rb +9 -3
  67. data/lib/autoproj/find_workspace.rb +20 -25
  68. data/lib/autoproj/git_server_configuration.rb +40 -44
  69. data/lib/autoproj/gitorious.rb +1 -1
  70. data/lib/autoproj/installation_manifest.rb +64 -29
  71. data/lib/autoproj/local_package_set.rb +13 -11
  72. data/lib/autoproj/manifest.rb +145 -135
  73. data/lib/autoproj/metapackage.rb +2 -6
  74. data/lib/autoproj/ops/atomic_write.rb +7 -6
  75. data/lib/autoproj/ops/build.rb +4 -6
  76. data/lib/autoproj/ops/cache.rb +64 -53
  77. data/lib/autoproj/ops/cached_env.rb +7 -6
  78. data/lib/autoproj/ops/configuration.rb +511 -506
  79. data/lib/autoproj/ops/import.rb +90 -61
  80. data/lib/autoproj/ops/install.rb +179 -175
  81. data/lib/autoproj/ops/loader.rb +77 -76
  82. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  83. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  84. data/lib/autoproj/ops/snapshot.rb +250 -247
  85. data/lib/autoproj/ops/tools.rb +76 -78
  86. data/lib/autoproj/ops/watch.rb +6 -6
  87. data/lib/autoproj/ops/which.rb +17 -14
  88. data/lib/autoproj/options.rb +13 -2
  89. data/lib/autoproj/os_package_installer.rb +102 -92
  90. data/lib/autoproj/os_package_query.rb +7 -13
  91. data/lib/autoproj/os_package_resolver.rb +189 -140
  92. data/lib/autoproj/os_repository_installer.rb +4 -4
  93. data/lib/autoproj/os_repository_resolver.rb +8 -6
  94. data/lib/autoproj/package_definition.rb +12 -13
  95. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +46 -31
  96. data/lib/autoproj/package_managers/bundler_manager.rb +156 -118
  97. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  98. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  99. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  100. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  101. data/lib/autoproj/package_managers/manager.rb +8 -3
  102. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  103. data/lib/autoproj/package_managers/pip_manager.rb +37 -27
  104. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  105. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  106. data/lib/autoproj/package_managers/shell_script_manager.rb +66 -36
  107. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  108. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  109. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  110. data/lib/autoproj/package_manifest.rb +66 -53
  111. data/lib/autoproj/package_selection.rb +187 -187
  112. data/lib/autoproj/package_set.rb +128 -114
  113. data/lib/autoproj/python.rb +285 -0
  114. data/lib/autoproj/query_base.rb +20 -14
  115. data/lib/autoproj/reporter.rb +19 -19
  116. data/lib/autoproj/repository_managers/apt.rb +101 -67
  117. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  118. data/lib/autoproj/shell_completion.rb +16 -13
  119. data/lib/autoproj/source_package_query.rb +29 -36
  120. data/lib/autoproj/system.rb +32 -21
  121. data/lib/autoproj/test.rb +131 -106
  122. data/lib/autoproj/variable_expansion.rb +10 -10
  123. data/lib/autoproj/vcs_definition.rb +53 -37
  124. data/lib/autoproj/version.rb +1 -1
  125. data/lib/autoproj/workspace.rb +162 -117
  126. data/lib/autoproj/zsh_completion.rb +8 -9
  127. data/lib/autoproj.rb +53 -53
  128. data/samples/autoproj/init.rb +1 -2
  129. metadata +62 -72
  130. data/.travis.yml +0 -22
@@ -1,7 +1,7 @@
1
- require 'autoproj/find_workspace'
2
- require 'autoproj/ops/cached_env'
3
- require 'autoproj/ops/which'
4
- require 'autoproj/ops/watch'
1
+ require "autoproj/find_workspace"
2
+ require "autoproj/ops/cached_env"
3
+ require "autoproj/ops/which"
4
+ require "autoproj/ops/watch"
5
5
 
6
6
  module Autoproj
7
7
  module CLI
@@ -9,7 +9,7 @@ module Autoproj
9
9
  def initialize
10
10
  @root_dir = Autoproj.find_workspace_dir
11
11
  unless @root_dir
12
- require 'autoproj/workspace'
12
+ require "autoproj/workspace"
13
13
  # Will do all sorts of error reporting,
14
14
  # or may be able to resolve
15
15
  @root_dir = Workspace.default.root_dir
@@ -20,40 +20,80 @@ module Autoproj
20
20
  env = Ops.load_cached_env(@root_dir)
21
21
  return unless env
22
22
 
23
- Autobuild::Environment.
24
- environment_from_export(env, ENV)
23
+ Autobuild::Environment
24
+ .environment_from_export(env, ENV)
25
25
  end
26
26
 
27
- def run(cmd, *args, use_cached_env: Ops.watch_running?(@root_dir))
27
+ def try_loading_installation_manifest
28
+ Autoproj::InstallationManifest.from_workspace_root(@root_dir)
29
+ rescue
30
+ end
31
+
32
+ PACKAGE_ROOT_PATH_RX = /^(srcdir|builddir|prefix):(.*)$/
33
+
34
+ def resolve_package_root_path(package, manifest)
35
+ if (m = PACKAGE_ROOT_PATH_RX.match(package))
36
+ kind = m[1]
37
+ name = m[2]
38
+ else
39
+ kind = "srcdir"
40
+ name = package
41
+ end
42
+
43
+ unless (pkg = manifest.find_package_by_name(name))
44
+ raise ArgumentError, "no package #{name} in this workspace"
45
+ end
46
+
47
+ unless (dir = pkg.send(kind))
48
+ raise CLIInvalidArguments, "package #{pkg.name} has no #{kind}"
49
+ end
50
+
51
+ dir
52
+ end
53
+
54
+ def run(
55
+ cmd, *args,
56
+ use_cached_env: Ops.watch_running?(@root_dir),
57
+ interactive: nil,
58
+ package: nil, chdir: nil
59
+ )
28
60
  env = load_cached_env if use_cached_env
61
+ manifest = try_loading_installation_manifest if use_cached_env
29
62
 
30
- unless env
31
- require 'autoproj'
32
- require 'autoproj/cli/inspection_tool'
63
+ if !env || (package && !manifest)
64
+ require "autoproj"
65
+ require "autoproj/cli/inspection_tool"
33
66
  ws = Workspace.from_dir(@root_dir)
67
+ ws.config.interactive = interactive unless interactive.nil?
34
68
  loader = InspectionTool.new(ws)
35
- loader.initialize_and_load
36
- loader.finalize_setup(Array.new)
69
+ loader.initialize_and_load(read_only: true)
70
+ loader.finalize_setup(read_only: true)
37
71
  env = ws.full_env.resolved_env
72
+ manifest = ws.installation_manifest if package
38
73
  end
39
74
 
40
- path = env['PATH'].split(File::PATH_SEPARATOR)
75
+ root_path = resolve_package_root_path(package, manifest) if package
76
+ chdir ||= root_path
77
+ if chdir
78
+ chdir = File.expand_path(chdir, root_path)
79
+ chdir_kw = { chdir: chdir }
80
+ end
81
+
82
+ path = env["PATH"].split(File::PATH_SEPARATOR)
41
83
  program =
42
- begin Ops.which(cmd, path_entries: path)
84
+ begin Ops.which(cmd, path_entries: [chdir, *path].compact)
43
85
  rescue ::Exception => e
44
- require 'autoproj'
86
+ require "autoproj"
45
87
  raise CLIInvalidArguments, e.message, e.backtrace
46
88
  end
47
89
 
48
90
  begin
49
- ::Process.exec(env, program, *args)
91
+ ::Process.exec(env, program, *args, **(chdir_kw || {}))
50
92
  rescue ::Exception => e
51
- require 'autoproj'
93
+ require "autoproj"
52
94
  raise CLIInvalidArguments, e.message, e.backtrace
53
95
  end
54
96
  end
55
97
  end
56
98
  end
57
99
  end
58
-
59
-
@@ -1,18 +1,16 @@
1
- require 'autoproj/cli/base'
1
+ require "autoproj/cli/base"
2
2
 
3
3
  module Autoproj
4
4
  module CLI
5
5
  # Base class for CLI tools that do not change the state of the installed
6
6
  # system
7
7
  class InspectionTool < Base
8
- def initialize_and_load(mainline: nil)
8
+ def initialize_and_load(mainline: nil, read_only: false)
9
9
  Autoproj.silent do
10
- ws.setup
11
- if mainline == 'mainline' || mainline == 'true'
12
- mainline = true
13
- end
10
+ ws.setup(read_only: read_only)
11
+ mainline = true if %w[mainline true].include?(mainline)
14
12
  ws.load_package_sets(mainline: mainline)
15
- ws.config.save
13
+ ws.config.save unless read_only
16
14
  ws.setup_all_package_directories
17
15
  end
18
16
  end
@@ -22,7 +20,7 @@ module Autoproj
22
20
  # @param [Array<String>] packages the list of package names
23
21
  # @param [Symbol] non_imported_packages whether packages that are
24
22
  # not yet imported should be ignored (:ignore) or returned
25
- # (:return).
23
+ # (:return).
26
24
  # @option options recursive (true) whether the package resolution
27
25
  # should return the package(s) and their dependencies
28
26
  #
@@ -30,18 +28,25 @@ module Autoproj
30
28
  # selected packages, the PackageSelection representing the
31
29
  # selection resolution itself, and a flag telling whether some of
32
30
  # the arguments were pointing within the configuration area
33
- def finalize_setup(packages = [], non_imported_packages: :ignore, recursive: true, auto_exclude: false)
31
+ def finalize_setup(
32
+ packages = [],
33
+ non_imported_packages: :ignore,
34
+ recursive: true,
35
+ auto_exclude: false,
36
+ read_only: false
37
+ )
34
38
  Autoproj.silent do
35
- packages, config_selected = normalize_command_line_package_selection(packages)
39
+ packages, config_selected =
40
+ normalize_command_line_package_selection(packages)
36
41
  # Call resolve_user_selection once to auto-add packages, so
37
42
  # that they're available to e.g. overrides.rb
38
43
  resolve_user_selection(packages)
39
44
  ws.finalize_package_setup
40
45
  source_packages, osdep_packages, resolved_selection =
41
46
  resolve_selection(packages, recursive: recursive, non_imported_packages: non_imported_packages, auto_exclude: auto_exclude)
42
- ws.finalize_setup
43
- ws.export_installation_manifest
44
- return source_packages, osdep_packages, resolved_selection, config_selected
47
+ ws.finalize_setup(read_only: read_only)
48
+ ws.export_installation_manifest unless read_only
49
+ [source_packages, osdep_packages, resolved_selection, config_selected]
45
50
  end
46
51
  end
47
52
  end
@@ -1,4 +1,4 @@
1
- require 'autoproj/cli/inspection_tool'
1
+ require "autoproj/cli/inspection_tool"
2
2
 
3
3
  module Autoproj
4
4
  module CLI
@@ -11,8 +11,9 @@ module Autoproj
11
11
  class Locate < InspectionTool
12
12
  attr_reader :packages
13
13
  attr_reader :package_sets
14
-
14
+
15
15
  class NotFound < CLIException; end
16
+
16
17
  class NoSuchDir < CLIException; end
17
18
 
18
19
  # Create the locate CLI interface
@@ -69,14 +70,14 @@ module Autoproj
69
70
  candidates << pkg
70
71
  end
71
72
  end
72
- return candidates
73
+ candidates
73
74
  end
74
75
 
75
76
  def find_packages_with_directory_shortnames(selection)
76
- *directories, basename = *selection.split('/')
77
- dirname_rx = directories.
78
- map { |d| "#{Regexp.quote(d)}\\w*" }.
79
- join("/")
77
+ *directories, basename = *selection.split("/")
78
+ dirname_rx = directories
79
+ .map { |d| "#{Regexp.quote(d)}\\w*" }
80
+ .join("/")
80
81
 
81
82
  rx = Regexp.new("#{dirname_rx}/#{Regexp.quote(basename)}")
82
83
  rx_strict = Regexp.new("#{dirname_rx}/#{Regexp.quote(basename)}$")
@@ -85,12 +86,8 @@ module Autoproj
85
86
  candidates_strict = []
86
87
  packages.each do |pkg|
87
88
  name = pkg.name
88
- if name =~ rx
89
- candidates << pkg
90
- end
91
- if name =~ rx_strict
92
- candidates_strict << pkg
93
- end
89
+ candidates << pkg if name =~ rx
90
+ candidates_strict << pkg if name =~ rx_strict
94
91
  end
95
92
 
96
93
  if candidates.size > 1 && candidates_strict.size == 1
@@ -114,22 +111,18 @@ module Autoproj
114
111
  :build_dir
115
112
  elsif options.delete(:prefix)
116
113
  :prefix_dir
117
- elsif log_type = options[:log]
118
- if log_type == 'log'
119
- options.delete(:log)
120
- end
114
+ elsif (log_type = options[:log])
115
+ options.delete(:log) if log_type == "log"
121
116
  :log
122
117
  else
123
118
  :source_dir
124
119
  end
125
120
  options[:mode] ||= mode
126
- if selections.empty?
127
- selections << ws.root_dir
128
- end
129
- return selections, options
121
+ selections << ws.root_dir if selections.empty?
122
+ [selections, options]
130
123
  end
131
124
 
132
- RESOLUTION_MODES = [:source_dir, :build_dir, :prefix_dir, :log]
125
+ RESOLUTION_MODES = %i[source_dir build_dir prefix_dir log]
133
126
 
134
127
  def run(selections, cache: !!packages, mode: :source_dir, log: nil)
135
128
  if !RESOLUTION_MODES.include?(mode)
@@ -139,9 +132,7 @@ module Autoproj
139
132
  end
140
133
 
141
134
  selections.each do |string|
142
- if File.directory?(string)
143
- string = "#{File.expand_path(string)}/"
144
- end
135
+ string = "#{File.expand_path(string)}/" if File.directory?(string)
145
136
  if mode == :source_dir
146
137
  puts source_dir_of(string)
147
138
  elsif mode == :build_dir
@@ -149,7 +140,7 @@ module Autoproj
149
140
  elsif mode == :prefix_dir
150
141
  puts prefix_dir_of(string)
151
142
  elsif mode == :log
152
- if all_logs = (log == 'all')
143
+ if (all_logs = (log == "all"))
153
144
  log = nil
154
145
  end
155
146
  result = logs_of(string, log: log)
@@ -179,17 +170,15 @@ module Autoproj
179
170
  # If there is more than one candidate, check if there are some that are not
180
171
  # present on disk
181
172
  present = matching_packages.find_all { |pkg| File.directory?(pkg.srcdir) }
182
- if present.size == 1
183
- matching_packages = present
184
- end
173
+ matching_packages = present if present.size == 1
185
174
  end
186
175
 
187
176
  if matching_packages.empty?
188
177
  raise CLIInvalidArguments, "cannot find '#{selection}' in the current autoproj installation"
189
178
  elsif matching_packages.size > 1
190
- raise CLIAmbiguousArguments, "multiple packages match '#{selection}' in the current autoproj installation: #{matching_packages.map(&:name).sort.join(", ")}"
179
+ raise CLIAmbiguousArguments, "multiple packages match '#{selection}' in the current autoproj installation: #{matching_packages.map(&:name).sort.join(', ')}"
191
180
  else
192
- return matching_packages.first
181
+ matching_packages.first
193
182
  end
194
183
  end
195
184
 
@@ -203,7 +192,7 @@ module Autoproj
203
192
  def source_dir_of(selection)
204
193
  if workspace_dir?(selection)
205
194
  ws.root_dir
206
- elsif pkg_set = find_package_set(selection)
195
+ elsif (pkg_set = find_package_set(selection))
207
196
  pkg_set.user_local_dir
208
197
  else
209
198
  resolve_package(selection).srcdir
@@ -246,20 +235,21 @@ module Autoproj
246
235
  #
247
236
  # The workspace is resolved as the main configuration
248
237
  #
249
- # If 'log' is nil and multiple logs are available,
238
+ # If 'log' is nil and multiple logs are available,
250
239
  def logs_of(selection, log: nil)
251
240
  if workspace_dir?(selection) || (pkg_set = find_package_set(selection))
252
- if log && log != 'import'
253
- return []
254
- end
241
+ return [] if log && log != "import"
242
+
255
243
  name = if pkg_set then pkg_set.name
256
- else "autoproj main configuration"
244
+ else
245
+ "autoproj main configuration"
257
246
  end
258
247
 
259
248
  import_log = File.join(ws.log_dir, "#{name}-import.log")
260
249
  if File.file?(import_log)
261
- return [import_log]
262
- else return []
250
+ [import_log]
251
+ else
252
+ []
263
253
  end
264
254
  else
265
255
  pkg = resolve_package(selection)
@@ -269,7 +259,7 @@ module Autoproj
269
259
 
270
260
  # Interactively select a log file among a list
271
261
  def select_log_file(log_files)
272
- require 'tty/prompt'
262
+ require "tty/prompt"
273
263
 
274
264
  log_files = log_files.map do |path|
275
265
  [path, File.stat(path).mtime]
@@ -294,4 +284,3 @@ module Autoproj
294
284
  end
295
285
  end
296
286
  end
297
-
@@ -1,4 +1,4 @@
1
- require 'autoproj/cli/base'
1
+ require "autoproj/cli/base"
2
2
 
3
3
  module Autoproj
4
4
  module CLI
@@ -15,15 +15,15 @@ module Autoproj
15
15
  end
16
16
 
17
17
  common_args = [Autobuild.tool(:git), "--git-dir=#{ws.config_dir}/.git"]
18
- if since = options[:since]
19
- exec(*common_args, 'diff', parse_log_entry(since), 'autoproj@{0}')
18
+ if (since = options[:since])
19
+ exec(*common_args, "diff", parse_log_entry(since), "autoproj@{0}")
20
20
  elsif args.empty?
21
- exec(*common_args, 'reflog',
22
- Ops::Snapshot.import_state_log_ref, '--format=%Cgreen%gd %Cblue%cr %Creset%gs')
21
+ exec(*common_args, "reflog",
22
+ Ops::Snapshot.import_state_log_ref, "--format=%Cgreen%gd %Cblue%cr %Creset%gs")
23
23
  elsif options[:diff]
24
- exec(*common_args, 'diff', *args.map { |entry| parse_log_entry(entry) })
24
+ exec(*common_args, "diff", *args.map { |entry| parse_log_entry(entry) })
25
25
  else
26
- exec(*common_args, 'show', *args.map { |entry| parse_log_entry(entry) })
26
+ exec(*common_args, "show", *args.map { |entry| parse_log_entry(entry) })
27
27
  end
28
28
  end
29
29