[Linux] 移除 RPM 時,出現 remove failed: No such file or directory 錯誤?

[Linux] 移除 RPM 時,出現 remove failed: No such file or directory 錯誤?

最近在移除專案的一個 RPM 時,會出現奇怪的錯誤訊息,

說 remove failed: No such file or directory:

root@localhost ~ # rpm -ev test_agent

Preparing packages...
test_agent-1.0.0-1000.el8.x86_64
warning: file /opt/test_agent/update.zip: remove failed: No such file or directory
warning: file /opt/test_agent/main.zip: remove failed: No such file or directory

 

這個錯誤訊息先前並不會出現…

研究了一下,我們最近將 update.zip 和 main.zip 包進了 RPM 裡面,

並且在 RPM 安裝時,將這兩個 zip 解開後會刪掉它們,

應該就是因為這樣,在移除 RPM 時,才會抱怨找不到這兩個檔案…

 

後來同事建議可以修改 RPM 的 .spec 檔,

把這兩個檔案設定成可選的組態檔 %config(missingok) 如下:

%files
%defattr(-,root,root,700)
/opt/%{name}
%config(missingok) /opt/%{name}/unzip.zip
%config(missingok) /opt/%{name}/main.zip

 

這樣檔案如果不在,移除 RPM 時也不會出現錯誤了:

root@localhost ~ # rpm -ev test_agent

Preparing packages...
test_agent-1.0.0-1000.el8.x86_64

 

參考資料:

Marking files as documentation or configuration files

linux – How do I set optional configuration files in an RPM SPEC file? – Stack Overflow

(本頁面已被瀏覽過 518 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料