diff options
Diffstat (limited to 'perl-install/install/install2.pm')
| -rw-r--r-- | perl-install/install/install2.pm | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/perl-install/install/install2.pm b/perl-install/install/install2.pm index 7f6cbd6fe..a12954d23 100644 --- a/perl-install/install/install2.pm +++ b/perl-install/install/install2.pm @@ -34,6 +34,7 @@ use log; use fs; use fs::any; use fs::mount; +use fs::type; use messages; #-####################################################################################### @@ -163,6 +164,45 @@ sub setupSCSI { } #------------------------------------------------------------------------------ +sub selectTimezone { + my ($auto) = @_; + require timezone; + + if ($o->{isUpgrade}) { + #- Read the existing settings. But we will still ask the user, in case + #- they are wrong. + my $root_part = fs::get::mntpoint2part('/', $o->{fstab}); + if ($root_part && eval{ fs::mount::mount(fs::wild_device::from_part('', $root_part), $::prefix, $root_part->{fs_type}, 'ro') }) { + if (my $tz = timezone::read()) { + add2hash($o->{timezone}, $tz); + $o->{timezone}{ntp} = timezone::ntp_pool(); + } + fs::mount::umount($::prefix); + } + } + if (!defined $o->{timezone}{UTC}) { + #- Guess whether the HW clock is set to UTC or local time. If we find a + #- NTFS or FAT partition (excluding the ESP), assume this machine has a + #- Windows installation, which will sets the HW clock to local time, + #- otherwise assume it is set to UTC. + $o->{timezone}{UTC} = every { !isnormal_Fat_or_NTFS($_) } @{$o->{fstab}}; + } + $o->{timezone}{timezone} ||= timezone::bestTimezone($o->{locale}{country}); + + $o->configureTimezone(0) if $o->{interactive} && !$auto; + + log::l('selected timezone: ' . $o->{timezone}{timezone}); + log::l('hwclock set to: ' . ($o->{timezone}{UTC} ? 'UTC' : 'local time')); + + #- Make the timezone available to urpm::mirrors. + install::any::write_installer_timezone($o->{timezone}); + + #- reload the system clock from the HW clock now we know the real timezone + local $ENV{TZ} = ':' . $o->{timezone}{timezone}; + run_program::run('hwclock', '--hctosys', '--noadjfile', ($t->{UTC} ? '--utc' : '--localtime')); +} + +#------------------------------------------------------------------------------ sub selectKeyboard { my ($auto) = @_; @@ -185,7 +225,7 @@ sub selectInstallClass { if ($o->{isUpgrade}) { @{$o->{orderedSteps}} = uniq(map { - $_ eq 'selectInstallClass' ? ($_, 'doPartitionDisks', 'formatPartitions') : $_; + $_ eq 'selectInstallClass' ? ($_, 'selectTimezone', 'doPartitionDisks', 'formatPartitions') : $_; } @{$o->{orderedSteps}}); } } |
