[PATCH v2] Create empty files on rpm build

Changes v2: Only remove nginx conm Issue #496 - System leftovers after uninstalling Kimchi A rpm does not remove files that are not created by the installation. So, all the files were provided by the package and now they can be uninstalled. Beyond this, the function that creates the proxy conf now accepts empty files to fill the configuration. Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- contrib/kimchi.spec.fedora.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 9f7bb59..750dada 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -92,6 +92,10 @@ mkdir -p %{buildroot}/%{_localstatedir}/log/kimchi/ touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-access.log touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log +# create /etc/kimchi structure +mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/ +touch %{buildroot}/%{_sysconfdir}/kimchi/nginx_kimchi.conf + # Install the systemd scripts install -Dm 0644 contrib/kimchid.service.fedora %{buildroot}%{_unitdir}/kimchid.service install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services/kimchid.xml @@ -161,6 +165,7 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/kimchi/distros.d/opensuse.json %{_sysconfdir}/kimchi/distros.d/ubuntu.json %{_sysconfdir}/kimchi/distros.d/gentoo.json +%{_sysconfdir}/kimchi/nginx_kimchi.conf %{_sysconfdir}/kimchi/ %{_sharedstatedir}/kimchi/debugreports/ %{_sharedstatedir}/kimchi/screenshots/ -- 1.8.3.1

On 13/04/2015 11:59, Ramon Medeiros wrote:
Changes
v2: Only remove nginx conm
Issue #496 - System leftovers after uninstalling Kimchi
A rpm does not remove files that are not created by the installation. So, all the files were provided by the package and now they can be uninstalled. Beyond this, the function that creates the proxy conf now accepts empty files to fill the configuration.
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- contrib/kimchi.spec.fedora.in | 5 +++++
You need to apply the same changes to the suse.spec
1 file changed, 5 insertions(+)
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 9f7bb59..750dada 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -92,6 +92,10 @@ mkdir -p %{buildroot}/%{_localstatedir}/log/kimchi/ touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-access.log touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log
+# create /etc/kimchi structure +mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/ +touch %{buildroot}/%{_sysconfdir}/kimchi/nginx_kimchi.conf + # Install the systemd scripts install -Dm 0644 contrib/kimchid.service.fedora %{buildroot}%{_unitdir}/kimchid.service install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services/kimchid.xml @@ -161,6 +165,7 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/kimchi/distros.d/opensuse.json %{_sysconfdir}/kimchi/distros.d/ubuntu.json %{_sysconfdir}/kimchi/distros.d/gentoo.json +%{_sysconfdir}/kimchi/nginx_kimchi.conf %{_sysconfdir}/kimchi/ %{_sharedstatedir}/kimchi/debugreports/ %{_sharedstatedir}/kimchi/screenshots/

I tested this patch on Fedora 21 and, after removing Kimchi, some files were still left on the system. I installed the RPM, started the Kimchi server, stopped the server and then I removed the RPM. Here's the final output of my tests: [kimchi@localhost ~]$ ls /etc/kimchi/ distros.d kimchi-cert.pem kimchi.conf kimchi-key.pem nginx.conf.in nginx_kimchi.conf [kimchi@localhost ~]$ sudo yum remove kimchi [...] [kimchi@localhost ~]$ ls /etc/kimchi/ kimchi-cert.pem kimchi-key.pem [kimchi@localhost ~]$

On 13/04/2015 17:00, Crístian Viana wrote:
I tested this patch on Fedora 21 and, after removing Kimchi, some files were still left on the system.
I installed the RPM, started the Kimchi server, stopped the server and then I removed the RPM. Here's the final output of my tests:
Yeap! I talked to Ramon about that. Those 2 cert files are created automatically according to the user configuration, ie, if the user provides them Kimchi will not generate those files. So they may exist or not on package removal.
[kimchi@localhost ~]$ ls /etc/kimchi/ distros.d kimchi-cert.pem kimchi.conf kimchi-key.pem nginx.conf.in <http://nginx.conf.in> nginx_kimchi.conf [kimchi@localhost ~]$ sudo yum remove kimchi [...] [kimchi@localhost ~]$ ls /etc/kimchi/ kimchi-cert.pem kimchi-key.pem [kimchi@localhost ~]$

On Mon, 2015-04-13 at 17:19 -0300, Aline Manera wrote:
On 13/04/2015 17:00, Crístian Viana wrote:
I tested this patch on Fedora 21 and, after removing Kimchi, some files were still left on the system.
I installed the RPM, started the Kimchi server, stopped the server and then I removed the RPM. Here's the final output of my tests:
Yeap! I talked to Ramon about that. Those 2 cert files are created automatically according to the user configuration, ie, if the user provides them Kimchi will not generate those files. So they may exist or not on package removal.
[kimchi@localhost ~]$ ls /etc/kimchi/ distros.d kimchi-cert.pem kimchi.conf kimchi-key.pem nginx.conf.in nginx_kimchi.conf [kimchi@localhost ~]$ sudo yum remove kimchi [...] [kimchi@localhost ~]$ ls /etc/kimchi/
kimchi-cert.pem kimchi-key.pem [kimchi@localhost ~]$
Why not use a %preun/%postun script in the spec file? Test for the existence of files that Kimchi can generate and remove accordingly.

On 04/13/2015 07:13 PM, Kevin Zander wrote:
On Mon, 2015-04-13 at 17:19 -0300, Aline Manera wrote:
On 13/04/2015 17:00, Crístian Viana wrote:
I tested this patch on Fedora 21 and, after removing Kimchi, some files were still left on the system.
I installed the RPM, started the Kimchi server, stopped the server and then I removed the RPM. Here's the final output of my tests: Yeap! I talked to Ramon about that. Those 2 cert files are created automatically according to the user configuration, ie, if the user provides them Kimchi will not generate those files. So they may exist or not on package removal.
[kimchi@localhost ~]$ ls /etc/kimchi/ distros.d kimchi-cert.pem kimchi.conf kimchi-key.pem nginx.conf.in nginx_kimchi.conf [kimchi@localhost ~]$ sudo yum remove kimchi [...] [kimchi@localhost ~]$ ls /etc/kimchi/
kimchi-cert.pem kimchi-key.pem [kimchi@localhost ~]$
Why not use a %preun/%postun script in the spec file? Test for the existence of files that Kimchi can generate and remove accordingly.
RPM does not remove files (without force) if the file was not created by the rpm. Use a rm -rf on the postscripts can fix this, but it's not the best way. I guess this way now it's safer. -- Ramon Nunes Medeiros Kimchi Developer Software Engineer - Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
participants (4)
-
Aline Manera
-
Crístian Viana
-
Kevin Zander
-
Ramon Medeiros