PATCH [1/2] is just a minor change without any significant result.
PATCH [2/2] adds a heuristic to guess wheter HW clock uses UTC or local time by searching for bootable NTFS partitions. It adds two threads, but these are really lightweight and just handle the potential long storage initialization.
Vratislav Podzimek (2): Return bool value from the GRUB.has_windows method Set system time from HW clock and guess if it is UTC
anaconda | 11 ++++++++- pyanaconda/bootloader.py | 2 +- pyanaconda/kickstart.py | 7 ------ pyanaconda/timezone.py | 38 ++++++++++++++++++++++++++++++ pyanaconda/ui/gui/spokes/datetime_spoke.py | 20 ++++++++++++++++ 5 files changed, 69 insertions(+), 9 deletions(-)
GRUB class is inherited from the Bootloader class which returns bool value from its has_windows method.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- pyanaconda/bootloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index 10415e1..259dd34 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -1317,7 +1317,7 @@ class GRUB(BootLoader): ret = [d for d in devices if self.is_valid_stage2_device(d, linux=False, non_linux=True)] self.errors = errors self.warnings = warnings - return ret + return bool(ret)
class GRUB2(GRUB): """ GRUBv2
We should set system time to HW clock in early phase of the installation. If we are not given info about it being UTC in kickstart, we have to guess by searching for bootable partitions of other operating system(s).
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- anaconda | 11 ++++++++- pyanaconda/kickstart.py | 7 ------ pyanaconda/timezone.py | 38 ++++++++++++++++++++++++++++++ pyanaconda/ui/gui/spokes/datetime_spoke.py | 20 ++++++++++++++++ 4 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/anaconda b/anaconda index f291fb0..b121faf 100755 --- a/anaconda +++ b/anaconda @@ -972,14 +972,23 @@ if __name__ == "__main__": from pyanaconda.storage import storageInitialize from pyanaconda.packaging import payloadInitialize from pyanaconda.network import networkInitialize + from pyanaconda.timezone import time_initialize, TIME_INIT_THREAD_NAME
if anaconda.rescue: from pyanaconda.rescue import doRescue doRescue(anaconda.rescue_mount, ksdata, anaconda.platform)
- threadMgr.add(AnacondaThread(name="AnaStorageThread", target=storageInitialize, args=(anaconda.storage, ksdata, anaconda.protected))) + storage_thread_name = "AnaStorageThread" + + threadMgr.add(AnacondaThread(name=storage_thread_name, target=storageInitialize, args=(anaconda.storage, ksdata, anaconda.protected))) threadMgr.add(AnacondaThread(name="AnaNetworkThread", target=networkInitialize, args=(ksdata,))) threadMgr.add(AnacondaThread(name="AnaPayloadThread", target=payloadInitialize, args=(anaconda.storage, ksdata, anaconda.payload))) + threadMgr.add(AnacondaThread(name=TIME_INIT_THREAD_NAME, + target=time_initialize, + args=(anaconda.ksdata.timezone, + anaconda.storage, + storage_thread_name, + anaconda.bootloader)))
atexit.register(exitHandler, ksdata.reboot, anaconda.storage)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 65a1e55..7ff6a13 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -1180,13 +1180,6 @@ class Services(commands.services.FC6_Services): root=ROOT_PATH)
class Timezone(commands.timezone.F18_Timezone): - def __init__(self, *args): - commands.timezone.F18_Timezone.__init__(self, *args) - - #TODO: Do we need to set it to False in case of dual-boot? - #default to UTC HW clock in Anaconda - self.isUtc = True - def execute(self, *args): # write out timezone configuration if not timezone.is_valid_timezone(self.timezone): diff --git a/pyanaconda/timezone.py b/pyanaconda/timezone.py index 5337a21..1a8fab3 100644 --- a/pyanaconda/timezone.py +++ b/pyanaconda/timezone.py @@ -30,10 +30,13 @@ from collections import OrderedDict
from pyanaconda import localization from pyanaconda import iutil +from pyanaconda.threads import threadMgr
import logging log = logging.getLogger("anaconda")
+TIME_INIT_THREAD_NAME = "AnaTimeThread" + # The following zones are not in pytz.common_timezones and # Etc category in pytz.all_timezones includes some more, # however confusing ones (like UCT, GMT+0, GMT-0,...) @@ -47,6 +50,41 @@ class TimezoneConfigError(Exception): """Exception class for timezone configuration related problems""" pass
+def time_initialize(timezone, storage, storage_thread_name, bootloader): + """ + Try to guess if RTC uses UTC time or not, set timezone.isUtc properly and + set system time from RTC using the UTC guess. + Guess is done by searching for bootable ntfs devices. + + @param timezone: ksdata.timezone object + @param storage: storage.Storage instance + @param storage_thread_name: name of the thread running storageInitialize + @param bootloader: bootloader.Bootloader instance + + """ + + if not timezone.isUtc: + # if set in the kickstart, nothing to do here + + storage_init_thread = threadMgr.get(storage_thread_name) + if storage_init_thread is not None: + # wait until storage initialization is finished + storage_init_thread.join() + + ntfs_devs = filter(lambda dev: dev.format.name == "ntfs", + storage.devices) + + timezone.isUtc = not bootloader.has_windows(ntfs_devs) + + cmd = "hwclock" + args = ["--hctosys"] + if timezone.isUtc: + args.append("--utc") + else: + args.append("--localtime") + + iutil.execWithRedirect(cmd, args, stdout="/dev/tty5", stderr="/dev/tty5") + def write_timezone_config(timezone, root): """ Write timezone configuration for the system specified by root. diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py index b9b59bb..3d7ed8e 100644 --- a/pyanaconda/ui/gui/spokes/datetime_spoke.py +++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py @@ -39,6 +39,8 @@ from pyanaconda import iutil from pyanaconda import network from pyanaconda import ntp from pyanaconda import flags +from pyanaconda.ui.gui import communication +from pyanaconda.timezone import TIME_INIT_THREAD_NAME from pyanaconda.threads import threadMgr, AnacondaThread
import datetime @@ -372,6 +374,24 @@ class DatetimeSpoke(NormalSpoke): self._config_dialog = NTPconfigDialog(self.data) self._config_dialog.initialize()
+ self._ready = False + threadMgr.add(AnacondaThread(name="AnaWaitTimeThread", + target=self.wait_for_time_init)) + + def wait_for_time_init(self): + time_init_thread = threadMgr.get(TIME_INIT_THREAD_NAME) + if time_init_thread is not None: + communication.send_message(self.__class__.__name__, + _("Restoring hardware time...")) + time_init_thread.join() + + self._ready = True + communication.send_ready(self.__class__.__name__) + + @property + def ready(self): + return self._ready + @property def status(self): if self.data.timezone.timezone:
On Wed, 2013-01-09 at 14:46 +0100, Vratislav Podzimek wrote:
PATCH [1/2] is just a minor change without any significant result.
PATCH [2/2] adds a heuristic to guess wheter HW clock uses UTC or local time by searching for bootable NTFS partitions. It adds two threads, but these are really lightweight and just handle the potential long storage initialization.
Vratislav Podzimek (2): Return bool value from the GRUB.has_windows method Set system time from HW clock and guess if it is UTC
anaconda | 11 ++++++++- pyanaconda/bootloader.py | 2 +- pyanaconda/kickstart.py | 7 ------ pyanaconda/timezone.py | 38 ++++++++++++++++++++++++++++++ pyanaconda/ui/gui/spokes/datetime_spoke.py | 20 ++++++++++++++++ 5 files changed, 69 insertions(+), 9 deletions(-)
These patches stil haven't been approved or rejected and the bug for the HW clock issue [1] has been approved as an F19 final exception.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=881403
These patches stil haven't been approved or rejected and the bug for the HW clock issue [1] has been approved as an F19 final exception.
Sorry, this one appears to have slipped through unread. There's an awful lot of email.
I think the idea's fine, but since you originally made the patch, a couple things in anaconda have changed that you'll need to take into account:
* All the thread name constants have been consolidated in pyanaconda/constants.py, so you should do that instead of defining in anaconda and pyanaconda/timezone.py.
* datetime_spoke.py now has the _initialize threading stuff already set up, so you can move the wait_for_time_init stuff into that method.
- Chris
On Tue, 2013-06-04 at 16:57 -0400, Chris Lumens wrote:
These patches stil haven't been approved or rejected and the bug for the HW clock issue [1] has been approved as an F19 final exception.
Sorry, this one appears to have slipped through unread. There's an awful lot of email.
I think the idea's fine, but since you originally made the patch, a couple things in anaconda have changed that you'll need to take into account:
All the thread name constants have been consolidated in pyanaconda/constants.py, so you should do that instead of defining in anaconda and pyanaconda/timezone.py.
datetime_spoke.py now has the _initialize threading stuff already set up, so you can move the wait_for_time_init stuff into that method.
Thanks for pointing that out. I was about to look at those things, I just wanted an approval of the overall idea and approach. I'll soon send updated patches.
anaconda-patches@lists.fedorahosted.org