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
@@ -2,9 +2,9 @@ module Autoproj
2
2
  module Ops
3
3
  # Shamelessly stolen from ActiveSupport
4
4
  def self.atomic_write(file_name, temp_dir = Dir.tmpdir)
5
- require 'tempfile' unless defined?(Tempfile)
6
- require 'fileutils' unless defined?(FileUtils)
7
-
5
+ require "tempfile" unless defined?(Tempfile)
6
+ require "fileutils" unless defined?(FileUtils)
7
+
8
8
  temp_file = Tempfile.new(File.basename(file_name), temp_dir)
9
9
  yield temp_file
10
10
  temp_file.flush
@@ -12,15 +12,16 @@ module Autoproj
12
12
  rescue NotImplementedError
13
13
  end
14
14
  temp_file.close
15
-
15
+
16
16
  begin
17
17
  # Get original file permissions
18
18
  old_stat = File.stat(file_name)
19
19
  rescue Errno::ENOENT
20
20
  # No old permissions, write a temp file to determine the defaults
21
21
  check_name = File.join(
22
- File.dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}")
23
- File.open(check_name, "w") { }
22
+ File.dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"
23
+ )
24
+ File.open(check_name, "w") {}
24
25
  old_stat = File.stat(check_name)
25
26
  File.unlink(check_name)
26
27
  end
@@ -1,4 +1,4 @@
1
- require 'erb'
1
+ require "erb"
2
2
  module Autoproj
3
3
  module Ops
4
4
  # Operations related to building packages
@@ -77,7 +77,6 @@ module Autoproj
77
77
  build_packages(all_enabled_packages)
78
78
  end
79
79
 
80
-
81
80
  # Builds the listed packages
82
81
  #
83
82
  # Only build steps that are actually needed will be performed. See
@@ -89,7 +88,7 @@ module Autoproj
89
88
  def build_packages(all_enabled_packages, options = Hash.new)
90
89
  if @report_path
91
90
  reporting = Ops::PhaseReporting.new(
92
- 'build', @report_path, method(:package_metadata)
91
+ "build", @report_path, method(:package_metadata)
93
92
  )
94
93
  end
95
94
 
@@ -99,11 +98,10 @@ module Autoproj
99
98
  begin
100
99
  Autobuild.apply(
101
100
  all_enabled_packages,
102
- "autoproj-build", ['build'], options
101
+ "autoproj-build", ["build"], options
103
102
  ) do |pkg, phase|
104
- reporting&.report_incremental(pkg) if phase == 'build'
103
+ reporting&.report_incremental(pkg) if phase == "build"
105
104
  end
106
-
107
105
  ensure
108
106
  packages = all_enabled_packages.map do |name|
109
107
  @manifest.find_autobuild_package(name)
@@ -12,20 +12,18 @@ module Autoproj
12
12
 
13
13
  def with_retry(count)
14
14
  (count + 1).times do |i|
15
- begin
16
- break yield
17
- rescue Autobuild::SubcommandFailed
18
- if i == count
19
- raise
20
- else
21
- Autobuild.message " failed, retrying (#{i}/#{count})"
22
- end
15
+ break yield
16
+ rescue Autobuild::SubcommandFailed
17
+ if i == count
18
+ raise
19
+ else
20
+ Autobuild.message " failed, retrying (#{i}/#{count})"
23
21
  end
24
22
  end
25
23
  end
26
24
 
27
25
  def git_cache_dir
28
- File.join(cache_dir, 'git')
26
+ File.join(cache_dir, "git")
29
27
  end
30
28
 
31
29
  def cache_git(pkg, checkout_only: false)
@@ -34,37 +32,37 @@ module Autoproj
34
32
 
35
33
  pkg.importer.local_branch = nil
36
34
  pkg.importer.remote_branch = nil
37
- pkg.importer.remote_name = 'autobuild'
35
+ pkg.importer.remote_name = "autobuild"
38
36
 
39
37
  unless File.directory?(pkg.importdir)
40
38
  FileUtils.mkdir_p File.dirname(pkg.importdir)
41
39
  Autobuild::Subprocess.run(
42
40
  "autoproj-cache", "import", Autobuild.tool(:git),
43
- "--git-dir", pkg.importdir, 'init', "--bare"
41
+ "--git-dir", pkg.importdir, "init", "--bare"
44
42
  )
45
43
  end
46
- pkg.importer.update_remotes_configuration(pkg)
44
+ pkg.importer.update_remotes_configuration(pkg, only_local: false)
47
45
 
48
46
  with_retry(10) do
49
47
  Autobuild::Subprocess.run(
50
- 'autoproj-cache', :import, Autobuild.tool('git'),
51
- '--git-dir', pkg.importdir, 'remote', 'update', 'autobuild'
48
+ "autoproj-cache", :import, Autobuild.tool("git"),
49
+ "--git-dir", pkg.importdir, "remote", "update", "autobuild"
52
50
  )
53
51
  end
54
52
  with_retry(10) do
55
53
  Autobuild::Subprocess.run(
56
- 'autoproj-cache', :import, Autobuild.tool('git'),
57
- '--git-dir', pkg.importdir, 'fetch', 'autobuild', '--tags'
54
+ "autoproj-cache", :import, Autobuild.tool("git"),
55
+ "--git-dir", pkg.importdir, "fetch", "autobuild", "--tags"
58
56
  )
59
57
  end
60
58
  Autobuild::Subprocess.run(
61
- 'autoproj-cache', :import, Autobuild.tool('git'),
62
- '--git-dir', pkg.importdir, 'gc', '--prune=all'
59
+ "autoproj-cache", :import, Autobuild.tool("git"),
60
+ "--git-dir", pkg.importdir, "gc", "--prune=all"
63
61
  )
64
62
  end
65
63
 
66
64
  def archive_cache_dir
67
- File.join(cache_dir, 'archives')
65
+ File.join(cache_dir, "archives")
68
66
  end
69
67
 
70
68
  def cache_archive(pkg)
@@ -75,25 +73,25 @@ module Autoproj
75
73
  end
76
74
 
77
75
  def create_or_update(*package_names, all: true, keep_going: false,
78
- checkout_only: false)
76
+ checkout_only: false)
79
77
  FileUtils.mkdir_p cache_dir
80
78
 
81
- if package_names.empty?
82
- packages =
79
+ packages =
80
+ if package_names.empty?
83
81
  if all
84
82
  manifest.each_autobuild_package
85
83
  else
86
84
  manifest.all_selected_source_packages.map(&:autobuild)
87
85
  end
88
- else
89
- packages = package_names.map do |name|
90
- if (pkg = manifest.find_autobuild_package(name))
91
- pkg
92
- else
93
- raise PackageNotFound, "no package named #{name}"
86
+ else
87
+ package_names.map do |name|
88
+ if (pkg = manifest.find_autobuild_package(name))
89
+ pkg
90
+ else
91
+ raise PackageNotFound, "no package named #{name}"
92
+ end
94
93
  end
95
94
  end
96
- end
97
95
 
98
96
  packages = packages.sort_by(&:name)
99
97
 
@@ -107,13 +105,20 @@ module Autoproj
107
105
  begin
108
106
  case pkg.importer
109
107
  when Autobuild::Git
110
- Autoproj.message " [#{i}/#{total}] caching #{pkg.name} (git)"
108
+ Autoproj.message(
109
+ " [#{i}/#{total}] caching #{pkg.name} (git)"
110
+ )
111
111
  cache_git(pkg, checkout_only: checkout_only)
112
112
  when Autobuild::ArchiveImporter
113
- Autoproj.message " [#{i}/#{total}] caching #{pkg.name} (archive)"
113
+ Autoproj.message(
114
+ " [#{i}/#{total}] caching #{pkg.name} (archive)"
115
+ )
114
116
  cache_archive(pkg)
115
117
  else
116
- Autoproj.message " [#{i}/#{total}] not caching #{pkg.name} (cannot cache #{pkg.importer.class})"
118
+ Autoproj.message(
119
+ " [#{i}/#{total}] not caching #{pkg.name} "\
120
+ "(cannot cache #{pkg.importer.class})"
121
+ )
117
122
  end
118
123
  rescue Interrupt
119
124
  raise
@@ -121,10 +126,10 @@ module Autoproj
121
126
  raise unless keep_going
122
127
 
123
128
  pkg.error " failed to cache #{pkg.name}, "\
124
- 'but going on as requested'
129
+ "but going on as requested"
125
130
  lines = e.to_s.split('\n')
126
131
  lines = e.message.split('\n') if lines.empty?
127
- lines = ['unknown error'] if lines.empty?
132
+ lines = ["unknown error"] if lines.empty?
128
133
  pkg.message(lines.shift, :red, :bold)
129
134
  lines.each do |line|
130
135
  pkg.message(line)
@@ -135,15 +140,15 @@ module Autoproj
135
140
  end
136
141
 
137
142
  def gems_cache_dir
138
- File.join(cache_dir, 'package_managers', 'gem')
143
+ File.join(cache_dir, "package_managers", "gem")
139
144
  end
140
145
 
141
146
  def create_or_update_gems(keep_going: true, compile_force: false, compile: [])
142
147
  # Note: this might directly copy into the cache directoy, and
143
148
  # we support it later
144
- cache_dir = File.join(@ws.prefix_dir, 'gems', 'vendor', 'cache')
149
+ cache_dir = File.join(@ws.prefix_dir, "gems", "vendor", "cache")
145
150
  PackageManagers::BundlerManager.run_bundler(
146
- @ws, 'cache'
151
+ @ws, "cache"
147
152
  )
148
153
 
149
154
  FileUtils.mkdir_p(gems_cache_dir) unless File.exist?(gems_cache_dir)
@@ -170,7 +175,9 @@ module Autoproj
170
175
  next if !compile_force && File.file?(expected_platform_gem)
171
176
 
172
177
  begin
173
- compile_gem(gem, artifacts: artifacts, output: real_target_dir)
178
+ compile_gem(
179
+ gem, artifacts: artifacts, output: real_target_dir
180
+ )
174
181
  rescue CompilationFailed
175
182
  unless keep_going
176
183
  raise CompilationFailed, "#{gem} failed to compile"
@@ -200,32 +207,36 @@ module Autoproj
200
207
  end
201
208
 
202
209
  def guess_gem_program
203
- if Autobuild.programs['gem']
204
- return Autobuild.programs['gem']
205
- end
210
+ return Autobuild.programs["gem"] if Autobuild.programs["gem"]
206
211
 
207
- ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
208
- ruby_bindir = RbConfig::CONFIG['bindir']
212
+ ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
213
+ ruby_bindir = RbConfig::CONFIG["bindir"]
209
214
 
210
- candidates = ['gem']
211
- if ruby_bin =~ /^ruby(.+)$/
212
- candidates << "gem#{$1}"
213
- end
215
+ candidates = ["gem"]
216
+ candidates << "gem#{$1}" if ruby_bin =~ /^ruby(.+)$/
214
217
 
215
218
  candidates.each do |gem_name|
216
219
  if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
217
- Autobuild.programs['gem'] = gem_full_path
218
- return Autobuild.programs['gem']
220
+ Autobuild.programs["gem"] = gem_full_path
221
+ return Autobuild.programs["gem"]
219
222
  end
220
223
  end
221
224
 
222
- raise ArgumentError, "cannot find a gem program (tried #{candidates.sort.join(", ")} in #{ruby_bindir})"
225
+ raise ArgumentError,
226
+ "cannot find a gem program (tried "\
227
+ "#{candidates.sort.join(', ')} in #{ruby_bindir})"
223
228
  end
224
229
 
225
230
  private def compile_gem(gem_path, output:, artifacts: [])
226
- artifacts = artifacts.flat_map { |n| ["--artifact", n] }
227
- unless system(Autobuild.tool('ruby'), '-S', guess_gem_program,
228
- 'compile', '--output', output, *artifacts, gem_path)
231
+ artifacts = artifacts.flat_map do |include, n|
232
+ if include
233
+ ["--include", n]
234
+ else
235
+ ["--exclude", n]
236
+ end
237
+ end
238
+ unless system(Autobuild.tool("ruby"), "-S", guess_gem_program,
239
+ "compile", "--output", output, *artifacts, gem_path)
229
240
  raise CompilationFailed, "#{gem_path} failed to compile"
230
241
  end
231
242
  end
@@ -1,17 +1,18 @@
1
- require 'autobuild/environment'
1
+ require "autobuild/environment"
2
2
 
3
3
  module Autoproj
4
4
  module Ops
5
5
  def self.cached_env_path(root_dir)
6
- File.join(root_dir, '.autoproj', 'env.yml')
6
+ File.join(root_dir, ".autoproj", "env.yml")
7
7
  end
8
8
 
9
9
  def self.load_cached_env(root_dir)
10
10
  path = cached_env_path(root_dir)
11
11
  if File.file?(path)
12
- env = YAML.load(File.read(path))
12
+ env = YAML.safe_load(File.read(path))
13
13
  Autobuild::Environment::ExportedEnvironment.new(
14
- env['set'], env['unset'], env['update'])
14
+ env["set"], env["unset"], env["update"]
15
+ )
15
16
  end
16
17
  end
17
18
 
@@ -20,11 +21,11 @@ module Autoproj
20
21
  path = cached_env_path(root_dir)
21
22
  existing =
22
23
  begin
23
- YAML.load(File.read(path))
24
+ YAML.safe_load(File.read(path))
24
25
  rescue Exception
25
26
  end
26
27
 
27
- env = Hash['set' => env.set, 'unset' => env.unset, 'update' => env.update]
28
+ env = Hash["set" => env.set, "unset" => env.unset, "update" => env.update]
28
29
  if env != existing
29
30
  Ops.atomic_write(path) do |io|
30
31
  io.write YAML.dump(env)