From 25f74ddb44213151a7547149e37b0b69a8308ff8 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 13 Jan 2026 17:27:33 +0000 Subject: 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. --- perl-install/install/install2.pm | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'perl-install/install/install2.pm') 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; #-####################################################################################### @@ -162,6 +163,45 @@ sub setupSCSI { installStepsCall($o, $auto, 'setupSCSI') if !$::local_install; } +#------------------------------------------------------------------------------ +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}}); } } -- cgit v1.2.1