sync time and zone setting to bootstrap env
authorGui Chen <gui.chen@intel.com>
Thu, 29 Nov 2012 06:21:48 +0000 (14:21 +0800)
committerGui Chen <gui.chen@intel.com>
Wed, 12 Dec 2012 11:33:44 +0000 (19:33 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/bootstrap.py
mic/msger.py

index 7f34f19..6f00d66 100644 (file)
@@ -230,6 +230,15 @@ class Bootstrap(object):
             os.chroot(rootdir)
             os.chdir(chdir)
 
+        def sync_timesetting(rootdir):
+            try:
+                # sync time and zone info to bootstrap
+                if os.path.exists(rootdir + "/etc/localtime"):
+                    os.unlink(rootdir + "/etc/localtime")
+                shutil.copyfile("/etc/localtime", rootdir + "/etc/localtime")
+            except:
+                pass
+            
         if not rootdir:
             rootdir = self.rootdir
 
@@ -246,6 +255,7 @@ class Bootstrap(object):
         try:
             proxy.set_proxy_environ()
             gloablmounts = setup_chrootenv(rootdir, bindmounts, False)
+            sync_timesetting(rootdir)
             retcode = subprocess.call(cmd, preexec_fn=mychroot, env=env, shell=shell)
         except (OSError, IOError), err:
             raise RuntimeError(err)
index 03de73b..2252786 100644 (file)
@@ -87,7 +87,7 @@ def _general_print(head, color, msg = None, stream = None, level = 'normal'):
     # append normal msg to LOG
     save_msg = msg.strip() if msg else None
     if save_msg:
-        timestr = time.strftime("[%m/%d %H:%M:%S] ", time.localtime())
+        timestr = time.strftime("[%m/%d %H:%M:%S %Z] ", time.localtime())
         LOG_CONTENT += timestr + save_msg + '\n'
 
     if errormsg: