From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
add a method to get kimchi version in config.py
If kimchi run after package install, just get the version.
Or get the build nubmer.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/Makefile.am | 4 +++-
src/kimchi/config.py.in | 7 +++++++
2 files changed, 10 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..1b1b7c6 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"
@@ -53,6 +55,11 @@ def get_screenshot_path():
def get_debugreports_path():
return os.path.join(paths.state_dir, 'debugreports')
+def get_version():
+ if os.path.exists(os.path.join(paths.state_dir, 'packaged')):
+ return __version__
+ else:
+ return "-".join([__version__, __release__])
def find_qemu_binary(find_emulator=False):
try:
--
1.8.5.3