[PATCH 3/3] Save system time to hardware clock

Vratislav Podzimek vpodzime at redhat.com
Wed Sep 19 09:52:49 UTC 2012


We need to save system time to hardware clock before doing partitioning
and installing packages. Otherwise, in case of some error, user may end
up with a partitions and data created in future.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/install.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index d401e2f..67a6da9 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -27,6 +27,9 @@ from pyanaconda.progress import progress_report
 from pyanaconda.users import createLuserConf, getPassAlgo, Users
 from pyanaconda.network import writeNetworkConf
 from pyanaconda.flags import flags
+from pyanaconda.timezone import TIME_INIT_THREAD_NAME
+from pyanaconda.threads import threadMgr
+from pyanaconda import iutil
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -97,6 +100,21 @@ def doInstall(storage, payload, ksdata, instClass):
     steps += 4  # packages setup, packages, bootloader, post install
     progress.send_init(steps)
 
+    # Save system time to hardware clock before any other steps
+    time_init_thread = threadMgr.get(TIME_INIT_THREAD_NAME)
+    if time_init_thread is not None:
+        # wait until time initialization finishes
+        time_init_thread.join()
+
+    cmd = "hwclock"
+    args = ["--systohc"]
+    if ksdata.timezone.isUtc:
+        args.append("--utc")
+    else:
+        args.append("--local")
+
+    iutil.execWithRedirect(cmd, args, stdout="/dev/tty5", stderr="/dev/tty5")
+
     # Do partitioning.
     payload.preStorage()
     turnOnFilesystems(storage)
-- 
1.7.11.4



More information about the anaconda-patches mailing list