diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2022-02-04 09:56:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2022-02-07 14:02:25 -0800 |
commit | 1e1d5c30502f4fc05fb324a2261145029aeba3f6 (patch) | |
tree | 70fe2aa13f738e976031bd720abc99748580ea22 | |
parent | 2d6853eff6a4690eba0a3d47a74ecd16607210b9 (diff) | |
download | chef-1e1d5c30502f4fc05fb324a2261145029aeba3f6.tar.gz |
Eager load ffi-libarchive to resolve centos-7 failures
Closes #12228
Extensive details in https://github.com/chef/chef/issues/12228
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/resource/archive_file.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/archive_file_spec.rb | 3 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource/archive_file_spec.rb | 3 |
4 files changed, 4 insertions, 12 deletions
diff --git a/lib/chef/resource/archive_file.rb b/lib/chef/resource/archive_file.rb index 9acec4213c..9d60603d8a 100644 --- a/lib/chef/resource/archive_file.rb +++ b/lib/chef/resource/archive_file.rb @@ -20,6 +20,8 @@ require_relative "../resource" require "fileutils" unless defined?(FileUtils) +# ffi-libarchive must be eager loaded see: https://github.com/chef/chef/issues/12228 +require "ffi-libarchive" unless defined?(Archive::Reader) class Chef class Resource @@ -92,8 +94,6 @@ class Chef action :extract, description: "Extract and archive file." do - require_libarchive - unless ::File.exist?(new_resource.path) raise Errno::ENOENT, "No archive found at #{new_resource.path}! Cannot continue." end @@ -131,10 +131,6 @@ class Chef end action_class do - def require_libarchive - require "ffi-libarchive" - end - def define_resource_requirements if new_resource.mode.is_a?(Integer) Chef.deprecated(:archive_file_integer_file_mode, "The mode property should be passed to archive_file resources as a String and not an Integer to ensure the value is properly interpreted.") diff --git a/spec/functional/resource/archive_file_spec.rb b/spec/functional/resource/archive_file_spec.rb index 27815cb319..edf4777dd8 100644 --- a/spec/functional/resource/archive_file_spec.rb +++ b/spec/functional/resource/archive_file_spec.rb @@ -18,8 +18,7 @@ require "spec_helper" require "tmpdir" -# Exclude this test on platforms where ffi-libarchive loading is broken -describe Chef::Resource::ArchiveFile, :libarchive_loading_broken do +describe Chef::Resource::ArchiveFile, :not_supported_on_aix do include RecipeDSLHelper let(:tmp_path) { Dir.mktmpdir } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5cd04437be..2aa3b2a1cd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -187,8 +187,6 @@ RSpec.configure do |config| config.filter_run_excluding not_rhel7: true if rhel7? config.filter_run_excluding not_intel_64bit: true if intel_64bit? - config.filter_run_excluding libarchive_loading_broken: true if aix? || amazon_linux? || rhel7? - # these let us use chef: ">= 13" or ruby: "~> 2.0.0" or any other Gem::Dependency-style constraint config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION) config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION) diff --git a/spec/unit/resource/archive_file_spec.rb b/spec/unit/resource/archive_file_spec.rb index 88cbe94629..7818a31516 100644 --- a/spec/unit/resource/archive_file_spec.rb +++ b/spec/unit/resource/archive_file_spec.rb @@ -29,8 +29,7 @@ rescue LoadError end end -# Exclude this test on platforms where ffi-libarchive loading is broken -describe Chef::Resource::ArchiveFile, :libarchive_loading_broken do +describe Chef::Resource::ArchiveFile, :not_supported_on_aix do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } |