diff options
| author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2026-01-13 17:27:33 +0000 |
|---|---|---|
| committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2026-01-16 22:42:58 +0000 |
| commit | 25f74ddb44213151a7547149e37b0b69a8308ff8 (patch) | |
| tree | 9554f761bc2071b4d236fdc06ad595e93b2789a6 /perl-install/install/install2.pm | |
| parent | 9a66062be6806d10e79365da408993f8dca565df (diff) | |
| download | drakx-25f74ddb44213151a7547149e37b0b69a8308ff8.tar drakx-25f74ddb44213151a7547149e37b0b69a8308ff8.tar.gz drakx-25f74ddb44213151a7547149e37b0b69a8308ff8.tar.bz2 drakx-25f74ddb44213151a7547149e37b0b69a8308ff8.tar.xz drakx-25f74ddb44213151a7547149e37b0b69a8308ff8.zip | |
installer: ask for user's timezone at the start of installation (mga#34909)
This allows us to set the system clock to the correct time. This is
needed to prevent rpm verification failures when very recently built
packages are fetched from network media. The new Sequoia PGP backend
rejects packages that appear to have been signed in the future.
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}}); } } |
