adapt logfile handler for bootstrap mode
authorGui Chen <gui.chen@intel.com>
Mon, 14 Oct 2013 13:38:37 +0000 (09:38 -0400)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Wed, 16 Oct 2013 04:25:06 +0000 (21:25 -0700)
if bootstrap enabled, logfile will append the records

Change-Id: Ic080e5cf9357f41c7dd4d1a2ce8f8c605a3d55e1
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/creator.py
mic/rt_util.py

index ab8bdd4..cfdf208 100644 (file)
@@ -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:
index d8052f6..33b8ccc 100644 (file)
@@ -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):