From a210561adb92062390635ae9e518d5eeac37c478 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Tue, 10 Jul 2012 18:44:55 +0800 Subject: [PATCH] put mic version to build log Signed-off-by: Gui Chen --- mic/rt_util.py | 22 ---------------------- mic/utils/misc.py | 25 +++++++++++++++++++++++++ tools/mic | 4 ++++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/mic/rt_util.py b/mic/rt_util.py index 94e4821..bde3594 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -19,7 +19,6 @@ import os, sys import string import shutil import re -import platform from mic import bootstrap from mic import msger @@ -27,27 +26,6 @@ from mic.conf import configmgr from mic.utils import errors import mic.utils.misc as misc -SUPPORT_DISTS = ( - 'SuSE', - 'debian', - 'fedora', - 'redhat', - 'centos', - 'meego', - 'moblin', - 'tizen', -) - -# detect linux distribution, support "meego" -def linux_distribution(): - try: - (dist, ver, id) = platform.linux_distribution( \ - supported_dists = SUPPORT_DISTS) - except: - (dist, ver, id) = platform.dist( \ - supported_dists = SUPPORT_DISTS) - return (dist, ver, id) - def runmic_in_runtime(runmode, opts, ksfile, argv=None): if not runmode or "MeeGo" == linux_distribution()[0]: return diff --git a/mic/utils/misc.py b/mic/utils/misc.py index 44ced2b..ca1d7b7 100644 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -24,6 +24,7 @@ import shutil import glob import hashlib import subprocess +import platform import rpmmisc try: @@ -54,6 +55,30 @@ RPM_RE = re.compile("(.*)\.(.*) (.*)-(.*)") RPM_FMT = "%(name)s.%(arch)s %(ver_rel)s" SRPM_RE = re.compile("(.*)-(\d+.*)-(\d+\.\d+).src.rpm") +SUPPORT_DISTS = ( + 'SuSE', + 'debian', + 'fedora', + 'redhat', + 'centos', + 'meego', + 'moblin', + 'tizen', +) + +get_machine = platform.machine + +# detect linux distribution, support "meego" +def get_distro(): + try: + (dist, ver, id) = platform.linux_distribution( \ + supported_dists = SUPPORT_DISTS) + except: + (dist, ver, id) = platform.dist( \ + supported_dists = SUPPORT_DISTS) + + return (dist, ver, id) + def extract_rpm(rpmfile, targetdir): rpm2cpio = find_binary_path("rpm2cpio") cpio = find_binary_path("cpio") diff --git a/tools/mic b/tools/mic index 4070357..8c87a05 100755 --- a/tools/mic +++ b/tools/mic @@ -204,6 +204,10 @@ class MicCmd(cmdln.Cmdln): if __name__ == "__main__": try: + distro = ' '.join(misc.get_distro()).strip() + machin = misc.get_machine() + msger.raw("mic %s (%s %s)" % (VERSION, distro, machin)) + mic = MicCmd() sys.exit(mic.main()) -- 2.7.4