summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/install/NEWS3
-rw-r--r--perl-install/install/any.pm18
-rw-r--r--perl-install/install/install2.pm42
-rw-r--r--perl-install/install/share/list.xml1
-rw-r--r--perl-install/install/steps.pm1
-rw-r--r--perl-install/install/steps_interactive.pm11
-rw-r--r--perl-install/install/steps_list.pm1
7 files changed, 49 insertions, 28 deletions
diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS
index c41e833ad..e2760be8c 100644
--- a/perl-install/install/NEWS
+++ b/perl-install/install/NEWS
@@ -1,3 +1,6 @@
+- ask for user's timezone at the start of installation and correct the
+ system clock accordingly (mga#34909)
+
Version 18.71 - 5 January 2026
- improve Congratulations message in last installer screen (mga#28209)
diff --git a/perl-install/install/any.pm b/perl-install/install/any.pm
index 8772879ac..19bd157cb 100644
--- a/perl-install/install/any.pm
+++ b/perl-install/install/any.pm
@@ -123,23 +123,6 @@ sub getAvailableSpace {
fs::any::getAvailableSpace($o->{fstab});
}
-sub preConfigureTimezone {
- my ($o) = @_;
- require timezone;
-
- #- cannot be done in install cuz' timeconfig %post creates funny things
- add2hash($o->{timezone}, timezone::read()) if $o->{isUpgrade};
-
- $o->{timezone}{timezone} ||= timezone::bestTimezone($o->{locale}{country});
-
- my $utc = every { !isFat_or_NTFS($_) } @{$o->{fstab}};
- my $ntp = timezone::ntp_pool();
- add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp });
-
- #- Make the timezone available to urpm::mirrors.
- write_installer_timezone($o->{timezone});
-}
-
=item write_installer_timezone($timezone)
Writes a minimal version of $timezone to /etc/sysconfig/clock for use by urpm::mirrors
@@ -229,7 +212,6 @@ sub ask_suppl_media_url {
my ($o, $method, $o_url) = @_;
if (member($method, qw(ftp http))) {
- preConfigureTimezone($o);
any::ask_mirror_and_downloader($o, $o->{options}, 'downloader_only');
$o->{packages}{options}{downloader} = $o->{options}{downloader};
any::ask_mirror($o, 'distrib', $o_url);
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}});
}
}
diff --git a/perl-install/install/share/list.xml b/perl-install/install/share/list.xml
index b946f95db..cd52d6bf2 100644
--- a/perl-install/install/share/list.xml
+++ b/perl-install/install/share/list.xml
@@ -7,6 +7,7 @@
cpio gzip bzip2 xz
grub2-editenv
insmod modinfo rmmod modprobe lsmod
+ hwclock
<!-- block device tools -->
cryptsetup dmsetup
diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm
index c252d8fbb..a7394b28c 100644
--- a/perl-install/install/steps.pm
+++ b/perl-install/install/steps.pm
@@ -706,7 +706,6 @@ sub summaryAfter {
#------------------------------------------------------------------------------
sub configureTimezone {
my ($o) = @_;
- install::any::preConfigureTimezone($o);
if ($o->{timezone}{ntp}) {
# We prefer chrony, but we'll deal with ntpd for the sake of upgrades
diff --git a/perl-install/install/steps_interactive.pm b/perl-install/install/steps_interactive.pm
index 55985e01a..aaacd7fba 100644
--- a/perl-install/install/steps_interactive.pm
+++ b/perl-install/install/steps_interactive.pm
@@ -817,11 +817,11 @@ Do you want to install the updates?")),
#------------------------------------------------------------------------------
sub configureTimezone {
- my ($o, $clicked) = @_;
+ my ($o, $post_install) = @_;
- any::configure_timezone($o, $o->{timezone}, $clicked) or return;
+ any::configure_timezone($o, $o->{timezone}, 1) or return;
- install::steps::configureTimezone($o);
+ install::steps::configureTimezone($o) if $post_install;
1;
}
@@ -837,7 +837,6 @@ sub configureServices {
sub summaryBefore {
my ($o) = @_;
- install::any::preConfigureTimezone($o);
#- get back network configuration.
require network::network;
eval {
@@ -886,10 +885,6 @@ sub summary {
$o->pkg_install(map { $_->name } @pkgs) if @pkgs;
lang::write_and_install($o->{locale}, $o->do_pkgs);
- if (!$timezone_manually_set && !$o->{isUpgrade}) {
- delete $o->{timezone};
- install::any::preConfigureTimezone($o); #- now we can precise the timezone thanks to the country
- }
},
};
local $o->{bootloader}{boot} = 'ESP' if is_uefi();
diff --git a/perl-install/install/steps_list.pm b/perl-install/install/steps_list.pm
index 3dc3de2f2..df1454922 100644
--- a/perl-install/install/steps_list.pm
+++ b/perl-install/install/steps_list.pm
@@ -20,6 +20,7 @@ use common;
N_("_: Keep these entry short\nHard drive detection") ],
selectInstallClass => [ N_("_: Keep these entry short\nInstallation class"), 1, 1, '1', '',
N_("_: Keep these entry short\nInstallation class") ],
+ selectTimezone => [ N_("_: Keep these entry short\nTimezone"), 1, 1, '1', '', N_("Localization") ],
selectKeyboard => [ N_("_: Keep these entry short\nKeyboard"), 1, 1, '1', '', N_("Localization") ],
miscellaneous => [ N_("_: Keep these entry short\nSecurity"), 1, 1, '1', '', N_("Security") ],
doPartitionDisks => [ N_("_: Keep these entry short\nPartitioning"), 1, 0, '', "selectInstallClass",