Search code examples
linuxrpmrpm-spec

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


Is there a way I can flag a configuration file as optional so when verification is invoked (rpm -v), it will ignore a missing configuration file?


I have an RPM package which I include a default configuration file for my application. The configuration file is not required for my application but I'd like to include it for easy configuration purposes. If the file was deleted, the application will work as expected (with some internal defaults). The problem I'm facing is that if I delete my configuration file and then run a verification on my installed RPM, the RPM indicates the package is not in good standing:

rpm -V test-rpm

(outputs)

missing c /etc/test/test.conf

Minimized SPEC definition:

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

 ...

Is there some option I haven't found yet or am I misunderstanding something about RPMs?


Solution

  • This is what %config(missingok) is for I believe.

    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.