如何在 RPM 规范文件中设置可选配置文件?

How do I set optional configuration files in an RPM SPEC file?

有没有一种方法可以将配置文件标记为可选,以便在调用验证 (rpm -v) 时忽略丢失的配置文件?


我有一个 RPM 包,其中包含我的应用程序的默认配置文件。我的应用程序不需要配置文件,但我想包含它以便于配置。如果文件被删除,应用程序将按预期工作(有一些内部默认值)。我面临的问题是,如果我删除我的配置文件,然后 运行 对我安装的 RPM 进行验证,RPM 表明该包信誉不佳:

rpm -V test-rpm

(输出)

missing c /etc/test/test.conf

最小化规格定义:

Version:    0.0.1
Name:       test-rpm

...

%install
install -m 644 $resource_directory/test.conf %{buildroot}/etc/test/test.conf

 ...

%files
%defattr(-,root,root)
%config(noreplace) /etc/test/test.conf

 ...

有没有我还没有找到的选项,或者我对 RPM 有什么误解?

这就是我所相信的%config(missingok)

The %config(missingok) indicates that the file need not exist on the installed machine. The %config(missingok) is frequently used for files like /etc/rc.d/rc2.d/S55named where the (non-)existence of the symlink is part of the configuration in %post, and the file may need to be removed when this package is removed. This file is not required to exist at either install or uninstall time.