On 04/11/2014 11:50 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>

It means the kimchi run in package install path when the packaged file exists.
discuss with aline,
use config.get_prefix() to know kimchi is installed or not
if it is installed try "rpm -qa kimchi"
if it returns the package is installed otherwise it is from a "make install"

we can "rpm -qa kimchi" to check it is installed by rpm not by make install.
for deb we can use: "dpkg --get-selections kimchi"
try with rpm, if fails try deb

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
---
 Makefile.am                   | 2 ++
 contrib/kimchi.spec.fedora.in | 1 +
 contrib/kimchi.spec.suse.in   | 1 +
 3 files changed, 4 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 6831b5d..290e3dd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,11 +102,13 @@ all-local:
 install-deb: install
 	cp -R $(top_srcdir)/contrib/DEBIAN $(DESTDIR)/
 	$(MKDIR_P) $(DESTDIR)/etc/init
+	$(MKDIR_P) $(DESTDIR)/lib/kimchi
 	$(MKDIR_P) $(DESTDIR)/usr/lib/firewalld/services
 	cp -R $(top_srcdir)/contrib/kimchid-upstart.conf.debian \
 		$(DESTDIR)/etc/init/kimchid.conf
 	cp -R $(top_srcdir)/src/firewalld.xml \
 		$(DESTDIR)/usr/lib/firewalld/services/kimchid.xml
+	touch $(DESTDIR)/lib/kimchi/packaged


 deb: contrib/make-deb.sh
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 1cd99b0..2e66b00 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -83,6 +83,7 @@ install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid
 %endif

 %post
+touch %{_localstatedir}/lib/kimchi/packaged
 if [ $1 -eq 1 ] ; then
     /bin/systemctl enable kimchid.service >/dev/null 2>&1 || :
     # Initial installation
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index efb2c08..ee69384 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -51,6 +51,7 @@ install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid


 %post
+touch %{_localstatedir}/lib/kimchi/packaged
 chkconfig kimchid on

 %preun


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com>
IBM Linux Technology Center