rpm %config(noreplace) override with %config

Kyle Fransham picture Kyle Fransham · Sep 16, 2015 · Viewed 7.8k times · Source

In my rpm I have a full directory that I want to tag with %config(noreplace). There is a file in that directory that I want to replace on every install with the latest from the rpm, using the semantics from %config.

Using the guide here: http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html, I tried the following:

%files
%config(noreplace) /my/saved/dir/*
%config /my/saved/dir/file1

and

%files
%config /my/saved/dir/file1
%config(noreplace) /my/saved/dir/*

hoping that the specific command would override the glob, but it didn't work. Is there any RPM like command that I can use to force the %config behaviour on a file that's nested under a %config(noreplace) directory?

Answer

msuchy picture msuchy · Sep 16, 2015

From: http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html

There is a restriction to the %config directive, and that restriction is that no more than one filename may follow the %config. This means that the following example is the only allowable way to specify config files:

%config /etc/foonly

Note that the full path to the file, as it is installed at build time, is required.

However you can craft that list dynamically in %install section:

%install
echo '%dir /etc' >> list.txt
echo '%config(noreplace) /etc/foo' >> list.txt
# use for-loop or any other shell scripting technique

%files -f list.txt