[Kimchi-devel] [PATCH V4 1/2] config version API support: add a method to get kimchi version

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Mon Apr 14 23:43:22 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

add a method to get kimchi version in config.py

No matter kimchi package installed or not, we will always
get version and release.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/Makefile.am  | 4 +++-
 src/kimchi/config.py.in | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/Makefile.am b/src/kimchi/Makefile.am
index 957d2c9..e2b5bea 100644
--- a/src/kimchi/Makefile.am
+++ b/src/kimchi/Makefile.am
@@ -41,7 +41,9 @@ do_substitution = \
 	-e 's,[@]sysconfdir[@],$(sysconfdir),g'         \
 	-e 's,[@]localstatedir[@],$(localstatedir),g'   \
 	-e 's,[@]pkgdatadir[@],$(pkgdatadir),g'         \
-	-e 's,[@]kimchidir[@],$(kimchidir),g'
+	-e 's,[@]kimchidir[@],$(kimchidir),g'           \
+	-e 's,[@]kimchiversion[@],$(PACKAGE_VERSION),g' \
+	-e 's,[@]kimchirelease[@],$(PACKAGE_RELEASE),g'
 
 
 config.py: config.py.in Makefile
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 04218c2..bddcb5c 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -29,6 +29,8 @@ from ConfigParser import SafeConfigParser
 
 from kimchi.xmlutils import xpath_get_text
 
+__version__ = "@kimchiversion@"
+__release__ = "@kimchirelease@"
 
 DEFAULT_LOG_LEVEL = "debug"
 
@@ -54,6 +56,10 @@ def get_debugreports_path():
     return os.path.join(paths.state_dir, 'debugreports')
 
 
+def get_version():
+    return "-".join([__version__, __release__])
+
+
 def find_qemu_binary(find_emulator=False):
     try:
         connect = libvirt.open('qemu:///system')
-- 
1.8.5.3




More information about the Kimchi-devel mailing list