Eric Shubert | 28 Mar 2012 17:13
Favicon

[qmailtoaster-devel] rpm caveat

In my testing of clamav, I discovered a behavior of rpm that I didn't 
expect, regarding files coded as %config.

Here is a fairly nice write-up about rpm config files:
http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html
It says:
"In summary: if a file is not marked as a config file, or if a file has 
not been altered since installation, then it will be sliently {sic} 
replaced by the version from an update RPM. If a config file has been 
edited on disk, but is not actually different from one RPM to another 
then the edited version will be silently left in place. It is only when 
a config file has been edited and is different from one RPM to the next 
that what happens depens {sic} on the (noreplace) option. If absent, the 
new file will be installed, and the the old edited version will be 
renamed with a .rpmsave suffix. If present, the edited version will be 
left in place, and the new version will be installed with a .rpmnew 
suffix. I don't know what happens if RPM needs to create an .rpmsave or 
.rpmnew file and one already exists - at least in some cases it seems 
that the new file isn't written under these circumstances."

Reading between the lines, and what I didn't expect, is that if a 
%config file is no different between the installed version and the 
version being updated, then nothing happens to this file. I mean 
absolutely nothing. *Even if it has been deleted, it is not added.* This 
happens regardless of whether (noreplace) is specified or not.

What this means is that if a %config file happens to get deleted (or 
severely mangled), doing a --force (implies --replacefiles) update of 
the existing package will not reinstall it. Neither will installing an 
older version if the file is not different between the two. The only way 
to get it back (that I've found) is to remove the package and 
(re)install it.

Personally, I think this sux. I would think that --replacefiles would at 
least add it back if it was missing, but it doesn't. This is probably 
something that seasoned RPM users are familiar with, but it was news to 
me. Nice thing to know.

FWIW, you can find out which files are coded %config by doing
# rpm -qlc <package>

Just thought I'd share this, as it drove me nuts for a day or so.

--

-- 
-Eric 'shubes'

Gmane