summaryrefslogtreecommitdiffstats
path: root/perl-install/timezone.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/timezone.pm')
-rw-r--r--perl-install/timezone.pm56
1 files changed, 39 insertions, 17 deletions
diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm
index e5750fd6e..cfbaf98a1 100644
--- a/perl-install/timezone.pm
+++ b/perl-install/timezone.pm
@@ -1,4 +1,4 @@
-package timezone; # $Id$
+package timezone;
use diagnostics;
use strict;
@@ -6,10 +6,16 @@ use strict;
use common;
use log;
+sub get_timezone_prefix {
+ my ($b_use_system_prefix) = @_;
+
+ my $prefix = ($::testing || $b_use_system_prefix) ? '' : $::prefix;
+ $prefix . "/usr/share/zoneinfo";
+}
sub getTimeZones() {
- my $prefix = $::testing ? '' : $::prefix;
- open(my $F, "cd $prefix/usr/share/zoneinfo && find [A-Z]* -noleaf -type f |");
+ my $tz_prefix = get_timezone_prefix();
+ open(my $F, "cd $tz_prefix && find [A-Z]* -noleaf -type f |");
my @l = difference2([ chomp_(<$F>) ], [ 'ROC', 'PRC' ]);
close $F or die "cannot list the available zoneinfos";
sort @l;
@@ -20,15 +26,20 @@ sub read() {
{ timezone => $t{ZONE}, UTC => text2bool($t{UTC}) };
}
-my $ntp_conf_file = "/etc/ntp.conf";
+our $ntp = "ntp";
+my $servername_config_suffix = "";
+unless (-f $::prefix . "/etc/" . $ntp . ".conf") {
+ $ntp = "chrony";
+ $servername_config_suffix = " iburst";
+}
sub ntp_server() {
- find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . $ntp_conf_file);
+ find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . "/etc/" . $ntp . ".conf");
}
sub set_ntp_server {
my ($server) = @_;
- my $f = $::prefix . $ntp_conf_file;
+ my $f = $::prefix . "/etc/" . $ntp . ".conf";
-f $f or return;
my $pool_match = qr/\.pool\.ntp\.org$/;
@@ -37,14 +48,16 @@ sub set_ntp_server {
my $added = 0;
substInFile {
if (/^#?\s*server\s+(\S*)/ && $1 ne '127.127.1.0') {
- $_ = $added ? $_ =~ $pool_match ? undef : "#server $1\n" : join('', map { "server $_\n" } @servers);
+ $_ = $added ? $_ =~ $pool_match ? undef : "#server $1\n" : join('', map { "server $_$servername_config_suffix\n" } @servers);
$added = 1;
}
} $f;
- output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers));
+ if ($ntp eq "ntp") {
+ output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers));
+ }
require services;
- services::set_status('ntpd', to_bool($server), $::isInstall);
+ services::set_status($ntp . 'd', to_bool($server), $::isInstall);
}
sub write {
@@ -52,13 +65,20 @@ sub write {
set_ntp_server($t->{ntp});
- eval { cp_af("$::prefix/usr/share/zoneinfo/$t->{timezone}", "$::prefix/etc/localtime") };
+ my $tz_prefix = get_timezone_prefix(1);
+ eval { symlinkf($tz_prefix . '/' . $t->{timezone}, "$::prefix/etc/localtime") };
$@ and log::l("installing /etc/localtime failed");
setVarsInSh("$::prefix/etc/sysconfig/clock", {
ZONE => $t->{timezone},
UTC => bool2text($t->{UTC}),
ARC => "false",
});
+
+ my $adjtime_file = $::prefix . '/etc/adjtime';
+ my @adjtime = cat_($adjtime_file);
+ @adjtime or @adjtime = ("0.0 0 0.0\n", "0\n");
+ $adjtime[2] = $t->{UTC} ? "UTC\n" : "LOCAL\n";
+ output_p($adjtime_file, @adjtime);
}
sub reload_sys_clock {
@@ -78,7 +98,7 @@ my %c2t = (
'BA' => 'Europe/Sarajevo',
'BE' => 'Europe/Brussels',
'BG' => 'Europe/Sofia',
-'BR' => 'Brazil/East', #- most people live on the east coast
+'BR' => 'America/Sao_Paulo', #- most brazilians live on this time zone
'BY' => 'Europe/Minsk',
'CA' => 'Canada/Eastern',
'CH' => 'Europe/Zurich',
@@ -99,7 +119,7 @@ my %c2t = (
'ID' => 'Asia/Jakarta',
'IE' => 'Europe/Dublin',
'IL' => 'Asia/Tel_Aviv',
-'IN' => 'Asia/Calcutta',
+'IN' => 'Asia/Kolkata',
'IR' => 'Asia/Tehran',
'IS' => 'Atlantic/Reykjavik',
'IT' => 'Europe/Rome',
@@ -156,6 +176,7 @@ sub get_ntp_server_tree {
}
sub ntp_servers() {
+ # FIXME: missing parameter:
+{ get_ntp_server_tree() };
}
@@ -165,6 +186,7 @@ sub dump_ntp_zone {
}
sub print_ntp_zone {
my ($zone, $name) = @_;
+ # FIXME: missing parameter:
my %servers = dump_ntp_zone($zone);
print qq(\$ntp_servers{"$name"} = {\n);
print join('', map { qq( N_("$_") => "$servers{$_}",\n) } sort(keys %servers));
@@ -184,7 +206,7 @@ sub print_ntp_servers() {
$ntp_servers{""} = {
N_("Global") => "pool.ntp.org",
};
-$ntp_servers{"Global"} = {
+$ntp_servers{Global} = {
N_("Africa") => "africa.pool.ntp.org",
N_("Asia") => "asia.pool.ntp.org",
N_("Europe") => "europe.pool.ntp.org",
@@ -192,11 +214,11 @@ $ntp_servers{"Global"} = {
N_("Oceania") => "oceania.pool.ntp.org",
N_("South America") => "south-america.pool.ntp.org",
};
-$ntp_servers{"Africa"} = {
+$ntp_servers{Africa} = {
N_("South Africa") => "za.pool.ntp.org",
N_("Tanzania") => "tz.pool.ntp.org",
};
-$ntp_servers{"Asia"} = {
+$ntp_servers{Asia} = {
N_("Bangladesh") => "bd.pool.ntp.org",
N_("China") => "cn.pool.ntp.org",
N_("Hong Kong") => "hk.pool.ntp.org",
@@ -214,7 +236,7 @@ $ntp_servers{"Asia"} = {
N_("Turkey") => "tr.pool.ntp.org",
N_("United Arab Emirates") => "ae.pool.ntp.org",
};
-$ntp_servers{"Europe"} = {
+$ntp_servers{Europe} = {
N_("Austria") => "at.pool.ntp.org",
N_("Belarus") => "by.pool.ntp.org",
N_("Belgium") => "be.pool.ntp.org",
@@ -252,7 +274,7 @@ $ntp_servers{"North America"} = {
N_("Mexico") => "mx.pool.ntp.org",
N_("United States") => "us.pool.ntp.org",
};
-$ntp_servers{"Oceania"} = {
+$ntp_servers{Oceania} = {
N_("Australia") => "au.pool.ntp.org",
N_("New Zealand") => "nz.pool.ntp.org",
};