autoproj 2.16.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb77cb6d5c3c156ae3d665933ec7380f5b0ae491767b87c6e6f25c9c96966885
4
- data.tar.gz: 1474ca4f6e00f46dc70631f25c70e0cf0340d85f62101053117faf79ed65bd21
3
+ metadata.gz: e19c3ca78afb4d42f58b65effbed3ff1aed2fe83210e6fa2ee0d46ed12793430
4
+ data.tar.gz: 2b1a0802811156df47ac64a869f9ccf1de2ba5734d6d0316d2f857a5b18fa638
5
5
  SHA512:
6
- metadata.gz: e1fb865f1ecdfa9d290c9dbb6048e601ca99f8e691643a36ada2528137c47819a30172e7abf9bd3d5cd91c44148fa0b8a8793b4a6783fb9bee52661cad960777
7
- data.tar.gz: 6c9b821c1158e70bdb9a98536998dafe6270f4bb778646171d4691cc82fe0ce9828e263fda268ebaeced020cc7dcdfd30a33b9e5ea5593774f1ffe39eb0326c7
6
+ metadata.gz: b46ab523d1b83ef75128c8707d65899b8eb770706b391252bb1826578acc6505ad67169964ef9e9c1c7653962d8ed50ff5e20a6b48d765a2298afbcdf5c973c1
7
+ data.tar.gz: 21cc35037beb50b30ee0879c680b9c68ef401c07c394270b8d1e81ae678f8e9c931b53b35bc205b877224b440e745674cd48e49cf566aef575332324a309516c
@@ -19,7 +19,9 @@ jobs:
19
19
  uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Configure bundler without 'vscode'
23
+ run: bundle config set --local without vscode
22
24
  - name: Install dependencies
23
25
  run: bundle install
24
26
  - name: Run rubocop
25
- run: bundle exec rubocop
27
+ run: bundle exec rubocop
@@ -19,6 +19,8 @@ jobs:
19
19
  uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Configure bundler without 'vscode'
23
+ run: bundle config set --local without vscode
22
24
  - name: Install dependencies
23
25
  run: bundle install
24
26
  - name: Run tests
data/Gemfile CHANGED
@@ -2,12 +2,15 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "autobuild", git: "https://github.com/rock-core/autobuild", branch: "master"
4
4
 
5
+ group :dev do
6
+ gem "rubocop", "~> 1.28.0"
7
+ gem "rubocop-rock"
8
+ end
9
+
5
10
  group :vscode do
6
11
  gem "debase", ">= 0.2.2.beta10"
7
12
  gem "pry"
8
13
  gem "pry-byebug"
9
- gem "rubocop", ">= 0.6.0"
10
- gem "rubocop-rock"
11
14
  gem "ruby-debug-ide", ">= 0.6.0"
12
15
  gem "solargraph"
13
16
  end
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ task "bootstrap" do
20
20
  %w[bootstrap install].each do |install_script|
21
21
  bootstrap_code = File.read(File.join(Dir.pwd, "bin", "autoproj_#{install_script}.in"))
22
22
  .gsub("require 'autoproj/ops/install'", autoproj_ops_install)
23
+ .gsub('#{Autoproj::VERSION}', Autoproj::VERSION) # rubocop:disable Lint/InterpolationCheck
23
24
  File.open(File.join(Dir.pwd, "bin", "autoproj_#{install_script}"), "w") do |io|
24
25
  io.write bootstrap_code
25
26
  end
data/autoproj.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
38
38
  s.add_runtime_dependency "tty-spinner", "~> 0.9.0"
39
39
  s.add_runtime_dependency "utilrb", "~> 3.0.0", ">= 3.0.0"
40
40
  s.add_runtime_dependency "xdg", "= 2.2.5"
41
- s.add_development_dependency "aruba"
41
+ s.add_development_dependency "aruba", "~> 2.1.0"
42
42
  s.add_development_dependency "flexmock", "~> 2.0", ">= 2.0.0"
43
43
  s.add_development_dependency "minitest", "~> 5.0", ">= 5.0"
44
44
  s.add_development_dependency "simplecov"
@@ -97,7 +97,9 @@ module Autoproj
97
97
  @ruby_executable = config["ruby_executable"]
98
98
  @local = false
99
99
 
100
- install_gems_in_gem_user_dir unless @gems_install_path
100
+ @gems_install_path ||= default_gems_install_path
101
+ @gems_install_path = File.expand_path(@gems_install_path)
102
+
101
103
  env["GEM_HOME"] = [gems_gem_home]
102
104
  env["GEM_PATH"] = [gems_gem_home]
103
105
  end
@@ -171,24 +173,17 @@ module Autoproj
171
173
  # (see #local?)
172
174
  attr_writer :local
173
175
 
174
- # The user-wide place where RubyGems installs gems
175
- def self.dot_gem_dir
176
- if Gem.respond_to?(:data_home) # Debian 11+
177
- File.join(Gem.data_home, "gem")
178
- else
179
- File.join(Gem.user_home, ".gem")
180
- end
181
- end
182
-
183
- # The version and platform-specific suffix under {#dot_gem_dir}
176
+ # The version and platform-specific suffix
184
177
  #
185
178
  # This is also the suffix used by bundler to install gems
186
179
  def self.gems_path_suffix
187
- @gems_path_suffix ||=
188
- Pathname
189
- .new(Gem.user_dir)
190
- .relative_path_from(Pathname.new(dot_gem_dir))
191
- .to_s
180
+ return @gems_path_suffix if @gem_path_suffix
181
+
182
+ parts = [Gem.ruby_engine]
183
+ unless RbConfig::CONFIG["ruby_version"].empty?
184
+ parts << RbConfig::CONFIG["ruby_version"]
185
+ end
186
+ @gems_path_suffix = File.join parts
192
187
  end
193
188
 
194
189
  # The path into which the workspace's gems should be installed
@@ -219,21 +214,21 @@ module Autoproj
219
214
  end
220
215
  end
221
216
 
222
- # Install autoproj in Gem's default user dir
223
- def install_gems_in_gem_user_dir
217
+ # Get autoproj's default path for installing gems
218
+ def default_gems_install_path
224
219
  xdg_default_gem_path = xdg_var("XDG_DATA_HOME",
225
220
  File.join(Dir.home, ".local", "share", "autoproj", "gems"))
226
221
  default_gem_path = File.join(
227
222
  Dir.home, ".autoproj", "gems"
228
223
  )
229
- @gems_install_path =
230
- if File.directory?(xdg_default_gem_path)
231
- xdg_default_gem_path
232
- elsif File.directory?(default_gem_path)
233
- default_gem_path
234
- else
235
- xdg_default_gem_path
236
- end
224
+
225
+ if File.directory?(xdg_default_gem_path)
226
+ xdg_default_gem_path
227
+ elsif File.directory?(default_gem_path)
228
+ default_gem_path
229
+ else
230
+ xdg_default_gem_path
231
+ end
237
232
  end
238
233
 
239
234
  # Whether autoproj should prefer OS-independent packages over their
@@ -269,15 +264,22 @@ module Autoproj
269
264
  # @param [String] autoproj_version a constraint on the autoproj version
270
265
  # that should be used
271
266
  # @return [String]
272
- def default_gemfile_contents(autoproj_version = ">= 2.0.0")
267
+ def default_gemfile_contents(autoproj_version = ">= 2.17.0")
273
268
  ["source \"#{gem_source}\"",
274
269
  "ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
275
- "gem \"autoproj\", \"#{autoproj_version}\"",
276
- "gem \"utilrb\", \">= 3.0.1\""].join("\n")
270
+ "gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
271
+ end
272
+
273
+ def load_yaml(contents)
274
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
275
+ YAML.safe_load(contents, permitted_classes: [Symbol])
276
+ else
277
+ YAML.safe_load(contents, [Symbol])
278
+ end
277
279
  end
278
280
 
279
281
  def add_seed_config(path)
280
- @config.merge!(YAML.safe_load(File.read(path), [Symbol]))
282
+ @config.merge!(load_yaml(File.read(path)))
281
283
  end
282
284
 
283
285
  # Parse the provided command line options and returns the non-options
@@ -297,11 +299,12 @@ module Autoproj
297
299
  @gem_source = url
298
300
  end
299
301
  opt.on "--gems-path=PATH", "install gems under this path instead "\
300
- "of ~/.autoproj/gems" do |path|
301
- self.gems_install_path = path
302
+ "of #{default_gems_install_path} (do not use with --public-gems)" do |path|
303
+ @gems_install_path = path
302
304
  end
303
- opt.on "--public-gems", "install gems in the default gem location" do
304
- install_gems_in_gem_user_dir
305
+ opt.on "--public-gems", "install gems in the default gem location: #{default_gems_install_path}"\
306
+ " (do not use with --gems-path)" do
307
+ @gems_install_path = default_gems_install_path
305
308
  end
306
309
  opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
307
310
  "string as a version constraint for bundler" do |version|
@@ -323,6 +326,7 @@ module Autoproj
323
326
  "when reinstalling an existing autoproj workspace, do not "\
324
327
  "use the config in .autoproj/ as seed" do
325
328
  @config.clear
329
+ @config["bundler_version"] = Install.default_bundler_version
326
330
  end
327
331
  opt.on "--seed-config=PATH", String, "path to a seed file that "\
328
332
  "should be used to initialize the configuration" do |path|
@@ -756,11 +760,21 @@ require 'bundler/setup'
756
760
  end
757
761
 
758
762
  @config = config
763
+ @config["bundler_version"] ||= self.class.default_bundler_version
764
+
759
765
  %w[gems_install_path prefer_indep_over_os_packages].each do |flag|
760
766
  instance_variable_set "@#{flag}", config.fetch(flag, false)
761
767
  end
762
768
  end
763
769
 
770
+ def self.default_bundler_version
771
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6.0")
772
+ "2.3.6"
773
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0")
774
+ "2.4.22"
775
+ end
776
+ end
777
+
764
778
  def save_config
765
779
  config["gems_install_path"] = gems_install_path
766
780
  config["prefer_indep_over_os_packages"] = prefer_indep_over_os_packages?
data/bin/autoproj_install CHANGED
@@ -97,7 +97,9 @@ module Autoproj
97
97
  @ruby_executable = config["ruby_executable"]
98
98
  @local = false
99
99
 
100
- install_gems_in_gem_user_dir unless @gems_install_path
100
+ @gems_install_path ||= default_gems_install_path
101
+ @gems_install_path = File.expand_path(@gems_install_path)
102
+
101
103
  env["GEM_HOME"] = [gems_gem_home]
102
104
  env["GEM_PATH"] = [gems_gem_home]
103
105
  end
@@ -171,24 +173,17 @@ module Autoproj
171
173
  # (see #local?)
172
174
  attr_writer :local
173
175
 
174
- # The user-wide place where RubyGems installs gems
175
- def self.dot_gem_dir
176
- if Gem.respond_to?(:data_home) # Debian 11+
177
- File.join(Gem.data_home, "gem")
178
- else
179
- File.join(Gem.user_home, ".gem")
180
- end
181
- end
182
-
183
- # The version and platform-specific suffix under {#dot_gem_dir}
176
+ # The version and platform-specific suffix
184
177
  #
185
178
  # This is also the suffix used by bundler to install gems
186
179
  def self.gems_path_suffix
187
- @gems_path_suffix ||=
188
- Pathname
189
- .new(Gem.user_dir)
190
- .relative_path_from(Pathname.new(dot_gem_dir))
191
- .to_s
180
+ return @gems_path_suffix if @gem_path_suffix
181
+
182
+ parts = [Gem.ruby_engine]
183
+ unless RbConfig::CONFIG["ruby_version"].empty?
184
+ parts << RbConfig::CONFIG["ruby_version"]
185
+ end
186
+ @gems_path_suffix = File.join parts
192
187
  end
193
188
 
194
189
  # The path into which the workspace's gems should be installed
@@ -219,21 +214,21 @@ module Autoproj
219
214
  end
220
215
  end
221
216
 
222
- # Install autoproj in Gem's default user dir
223
- def install_gems_in_gem_user_dir
217
+ # Get autoproj's default path for installing gems
218
+ def default_gems_install_path
224
219
  xdg_default_gem_path = xdg_var("XDG_DATA_HOME",
225
220
  File.join(Dir.home, ".local", "share", "autoproj", "gems"))
226
221
  default_gem_path = File.join(
227
222
  Dir.home, ".autoproj", "gems"
228
223
  )
229
- @gems_install_path =
230
- if File.directory?(xdg_default_gem_path)
231
- xdg_default_gem_path
232
- elsif File.directory?(default_gem_path)
233
- default_gem_path
234
- else
235
- xdg_default_gem_path
236
- end
224
+
225
+ if File.directory?(xdg_default_gem_path)
226
+ xdg_default_gem_path
227
+ elsif File.directory?(default_gem_path)
228
+ default_gem_path
229
+ else
230
+ xdg_default_gem_path
231
+ end
237
232
  end
238
233
 
239
234
  # Whether autoproj should prefer OS-independent packages over their
@@ -269,15 +264,22 @@ module Autoproj
269
264
  # @param [String] autoproj_version a constraint on the autoproj version
270
265
  # that should be used
271
266
  # @return [String]
272
- def default_gemfile_contents(autoproj_version = ">= 2.0.0")
267
+ def default_gemfile_contents(autoproj_version = ">= 2.17.0")
273
268
  ["source \"#{gem_source}\"",
274
269
  "ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
275
- "gem \"autoproj\", \"#{autoproj_version}\"",
276
- "gem \"utilrb\", \">= 3.0.1\""].join("\n")
270
+ "gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
271
+ end
272
+
273
+ def load_yaml(contents)
274
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
275
+ YAML.safe_load(contents, permitted_classes: [Symbol])
276
+ else
277
+ YAML.safe_load(contents, [Symbol])
278
+ end
277
279
  end
278
280
 
279
281
  def add_seed_config(path)
280
- @config.merge!(YAML.safe_load(File.read(path), [Symbol]))
282
+ @config.merge!(load_yaml(File.read(path)))
281
283
  end
282
284
 
283
285
  # Parse the provided command line options and returns the non-options
@@ -297,11 +299,12 @@ module Autoproj
297
299
  @gem_source = url
298
300
  end
299
301
  opt.on "--gems-path=PATH", "install gems under this path instead "\
300
- "of ~/.autoproj/gems" do |path|
301
- self.gems_install_path = path
302
+ "of #{default_gems_install_path} (do not use with --public-gems)" do |path|
303
+ @gems_install_path = path
302
304
  end
303
- opt.on "--public-gems", "install gems in the default gem location" do
304
- install_gems_in_gem_user_dir
305
+ opt.on "--public-gems", "install gems in the default gem location: #{default_gems_install_path}"\
306
+ " (do not use with --gems-path)" do
307
+ @gems_install_path = default_gems_install_path
305
308
  end
306
309
  opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
307
310
  "string as a version constraint for bundler" do |version|
@@ -323,6 +326,7 @@ module Autoproj
323
326
  "when reinstalling an existing autoproj workspace, do not "\
324
327
  "use the config in .autoproj/ as seed" do
325
328
  @config.clear
329
+ @config["bundler_version"] = Install.default_bundler_version
326
330
  end
327
331
  opt.on "--seed-config=PATH", String, "path to a seed file that "\
328
332
  "should be used to initialize the configuration" do |path|
@@ -756,11 +760,21 @@ require 'bundler/setup'
756
760
  end
757
761
 
758
762
  @config = config
763
+ @config["bundler_version"] ||= self.class.default_bundler_version
764
+
759
765
  %w[gems_install_path prefer_indep_over_os_packages].each do |flag|
760
766
  instance_variable_set "@#{flag}", config.fetch(flag, false)
761
767
  end
762
768
  end
763
769
 
770
+ def self.default_bundler_version
771
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6.0")
772
+ "2.3.6"
773
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0")
774
+ "2.4.22"
775
+ end
776
+ end
777
+
764
778
  def save_config
765
779
  config["gems_install_path"] = gems_install_path
766
780
  config["prefer_indep_over_os_packages"] = prefer_indep_over_os_packages?
@@ -107,6 +107,8 @@ module Autoproj
107
107
 
108
108
  pkg_autobuild, pkg_os = partition_package(name)
109
109
  pkg_autobuild.each do |pkg|
110
+ next if ws.manifest.ignored?(pkg)
111
+
110
112
  super(pkg)
111
113
  end
112
114
  @os_packages.merge(pkg_os.to_set)
@@ -268,11 +268,6 @@ module Autoproj
268
268
  set("parallel_import_level", level)
269
269
  end
270
270
 
271
- # The user-wide place where RubyGems installs gems
272
- def self.dot_gem_dir
273
- Ops::Install.dot_gem_dir
274
- end
275
-
276
271
  # The Ruby platform and version-specific subdirectory used by bundler and rubygem
277
272
  def self.gems_path_suffix
278
273
  Ops::Install.gems_path_suffix
@@ -93,10 +93,17 @@ ruby25:
93
93
  default: ignore # we assume that if the user has a ruby 2.5 runtime, it is usable
94
94
 
95
95
  ruby26:
96
- default: ignore # we assume that if the user has a ruby 2.5 runtime, it is usable
96
+ default: ignore # we assume that if the user has a ruby 2.6 runtime, it is usable
97
97
 
98
98
  ruby27:
99
- default: ignore # we assume that if the user has a ruby 2.5 runtime, it is usable
99
+ default: ignore # we assume that if the user has a ruby 2.7 runtime, it is usable
100
+
101
+ ruby30:
102
+ default: ignore # we assume that if the user has a ruby 3.0 runtime, it is usable
103
+
104
+ ruby32:
105
+ default: ignore # we assume that if the user has a ruby 3.0 runtime, it is usable
106
+
100
107
 
101
108
  build-essential:
102
109
  debian,ubuntu: build-essential
@@ -73,7 +73,8 @@ module Autoproj
73
73
  disabled_methods: [],
74
74
  config: Autoproj.config,
75
75
  fallback_to_http: nil,
76
- lazy: false)
76
+ lazy: false,
77
+ add_suffix: true)
77
78
 
78
79
  disabled_methods = Array(disabled_methods)
79
80
 
@@ -100,7 +101,7 @@ module Autoproj
100
101
  end
101
102
 
102
103
  Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options|
103
- url += ".git" if url !~ /\.git$/
104
+ url += ".git" if add_suffix && url !~ /\.git$/
104
105
  url = "/#{url}" if url !~ /^\//
105
106
 
106
107
  unless GIT_SERVER_CONFIG_VARS.all? { |v| config.has_value_for?("#{name}#{v}") }
@@ -1015,7 +1015,8 @@ module Autoproj
1015
1015
  "no package.xml file" unless File.file?(manifest_path)
1016
1016
 
1017
1017
  manifest = PackageManifest.load(package, manifest_path,
1018
- ros_manifest: true)
1018
+ ros_manifest: true,
1019
+ condition_context: @ws.env)
1019
1020
  else
1020
1021
  manifest_paths = [File.join(package.srcdir, "manifest.xml")]
1021
1022
  if package_set.local_dir
@@ -1028,7 +1029,8 @@ module Autoproj
1028
1029
  end
1029
1030
  if manifest_path
1030
1031
  manifest = PackageManifest.load(package, manifest_path,
1031
- ros_manifest: false)
1032
+ ros_manifest: false,
1033
+ condition_context: @ws.config)
1032
1034
  end
1033
1035
  end
1034
1036
 
@@ -1086,7 +1088,7 @@ module Autoproj
1086
1088
 
1087
1089
  # Remove any OSDeps override that has previously been added with
1088
1090
  # #add_osdeps_overrides
1089
- def remove_osdeps_overrides(osdep_name)
1091
+ def remove_osdeps_overrides(osdeps_name)
1090
1092
  @osdeps_overrides.delete(osdeps_name.to_s)
1091
1093
  end
1092
1094
 
@@ -1,37 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tempfile"
4
+ require "fileutils"
5
+
1
6
  module Autoproj
2
7
  module Ops
8
+ # Write to a file atomically. Useful for situations where you don't
9
+ # want other processes or threads to see half-written files.
10
+ #
11
+ # File.atomic_write('important.file') do |file|
12
+ # file.write('hello')
13
+ # end
14
+ #
15
+ # This method needs to create a temporary file. By default it will create it
16
+ # in the same directory as the destination file. If you don't like this
17
+ # behavior you can provide a different directory but it must be on the
18
+ # same physical filesystem as the file you're trying to write.
19
+ #
20
+ # File.atomic_write('/data/something.important', '/data/tmp') do |file|
21
+ # file.write('hello')
22
+ # end
23
+ #
3
24
  # Shamelessly stolen from ActiveSupport
4
- def self.atomic_write(file_name, temp_dir = Dir.tmpdir)
5
- require "tempfile" unless defined?(Tempfile)
6
- require "fileutils" unless defined?(FileUtils)
25
+ def self.atomic_write(file_name, temp_dir = File.dirname(file_name))
26
+ Tempfile.open(".#{File.basename(file_name)}", temp_dir) do |temp_file|
27
+ temp_file.binmode
28
+ yield temp_file
29
+ temp_file.close
7
30
 
8
- temp_file = Tempfile.new(File.basename(file_name), temp_dir)
9
- yield temp_file
10
- temp_file.flush
11
- begin temp_file.fsync
12
- rescue NotImplementedError
13
- end
14
- temp_file.close
31
+ old_stat = begin
32
+ # Get original file permissions
33
+ File.stat(file_name)
34
+ rescue Errno::ENOENT
35
+ # If not possible, probe which are the default permissions in the
36
+ # destination directory.
37
+ probe_stat_in(File.dirname(file_name))
38
+ end
15
39
 
16
- begin
17
- # Get original file permissions
18
- old_stat = File.stat(file_name)
19
- rescue Errno::ENOENT
20
- # No old permissions, write a temp file to determine the defaults
21
- check_name = File.join(
22
- File.dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"
23
- )
24
- File.open(check_name, "w") {}
25
- old_stat = File.stat(check_name)
26
- File.unlink(check_name)
40
+ if old_stat
41
+ # Set correct permissions on new file
42
+ begin
43
+ File.chown(old_stat.uid, old_stat.gid, temp_file.path)
44
+ # This operation will affect filesystem ACL's
45
+ File.chmod(old_stat.mode, temp_file.path)
46
+ rescue Errno::EPERM, Errno::EACCES
47
+ # Changing file ownership failed, moving on.
48
+ end
49
+ end
50
+
51
+ # Overwrite original file with temp file
52
+ File.rename(temp_file.path, file_name)
27
53
  end
54
+ end
28
55
 
29
- # Overwrite original file with temp file
30
- FileUtils.mv(temp_file.path, file_name)
56
+ # Private utility method.
57
+ def self.probe_stat_in(dir) # :nodoc:
58
+ basename = [
59
+ ".permissions_check",
60
+ Thread.current.object_id,
61
+ Process.pid,
62
+ rand(1000000)
63
+ ].join(".")
31
64
 
32
- # Set correct permissions on new file
33
- File.chown(old_stat.uid, old_stat.gid, file_name)
34
- File.chmod(old_stat.mode, file_name)
65
+ file_name = File.join(dir, basename)
66
+ FileUtils.touch(file_name)
67
+ File.stat(file_name)
68
+ rescue Errno::ENOENT
69
+ file_name = nil
70
+ ensure
71
+ FileUtils.rm_f(file_name) if file_name
35
72
  end
36
73
  end
37
74
  end
@@ -585,7 +585,7 @@ module Autoproj
585
585
  when OSPackageResolver::UNKNOWN_OS
586
586
  manifest.exclude_package(osdep_name, "the current operating system is unknown to autoproj")
587
587
  when OSPackageResolver::WRONG_OS
588
- manifest.exclude_package(osdep_name, "#{osdep_name} is defined, but not for this operating system")
588
+ manifest.exclude_package(osdep_name, "#{osdep_name} is defined in #{os_package_resolver.source_of(osdep_name)}, but not for this operating system")
589
589
  when OSPackageResolver::NONEXISTENT
590
590
  manifest.exclude_package(osdep_name, "#{osdep_name} is marked as unavailable for this operating system")
591
591
  end
@@ -87,7 +87,9 @@ module Autoproj
87
87
  @ruby_executable = config["ruby_executable"]
88
88
  @local = false
89
89
 
90
- install_gems_in_gem_user_dir unless @gems_install_path
90
+ @gems_install_path ||= default_gems_install_path
91
+ @gems_install_path = File.expand_path(@gems_install_path)
92
+
91
93
  env["GEM_HOME"] = [gems_gem_home]
92
94
  env["GEM_PATH"] = [gems_gem_home]
93
95
  end
@@ -161,24 +163,17 @@ module Autoproj
161
163
  # (see #local?)
162
164
  attr_writer :local
163
165
 
164
- # The user-wide place where RubyGems installs gems
165
- def self.dot_gem_dir
166
- if Gem.respond_to?(:data_home) # Debian 11+
167
- File.join(Gem.data_home, "gem")
168
- else
169
- File.join(Gem.user_home, ".gem")
170
- end
171
- end
172
-
173
- # The version and platform-specific suffix under {#dot_gem_dir}
166
+ # The version and platform-specific suffix
174
167
  #
175
168
  # This is also the suffix used by bundler to install gems
176
169
  def self.gems_path_suffix
177
- @gems_path_suffix ||=
178
- Pathname
179
- .new(Gem.user_dir)
180
- .relative_path_from(Pathname.new(dot_gem_dir))
181
- .to_s
170
+ return @gems_path_suffix if @gem_path_suffix
171
+
172
+ parts = [Gem.ruby_engine]
173
+ unless RbConfig::CONFIG["ruby_version"].empty?
174
+ parts << RbConfig::CONFIG["ruby_version"]
175
+ end
176
+ @gems_path_suffix = File.join parts
182
177
  end
183
178
 
184
179
  # The path into which the workspace's gems should be installed
@@ -209,21 +204,21 @@ module Autoproj
209
204
  end
210
205
  end
211
206
 
212
- # Install autoproj in Gem's default user dir
213
- def install_gems_in_gem_user_dir
207
+ # Get autoproj's default path for installing gems
208
+ def default_gems_install_path
214
209
  xdg_default_gem_path = xdg_var("XDG_DATA_HOME",
215
210
  File.join(Dir.home, ".local", "share", "autoproj", "gems"))
216
211
  default_gem_path = File.join(
217
212
  Dir.home, ".autoproj", "gems"
218
213
  )
219
- @gems_install_path =
220
- if File.directory?(xdg_default_gem_path)
221
- xdg_default_gem_path
222
- elsif File.directory?(default_gem_path)
223
- default_gem_path
224
- else
225
- xdg_default_gem_path
226
- end
214
+
215
+ if File.directory?(xdg_default_gem_path)
216
+ xdg_default_gem_path
217
+ elsif File.directory?(default_gem_path)
218
+ default_gem_path
219
+ else
220
+ xdg_default_gem_path
221
+ end
227
222
  end
228
223
 
229
224
  # Whether autoproj should prefer OS-independent packages over their
@@ -259,15 +254,22 @@ module Autoproj
259
254
  # @param [String] autoproj_version a constraint on the autoproj version
260
255
  # that should be used
261
256
  # @return [String]
262
- def default_gemfile_contents(autoproj_version = ">= 2.0.0")
257
+ def default_gemfile_contents(autoproj_version = ">= #{Autoproj::VERSION}")
263
258
  ["source \"#{gem_source}\"",
264
259
  "ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
265
- "gem \"autoproj\", \"#{autoproj_version}\"",
266
- "gem \"utilrb\", \">= 3.0.1\""].join("\n")
260
+ "gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
261
+ end
262
+
263
+ def load_yaml(contents)
264
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
265
+ YAML.safe_load(contents, permitted_classes: [Symbol])
266
+ else
267
+ YAML.safe_load(contents, [Symbol])
268
+ end
267
269
  end
268
270
 
269
271
  def add_seed_config(path)
270
- @config.merge!(YAML.safe_load(File.read(path), [Symbol]))
272
+ @config.merge!(load_yaml(File.read(path)))
271
273
  end
272
274
 
273
275
  # Parse the provided command line options and returns the non-options
@@ -287,11 +289,12 @@ module Autoproj
287
289
  @gem_source = url
288
290
  end
289
291
  opt.on "--gems-path=PATH", "install gems under this path instead "\
290
- "of ~/.autoproj/gems" do |path|
291
- self.gems_install_path = path
292
+ "of #{default_gems_install_path} (do not use with --public-gems)" do |path|
293
+ @gems_install_path = path
292
294
  end
293
- opt.on "--public-gems", "install gems in the default gem location" do
294
- install_gems_in_gem_user_dir
295
+ opt.on "--public-gems", "install gems in the default gem location: #{default_gems_install_path}"\
296
+ " (do not use with --gems-path)" do
297
+ @gems_install_path = default_gems_install_path
295
298
  end
296
299
  opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
297
300
  "string as a version constraint for bundler" do |version|
@@ -313,6 +316,7 @@ module Autoproj
313
316
  "when reinstalling an existing autoproj workspace, do not "\
314
317
  "use the config in .autoproj/ as seed" do
315
318
  @config.clear
319
+ @config["bundler_version"] = Install.default_bundler_version
316
320
  end
317
321
  opt.on "--seed-config=PATH", String, "path to a seed file that "\
318
322
  "should be used to initialize the configuration" do |path|
@@ -746,11 +750,21 @@ require 'bundler/setup'
746
750
  end
747
751
 
748
752
  @config = config
753
+ @config["bundler_version"] ||= self.class.default_bundler_version
754
+
749
755
  %w[gems_install_path prefer_indep_over_os_packages].each do |flag|
750
756
  instance_variable_set "@#{flag}", config.fetch(flag, false)
751
757
  end
752
758
  end
753
759
 
760
+ def self.default_bundler_version
761
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6.0")
762
+ "2.3.6"
763
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0")
764
+ "2.4.22"
765
+ end
766
+ end
767
+
754
768
  def save_config
755
769
  config["gems_install_path"] = gems_install_path
756
770
  config["prefer_indep_over_os_packages"] = prefer_indep_over_os_packages?
@@ -185,7 +185,8 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
185
185
  when "gem" then modes << "gem"
186
186
  when "pip" then modes << "pip"
187
187
  when "os" then modes << "os"
188
- when "none" then # rubocop:disable Lint/EmptyWhen
188
+ when "none" then
189
+ # noop
189
190
  else
190
191
  if package_managers.key?(str)
191
192
  modes << str
@@ -16,9 +16,10 @@ module Autoproj
16
16
  # @param [Boolean] ros_manifest whether the file follows the ROS format
17
17
  # @return [PackageManifest]
18
18
  # @see parse
19
- def self.load(package, file, ros_manifest: false)
19
+ def self.load(package, file, ros_manifest: false, condition_context: nil)
20
20
  loader_class = ros_manifest ? RosPackageManifest::Loader : Loader
21
- parse(package, File.read(file), path: file, loader_class: loader_class)
21
+ parse(package, File.read(file), path: file, loader_class: loader_class,
22
+ condition_context: condition_context)
22
23
  end
23
24
 
24
25
  # Create a PackageManifest object from the XML content provided as a
@@ -30,15 +31,22 @@ module Autoproj
30
31
  # @param [Boolean] ros_manifest whether the file follows the ROS format
31
32
  # @return [PackageManifest]
32
33
  # @see load
33
- def self.parse(package, contents,
34
- path: "<loaded from string>", loader_class: Loader)
34
+ def self.parse(
35
+ package, contents,
36
+ path: "<loaded from string>", loader_class: Loader,
37
+ condition_context: nil
38
+ )
35
39
  manifest = loader_class::MANIFEST_CLASS.new(package, path)
36
- loader = loader_class.new(path, manifest)
40
+ loader = loader_class.new(path, manifest,
41
+ condition_context: condition_context)
37
42
  begin
38
43
  REXML::Document.parse_stream(contents, loader)
39
44
  rescue REXML::ParseException => e
40
45
  raise Autobuild::PackageException.new(package.name, "prepare"),
41
- "invalid #{file}: #{e.message}"
46
+ "invalid #{path}: #{e.message}"
47
+ rescue Autoproj::ConfigError => e
48
+ raise Autobuild::PackageException.new(package.name, "prepare"),
49
+ "invalid #{path}: #{e.message}"
42
50
  end
43
51
  manifest
44
52
  end
@@ -181,10 +189,50 @@ module Autoproj
181
189
 
182
190
  MANIFEST_CLASS = PackageManifest
183
191
 
184
- def initialize(path, manifest)
192
+ def self.expand_configuration_variable(var, config)
193
+ prefix = var[0, 1]
194
+ var = var[1..-1] if prefix == "$"
195
+
196
+ if var.start_with?("operating_system_name_")
197
+ os = config.get("operating_system", nil)
198
+ return "" if os.nil?
199
+
200
+ os_names, = os
201
+ return "" unless os_names.any? do |name|
202
+ var == "operating_system_name_#{name}"
203
+ end
204
+
205
+ return "true"
206
+ end
207
+
208
+ if var.start_with?("operating_system_version_")
209
+ os = config.get("operating_system", nil)
210
+ return "" if os.nil?
211
+
212
+ _, os_versions = os
213
+ return "" unless os_versions.any? do |ver|
214
+ var == "operating_system_version_#{ver.gsub(/[.,+-]/, '_')}"
215
+ end
216
+
217
+ return "true"
218
+ end
219
+
220
+ config.get(var)
221
+ end
222
+
223
+ def initialize(path, manifest, condition_context: Configuration.new)
185
224
  super()
186
225
  @path = path
187
226
  @manifest = manifest
227
+ @condition_parser = RosConditionParser.new do |var|
228
+ Loader.expand_configuration_variable(var, condition_context)
229
+ end
230
+ end
231
+
232
+ def handle_condition(expr)
233
+ return true unless expr && !expr.empty?
234
+
235
+ @condition_parser.evaluate(expr)
188
236
  end
189
237
 
190
238
  def parse_depend_tag(tag_name, attributes, modes: [], optional: false)
@@ -195,6 +243,8 @@ module Autoproj
195
243
  "without a 'package' attribute"
196
244
  end
197
245
 
246
+ return unless handle_condition(attributes["condition"])
247
+
198
248
  if (tag_modes = attributes["modes"])
199
249
  modes += tag_modes.split(",")
200
250
  end
@@ -8,15 +8,13 @@ module Autoproj
8
8
  # Parses a conditional expression
9
9
  # Syntax and rules as defined in https://www.ros.org/reps/rep-0149.html#id20
10
10
  class RosConditionParser < Parslet::Parser
11
- def initialize(context)
12
- @context = context
11
+ def initialize(&expander)
12
+ @expander = expander
13
13
  super()
14
14
  end
15
15
 
16
16
  def expand(var)
17
- Autoproj.expand(var, @context)
18
- rescue StandardError
19
- ""
17
+ @expander.call(var)
20
18
  end
21
19
 
22
20
  # Evaluates the Abstract Syntax Tree generated by the parser
@@ -23,10 +23,13 @@ module Autoproj
23
23
  buildtool_depend buildtool_export_depend
24
24
  exec_depend test_depend run_depend doc_depend].to_set.freeze
25
25
 
26
- def initialize(path, manifest)
26
+ def initialize(path, manifest, condition_context: {})
27
27
  super
28
- @env = manifest.package.ws.env
29
- @condition_parser = RosConditionParser.new(@env)
28
+ @condition_parser = RosConditionParser.new do |var|
29
+ Autoproj.expand(var, condition_context)
30
+ rescue StandardError
31
+ ""
32
+ end
30
33
  end
31
34
 
32
35
  def tag_start(name, attributes)
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "2.16.0"
2
+ VERSION = "2.18.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-11 00:00:00.000000000 Z
11
+ date: 2025-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autobuild
@@ -202,16 +202,16 @@ dependencies:
202
202
  name: aruba
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
205
+ - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '0'
207
+ version: 2.1.0
208
208
  type: :development
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">="
212
+ - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '0'
214
+ version: 2.1.0
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: flexmock
217
217
  requirement: !ruby/object:Gem::Requirement