From: JF Ding Date: Mon, 2 Jan 2012 08:40:06 +0000 (+0800) Subject: headers for new modules and comments for TBD issues X-Git-Tag: 0.4~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=60866bee560b1d7ddd548e00573505b7d64bdddf;p=tools%2Fmic.git headers for new modules and comments for TBD issues --- diff --git a/mic/bootstrap.py b/mic/bootstrap.py index 6bcde9b..21a24d9 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -1,8 +1,22 @@ -#/usr/bin/env python +#!/usr/bin/python -tt +# +# Copyright (c) 2009, 2010, 2011 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. from __future__ import with_statement -import os -import sys +import os, sys import pickle import shutil import subprocess @@ -139,11 +153,14 @@ class Bootstrap(object): query_package = query_package_rpmdb name, mver = query_package(self.rootdir, 'name', 'meego-release') - #print "MeeGo Release: %s" % mver + msger.debug("MeeGo Release: %s" % mver) + name, kver = query_package(self.rootdir, 'name', 'kernel') - #print "Kernel Version: %s" % kver + msger.debug("Kernel Version: %s" % kver) + name, rver = query_package(self.rootdir, 'name', 'rpm') - #print "RPM Version: %s" % rver + msger.debug("RPM Version: %s" % rver) + return (mver, kver, rver) def create(self, name, repolist, **kwargs): @@ -151,7 +168,7 @@ class Bootstrap(object): self.pkgmgr = 'zypp' self.arch = 'i686' self.rootdir = name - self.cachedir = '/var/tmp/mic/cache' + self.cachedir = '/var/tmp/mic/cache' # TBD from conf, do NOT hardcode if 'arch' in kwargs: self.arch = kwargs['arch'] @@ -161,8 +178,8 @@ class Bootstrap(object): if os.path.exists(self._rootdir): metadata_fp = os.path.join(self._rootdir, '.metadata') if os.path.exists(metadata_fp) and \ - 0 != os.path.getsize(metadata_fp): - print "Already exists" + 0 != os.path.getsize(metadata_fp): + msger.warning("bootstrap already exists") # TBD more details return else: shutil.rmtree(self._rootdir) @@ -171,7 +188,6 @@ class Bootstrap(object): os.makedirs(self._rootdir) pkg_manager = self.pkgmgr(self.arch, self.rootdir, self.cachedir) - pkg_manager.setup() for repo in repolist: @@ -208,7 +224,7 @@ class Bootstrap(object): shutil.rmtree(destdir, ignore_errors = True) shutil.copytree(srcdir, destdir) - print "Bootstrap done" + msger.info("Bootstrap created.") def rebuild(self): pass diff --git a/mic/rt_util.py b/mic/rt_util.py index 71a4882..8de109c 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -1,7 +1,21 @@ -#!/usr/bin/python - -import os -import sys +#!/usr/bin/python -tt +# +# Copyright (c) 2009, 2010, 2011 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +import os, sys import string import shutil import re @@ -14,18 +28,15 @@ from mic.utils import errors import mic.utils.misc as misc SUPPORT_DISTS = ( - 'SuSE', 'debian', 'fedora', 'redhat', 'centos', - 'meego', 'moblin', 'tizen') - -def uniq(lst=[]): - if not lst: - return - try: - st = set(lst) - except: - import sets - st = sets.Set(lst) - return list(st) + 'SuSE', + 'debian', + 'fedora', + 'redhat', + 'centos', + 'meego', + 'moblin', + 'tizen', +) # detect linux distribution, support "meego" def linux_distribution(): @@ -138,12 +149,15 @@ def runmic_in_bootstrap(name, argv, opts, ksfile, repolist): if opts['logfile']: logfile = os.path.abspath(os.path.expanduser(opts['logfile'])) lst.append(os.path.dirname(logfile)) - # local package path - # local repo + + # TBD local package path + # TBD local repo # make unique - lst = uniq(lst) + lst = list(set(lst)) # FIXME: wo need the original order here + bindmounts = ';'.join(map(lambda p: os.path.abspath(os.path.expanduser(p)), lst)) + msger.info("Start mic command in bootstrap") bootstrap_env.run(name, argv, cwd, bindmounts) @@ -157,16 +171,19 @@ def get_mic_modpath(): return os.path.dirname(path) def get_mic_binpath(): + # FIXME: please use mic.find_binary_path() path = os.environ['PATH'] paths = string.split(path, os.pathsep) for pth in paths: fn = os.path.join(pth, 'mic') if os.path.isfile(fn): return fn + msger.warning("Can't find mic command") def get_mic_libpath(): # so far mic lib path is hard coded + # TBD return "/usr/lib/mic" # the hard code path is prepared for bootstrap