2

I have created an RPM for a piece of software my team is building. The installation works great, but I'm adding in logic to make the software uninstall and restore the system to a working state.

As part of the install, I have to place a configuration file on the file system. However, when I uninstall the RPM, this file is left in the directory, which causes the service to function incorrectly once our package is uninstalled.

.SPEC file:

%files
...
%attr(640, tomcat, tomcat) /var/lib/owf/lib/OWFsecurityContext.xml
...

Install log:

cat Install.log | grep "OWFsecurityContext"
...
D: fini      100640  1 ( 498, 501)      2336    /var/lib/owf/lib/OWFsecurityContext.xml;53a41ad5
...

Files owned by RPM:

$ rpm -ql OurToolName | grep "OWFsecurityContext"
/var/lib/owf/lib/OWFsecurityContext.xml

Uninstall Log

$ cat Remove.log | grep "OWFsecurityContext"
D: fini      100640  1 ( 498, 501)      2336 /var/lib/owf/lib/OWFsecurityContext.xml skip

Why is RPM "skip"ing this file? Is there a way (besides just forcing a remove in the %postun section) to tell RPM to remove this file, just like all of the other files it owns?

EDIT:

After @EtanReisner 's comments, it appears that the file is owned by two packages: the package which I created in this question (by explicit file reference in the %files section, and by the OWF install RPM, which owns the entire directory in which the file lives.

Given that the file ends up being owned by two packages, is there a way to explicitly tell RPM to remove it regardless of its status besides removing it by force in the %postun scriptlet?

shawmanz32na
  • 1,260
  • 3
  • 15
  • 19
  • Is that file being marked as a configuration file in the `%files` section of the spec file? What does 'rpm -V OurToolName` say before you uninstall the package? – Etan Reisner Jun 20 '14 at 20:17
  • @EtanReisner - It's not being marked as `%config`. The file is only mentioned once, as shown in the question. `rpm -V OurToolName` returns: `S.5....T. /usr/share/tomcat/apache-tomcat-7.0.42/webapps/OurTool/WEB-INF/spring.properties`, which is expected, since I modify that file in the `%post%` scriptlet. – shawmanz32na Jun 20 '14 at 21:10
  • Is that file owned by two packages perhaps? What does 'rpm -qf /var/lib/owf/lib/OWFsecurityContext.xml` say? – Etan Reisner Jun 23 '14 at 22:37
  • @EtanReisner - You are correct. It is owned by two different packages. output of `rpm -qf /var/lib/owf/lib/OWFsecurityContext.xml` is: `owf-7.0-1.noarch OurToolName-1.0.0.0.0-noarch` I have updated the question to ask if there is a way to tell RPM to remove that file, regardless of its ownership. – shawmanz32na Jun 25 '14 at 00:26

2 Answers2

2

I'm not aware of any way to get RPM to ignore competing ownership and remove the file anyway like you are trying to do (and the bit of code digging I did the other day to figure out why RPM would be skipping the file didn't present anything along those lines either, though I wasn't looking for that at the time).

I believe entire directory ownership is generally discouraged for this sort of reason.

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
1

You need to mark it as a %config file. What is happening is that it is leaving the file behind because it doesn't match what the database thinks it should be and it doesn't want you to inadvertently lose data. If you tag it explicitly as a config file, then at uninstall it will be renamed to /var/lib/owf/lib/OWFsecurityContext.xml.rpmsave, which shouldn't conflict with anything.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39