[Kimchi-devel] [PATCH] Create empty files on rpm build

Ramon Medeiros ramonn at linux.vnet.ibm.com
Fri Apr 10 12:16:42 UTC 2015


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 at linux.vnet.ibm.com>
---
 contrib/kimchi.spec.fedora.in | 9 +++++++++
 src/kimchi/proxy.py           | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 9f7bb59..d06c771 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -92,6 +92,12 @@ 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/kimchi-cert.pem
+touch %{buildroot}/%{_sysconfdir}/kimchi/kimchi-key.pem
+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 +167,9 @@ 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/kimchi-cert.pem
+%{_sysconfdir}/kimchi/kimchi-key.pem
+%{_sysconfdir}/kimchi/nginx_kimchi.conf
 %{_sysconfdir}/kimchi/
 %{_sharedstatedir}/kimchi/debugreports/
 %{_sharedstatedir}/kimchi/screenshots/
diff --git a/src/kimchi/proxy.py b/src/kimchi/proxy.py
index fafa5bc..ecf351c 100644
--- a/src/kimchi/proxy.py
+++ b/src/kimchi/proxy.py
@@ -60,8 +60,10 @@ def _create_proxy_config(options):
     if not cert or not key:
         cert = '%s/kimchi-cert.pem' % config_dir
         key = '%s/kimchi-key.pem' % config_dir
+
         # create cert files if they don't exist
-        if not os.path.exists(cert) or not os.path.exists(key):
+        if not (os.path.exists(cert) and len(open(cert).read()) > 0) or \
+        not (os.path.exists(key) and len(open(key).read()) > 0):
             ssl_gen = sslcert.SSLCert()
             with open(cert, "w") as f:
                 f.write(ssl_gen.cert_pem())
-- 
1.8.3.1




More information about the Kimchi-devel mailing list