diff --git a/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch b/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch index da74e1f..baef7cc 100644 --- a/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch +++ b/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch @@ -1,14 +1,13 @@ -From 66f688f2b3ddc795a087c81746da57190675e624 Mon Sep 17 00:00:00 2001 -From: Takashi Kajinami -Date: Wed, 27 Apr 2022 15:33:16 +0900 +From 54df2906528ddea38adaf5ee71860bdfb49af492 Mon Sep 17 00:00:00 2001 +From: Joel Capitao +Date: Tue, 17 May 2022 10:51:59 +0200 Subject: [PATCH] (FACT-3116) Ignore EROFS when deleting fact cache When fact cache is placed in read only file system, deleting a file fails with EROFS instead of EACCES . --- - lib/facter/framework/core/cache_manager.rb | 2 +- - spec/facter/cache_manager_spec.rb | 20 +++++++++++++++++++- - 2 files changed, 20 insertions(+), 2 deletions(-) + lib/facter/framework/core/cache_manager.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/framework/core/cache_manager.rb b/lib/facter/framework/core/cache_manager.rb index 100a7656a..d93020264 100644 @@ -23,44 +22,6 @@ index 100a7656a..d93020264 100644 @log.warn("Could not delete cache: #{e.message}") end end -diff --git a/spec/facter/cache_manager_spec.rb b/spec/facter/cache_manager_spec.rb -index 8b3194340..324964bd5 100644 ---- a/spec/facter/cache_manager_spec.rb -+++ b/spec/facter/cache_manager_spec.rb -@@ -132,7 +132,7 @@ describe Facter::CacheManager do - ) - end - -- context 'when file cannot be deleted' do -+ context 'when file cannot be deleted because of access denied' do - let(:cache_file) { File.join(cache_dir, 'ext_file.txt') } - - it 'logs warn if it cannot delete' do -@@ -149,6 +149,24 @@ describe Facter::CacheManager do - expect(logger).to have_received(:warn) - end - end -+ -+ context 'when file cannot be deleted because of read-only filesystem' do -+ let(:cache_file) { File.join(cache_dir, 'ext_file.txt') } -+ -+ it 'logs warn if it cannot delete' do -+ allow(fact_groups).to receive(:get_fact).with('ext_file.txt').and_return(external_fact) -+ allow(File).to receive(:readable?).with(cache_file_name).and_return(false) -+ allow(Facter::Util::FileHelper).to receive(:safe_read).with(cache_file) -+ .and_return(cached_external_fact) -+ allow(JSON).to receive(:parse).with(cached_external_fact).and_raise(JSON::ParserError) -+ allow(File).to receive(:readable?).with(cache_file).and_return(true) -+ allow(File).to receive(:mtime).with(File.join(cache_dir, 'ext_file.txt')).and_return(Time.now) -+ allow(File).to receive(:delete).with(cache_file).and_raise(Errno::EROFS) -+ -+ cache_manager.resolve_facts([searched_external_fact]) -+ expect(logger).to have_received(:warn) -+ end -+ end - end - - context 'with timer' do -- 2.35.1 diff --git a/SPECS/facter.spec b/SPECS/facter.spec index 80cea6a..92764ce 100644 --- a/SPECS/facter.spec +++ b/SPECS/facter.spec @@ -1,7 +1,7 @@ ## START: Set by rpmautospec ## (rpmautospec version 0.2.5) %define autorelease(e:s:pb:) %{?-p:0.}%{lua: - release_number = 3; + release_number = 4; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{?dist} @@ -78,6 +78,7 @@ Documentation for %{name}. %prep %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %setup -q -n %{gem_name}-%{version} +%patch1 -p1 %build gem build ../%{gem_name}-%{version}.gemspec @@ -112,6 +113,9 @@ GEM_HOME="%{buildroot}%{gem_dir}" %{buildroot}%{_bindir}/facter %doc %{gem_docdir} %changelog +* Tue May 17 2022 Joel Capitao 4.2.8-4.c7e3f55b6git +- Apply truly the patch + * Mon May 16 2022 Joel Capitao 4.2.8-3.c7e3f55b6git - Apply upstream patch to fix fact cache issue