[master] Pick up system's clock settings on upgrade. (#570299)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Including timezone and UTC through /etc/adjtime.
---
 dispatch.py |    2 ++
 upgrade.py  |   41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/dispatch.py b/dispatch.py
index 5bcaab9..a4029d9 100644
--- a/dispatch.py
+++ b/dispatch.py
@@ -36,6 +36,7 @@ from storage.partitioning import doAutoPartition
 from bootloader import writeBootloader, bootloaderSetupChoices
 from flags import flags
 from upgrade import upgradeMountFilesystems
+from upgrade import upgradeSetupTime
 from upgrade import upgradeSwapSuggestion, upgradeMigrateFind
 from upgrade import findRootParts, queryUpgradeContinue
 from installmethod import doMethodComplete
@@ -83,6 +84,7 @@ installSteps = [
     ("autopartitionexecute", doAutoPartition, ),
     ("partition", ),
     ("upgrademount", upgradeMountFilesystems, ),
+    ("upgradesetuptime", upgradeSetupTime, ),
     ("upgradecontinue", queryUpgradeContinue, ),
     ("upgradeswapsuggestion", upgradeSwapSuggestion, ),
     ("addswap", ),
diff --git a/upgrade.py b/upgrade.py
index 438407a..bff2ad0 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -107,7 +107,45 @@ def upgradeMigrateFind(anaconda):
         anaconda.dispatch.skipStep("upgrademigratefs")
     else:
         anaconda.dispatch.skipStep("upgrademigratefs", skip = 0)
-    
+
+def copyFromSysimage(rootPath, filename):
+    """Mirrors filename from the sysimage on the ramdisk."""
+    sysfile = os.path.normpath("%s/%s" % (rootPath, filename))
+    if os.access(sysfile, os.R_OK):
+        try:
+            # remove our copy if we have one (think liveinstall)
+            os.remove(filename)
+        except OSError:
+            pass
+        try:
+            shutil.copyfile(sysfile, filename)
+        except OSError as e:
+            log.error("Error copying %s to sysimage: %s" %(sysfile, e.strerror))
+            return False
+    else:
+        log.error("Error copying %s to sysimage, file not accessible." % sysfile)
+        return False
+    return True
+
+def upgradeSetupTime(anaconda):
+    """Load time setup for upgrade install.
+
+    This is pretty much what packages.setupTimezone() does in reverse.
+    """
+    if anaconda.dir == DISPATCH_BACK:
+        return
+    if os.environ.has_key("TZ"):
+        del os.environ["TZ"]
+    copyFromSysimage(anaconda.rootPath, '/etc/localtime')
+    copyFromSysimage(anaconda.rootPath, '/etc/adjtime')
+    if iutil.isS390():
+        return
+    args = [ "--hctosys" ]
+    try:
+        iutil.execWithRedirect("/usr/sbin/hwclock", args,stdout = "/dev/tty5",
+                               stderr = "/dev/tty5")
+    except RuntimeError:
+        log.error("Failed to set the clock.")
 
 # returns None if no more swap is needed
 def upgradeSwapSuggestion(anaconda):
@@ -271,6 +309,7 @@ def setSteps(anaconda):
                 "findrootparts",
                 "findinstall",
                 "upgrademount",
+                "upgradesetuptime",
                 "upgrademigfind",
                 "upgrademigratefs",
                 "enablefilesystems",
-- 
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux