autoproj 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) 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 +5 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +185 -182
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +184 -181
  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 +38 -34
  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 +26 -26
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +10 -7
  31. data/lib/autoproj/cli/cache.rb +11 -11
  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 +13 -7
  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 +213 -204
  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 +38 -39
  52. data/lib/autoproj/cli/status.rb +45 -39
  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 +35 -37
  57. data/lib/autoproj/cli/utility.rb +11 -10
  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 +77 -84
  64. data/lib/autoproj/environment.rb +28 -13
  65. data/lib/autoproj/exceptions.rb +9 -3
  66. data/lib/autoproj/find_workspace.rb +20 -25
  67. data/lib/autoproj/git_server_configuration.rb +40 -44
  68. data/lib/autoproj/gitorious.rb +1 -1
  69. data/lib/autoproj/installation_manifest.rb +64 -29
  70. data/lib/autoproj/local_package_set.rb +13 -11
  71. data/lib/autoproj/manifest.rb +132 -130
  72. data/lib/autoproj/metapackage.rb +2 -6
  73. data/lib/autoproj/ops/atomic_write.rb +7 -6
  74. data/lib/autoproj/ops/build.rb +4 -6
  75. data/lib/autoproj/ops/cache.rb +41 -43
  76. data/lib/autoproj/ops/cached_env.rb +5 -4
  77. data/lib/autoproj/ops/configuration.rb +511 -506
  78. data/lib/autoproj/ops/import.rb +73 -63
  79. data/lib/autoproj/ops/install.rb +178 -174
  80. data/lib/autoproj/ops/loader.rb +77 -76
  81. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  82. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  83. data/lib/autoproj/ops/snapshot.rb +250 -247
  84. data/lib/autoproj/ops/tools.rb +76 -78
  85. data/lib/autoproj/ops/watch.rb +6 -6
  86. data/lib/autoproj/ops/which.rb +17 -14
  87. data/lib/autoproj/options.rb +13 -2
  88. data/lib/autoproj/os_package_installer.rb +102 -92
  89. data/lib/autoproj/os_package_query.rb +7 -13
  90. data/lib/autoproj/os_package_resolver.rb +189 -140
  91. data/lib/autoproj/os_repository_installer.rb +4 -4
  92. data/lib/autoproj/os_repository_resolver.rb +8 -6
  93. data/lib/autoproj/package_definition.rb +12 -13
  94. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +10 -10
  95. data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
  96. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  97. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  98. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  99. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  100. data/lib/autoproj/package_managers/manager.rb +8 -3
  101. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  102. data/lib/autoproj/package_managers/pip_manager.rb +20 -22
  103. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  104. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  105. data/lib/autoproj/package_managers/shell_script_manager.rb +32 -22
  106. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  107. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  108. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  109. data/lib/autoproj/package_manifest.rb +27 -26
  110. data/lib/autoproj/package_selection.rb +187 -187
  111. data/lib/autoproj/package_set.rb +127 -113
  112. data/lib/autoproj/python.rb +55 -55
  113. data/lib/autoproj/query_base.rb +20 -14
  114. data/lib/autoproj/reporter.rb +19 -19
  115. data/lib/autoproj/repository_managers/apt.rb +101 -67
  116. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  117. data/lib/autoproj/shell_completion.rb +16 -13
  118. data/lib/autoproj/source_package_query.rb +29 -36
  119. data/lib/autoproj/system.rb +32 -21
  120. data/lib/autoproj/test.rb +127 -104
  121. data/lib/autoproj/variable_expansion.rb +7 -9
  122. data/lib/autoproj/vcs_definition.rb +35 -32
  123. data/lib/autoproj/version.rb +1 -1
  124. data/lib/autoproj/workspace.rb +123 -107
  125. data/lib/autoproj/zsh_completion.rb +8 -9
  126. data/lib/autoproj.rb +53 -55
  127. data/samples/autoproj/init.rb +1 -2
  128. metadata +53 -51
  129. 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['GEM_PATH'] =
31
- (env['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p|
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 'GEM_PATH'
35
- env.init_from_env 'GEM_PATH'
34
+ env.inherit "GEM_PATH"
35
+ env.init_from_env "GEM_PATH"
36
36
 
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)
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, '.gems')
42
+ p_gems = File.join(p, ".gems")
43
43
  if File.directory?(p_gems)
44
- env.push_path 'GEM_PATH', p_gems
45
- env.push_path 'PATH', File.join(p_gems, 'bin')
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['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"
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
- def self.gem_home=(gem_home)
63
- @gem_home = gem_home
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
- if dir = ENV['AUTOBUILD_CACHE_DIR']
70
- dir = File.join(dir, 'gems')
71
- FileUtils.mkdir_p dir
72
- dir
73
- end
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
- if cache = cache_dir
80
- gem_cache_dir = File.join(gem_home, 'cache')
81
- if !File.symlink?(gem_cache_dir) || File.readlink(gem_cache_dir) != cache
82
- FileUtils.mkdir_p gem_home
83
- FileUtils.rm_rf gem_cache_dir
84
- Autoproj.create_symlink(cache, gem_cache_dir)
85
- end
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
- def self.gem_home
91
- @gem_home
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 ||= ['--no-user-install', '--no-format-executable']
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
- if !@gem_fetcher
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['gem']
127
- return Autobuild.programs['gem']
128
- end
126
+ return Autobuild.programs["gem"] if Autobuild.programs["gem"]
129
127
 
130
- ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
131
- ruby_bindir = RbConfig::CONFIG['bindir']
128
+ ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
129
+ ruby_bindir = RbConfig::CONFIG["bindir"]
132
130
 
133
- candidates = ['gem']
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['gem'] = gem_full_path
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(", ")} in #{ruby_bindir})"
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
- if !without_version.empty?
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('ruby', env: ws.env), '-S', Autobuild.tool('gem')]
157
+ base_cmdline = [Autobuild.tool_in_path("ruby", env: ws.env), "-S", Autobuild.tool("gem")]
164
158
  cmdlines = [
165
- [*base_cmdline, 'clean'],
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(" ") }.sort.join(", ")}"
165
+ Autoproj.message " restoring RubyGems: #{gems.map { |g| g.join(' ') }.sort.join(', ')}"
172
166
  cmdlines.each do |c|
173
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c
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('ruby', env: ws.env), '-S', Autobuild.tool('gem'), 'install', *GemManager.default_install_options]
182
- if !GemManager.with_doc
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(" ") }.sort.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 'autoproj', 'osdeps', *c,
198
- env: Hash['GEM_HOME' => Gem.paths.home,
199
- 'GEM_PATH' => Gem.paths.path.join(":")]
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
- install_only: !Autobuild.do_update
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 || '>= 0')
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 prerelease = Array.new
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 :released
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
- if !available_version
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("The build process and/or the packages require some Ruby Gems to be installed", :bold)}
292
- #{Autoproj.color("and you required autoproj to not do it itself", :bold)}
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(" ") }.join("\n ")}
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("Press ENTER to continue ", :bold)}"
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{brew install},
9
- %w{brew install},
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 'autoproj', 'osdeps', command_line).first
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
- def enabled?; !!@enabled end
14
+
15
+ def enabled?
16
+ !!@enabled
17
+ end
15
18
 
16
19
  attr_writer :silent
17
- def silent?; !!@silent end
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{pacman -Sy --needed},
9
- %w{pacman -Sy --needed --noconfirm})
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 'autoproj/python'
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 'PYTHONUSERBASE', pip_home
11
- ws.env.add_path 'PATH', File.join(pip_home, 'bin')
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['AUTOPROJ_PYTHONUSERBASE'] || File.join(ws.prefix_dir, "pip")
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 + ['pip']
26
+ super + ["pip"]
27
27
  end
28
28
 
29
29
  def guess_pip_program
30
- unless ws.config.has_value_for?('USE_PYTHON')
31
- Autoproj::Python.setup_python_configuration_options(ws: ws)
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('USE_PYTHON')
34
- raise ConfigError, "Your current package selection" \
35
- " requires the use of pip, but" \
36
- " the use of python is either unspecified or has been denied, see" \
37
- " 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."
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['pip'] = "pip" unless Autobuild.programs['pip']
45
- Autobuild.programs['pip']
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('pip'), 'install', '--user']
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
- " #{pips.sort.join(', ')}"
58
+ " #{pips.sort.join(', ')}"
60
59
 
61
60
  cmdlines.each do |c|
62
- Autobuild::Subprocess.run 'autoproj', 'osdeps', *c,
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
- # Package manager interface for systems that use pkg (i.e. FreeBSD) as
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{pkg install -y},
9
- %w{pkg install -y})
8
+ %w[pkg install -y],
9
+ %w[pkg install -y])
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -5,10 +5,9 @@ module Autoproj
5
5
  class PortManager < ShellScriptManager
6
6
  def initialize(ws)
7
7
  super(ws, true,
8
- %w{port install},
9
- %w{port install})
8
+ %w[port install],
9
+ %w[port install])
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('/tmp/autoproj_osdeps_lock', 'w') do |lock_io|
9
- begin
10
- until lock_io.flock(File::LOCK_EX | File::LOCK_NB)
11
- Autoproj.message " waiting for other autoproj "\
12
- "instances to finish their osdeps "\
13
- "installation"
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('sudo', env: env)
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 'autoproj', 'osdeps', *command_line
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
- auto_install_cmd, needs_root = true)
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
- user_install_cmd: self.user_install_cmd)
111
+ user_install_cmd: self.user_install_cmd)
112
112
  if user_install_cmd
113
- user_install_cmd.join(" ") + " " + os_packages.join("' '")
114
- else generate_auto_os_script(os_packages)
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
- auto_install_cmd: self.auto_install_cmd)
129
- auto_install_cmd.join(" ") + " " + os_packages.join("' '")
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
- #{Autoproj.color('\nIf these packages are already installed, simply ignore this message\n', :red) unless respond_to?(:filter_uptodate_packages)}
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
- auto_install_cmd: self.auto_install_cmd,
187
- user_install_cmd: self.user_install_cmd)
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("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)}
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
- return false
28
+ false
29
29
  else
30
30
  osdeps = osdeps.to_set
31
31
  osdeps -= @installed_osdeps
32
- if !osdeps.empty?
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
- return result
34
+ result
37
35
  end
38
36
  end
39
37
  end
40
38
  end
41
39
  end
42
-