From: Gui Chen Date: Mon, 14 Oct 2013 13:38:37 +0000 (-0400) Subject: adapt logfile handler for bootstrap mode X-Git-Tag: 0.22~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=befdffce92b7e4eb301355b0cce5acf60cb77653;p=tools%2Fmic.git adapt logfile handler for bootstrap mode if bootstrap enabled, logfile will append the records Change-Id: Ic080e5cf9357f41c7dd4d1a2ce8f8c605a3d55e1 Signed-off-by: Gui Chen --- diff --git a/mic/creator.py b/mic/creator.py index ab8bdd4..cfdf208 100644 --- a/mic/creator.py +++ b/mic/creator.py @@ -179,7 +179,11 @@ class Creator(cmdln.Cmdln): if not os.path.exists(os.path.dirname(logfile_abs_path)): os.makedirs(os.path.dirname(logfile_abs_path)) msger.set_interactive(False) - msger.set_logfile(logfile_abs_path) + if rt_util.inbootstrap(): + mode = 'a' + else: + mode = 'w' + msger.set_logfile(logfile_abs_path, mode) configmgr.create['logfile'] = self.options.logfile if self.options.config: diff --git a/mic/rt_util.py b/mic/rt_util.py index d8052f6..33b8ccc 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -31,6 +31,11 @@ from mic.chroot import setup_chrootenv, cleanup_chrootenv expath = lambda p: os.path.abspath(os.path.expanduser(p)) +def inbootstrap(): + if os.path.exists(os.path.join("/", ".chroot.lock")): + return True + return (os.stat("/").st_ino != 2) + def bootstrap_mic(argv=None):