I am trying to build a rpm package for my application. And I would like to not remove a owned directory but keep adding files to it on upgrade. I will also like to remove the directory and all it files on uninstall. How do I achieve this?
Asked
Active
Viewed 558 times
1 Answers
1
that is basic behavior or rpm packages. If you put this:
%files
/var/application
in your spec file; then the directory /var/application
belongs to the rpm with everything below. When you uninstall your rpm; the directory will be completely removed.
Suppose application.1.rpm
contains:
/var/application/file1
/var/application/file2
and application.2.rpm
contains:
/var/application/file2
/var/application/file3
then after upgrade from application.1.rpm
to application.2.rpm
; the directory will contain file2 and file3. file1 will be removed because it is not anymore part of application.2.rpm
.

Chris Maes
- 35,025
- 12
- 111
- 136
-
Is there a directive for me to ask it to keep `file1` also? – Vinothkumar Raman May 14 '19 at 14:06
-
1no. that would not be logical; since you ask `application.2.rpm` to be installed with its files. Also that would mean that the behavior of your application would be different whether you first installed `application.1.rpm` and then upgraded; or just straight installed `application.2.rpm`. That would be very difficult to manage. Why don't you just package file1,2,3 all together in `application.2.rpm` ? – Chris Maes May 14 '19 at 14:08
-
True I get your point. Is it possible for me to create files in a directory not owned by the rpm? – Vinothkumar Raman May 14 '19 at 14:09
-
1Yes; but I would not recommend it. You could either just manually create those files of course; you an also let the rpm create them in the %post section. but those files are not guaranteed to be cleaned up after removal of the package (when the containing directory is owned by the rpm they will probably be erased though) – Chris Maes May 14 '19 at 14:11
-
@VinothkumarRaman is your problem solved? Then please accept the answer. – Chris Maes May 23 '19 at 12:08