From befdffce92b7e4eb301355b0cce5acf60cb77653 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Mon, 14 Oct 2013 09:38:37 -0400 Subject: [PATCH] adapt logfile handler for bootstrap mode if bootstrap enabled, logfile will append the records Change-Id: Ic080e5cf9357f41c7dd4d1a2ce8f8c605a3d55e1 Signed-off-by: Gui Chen --- mic/creator.py | 6 +++++- mic/rt_util.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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): -- 2.7.4