From b1f24e0e6c2b5dd8870d1ee89bf7911fe871bfac Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 7 Sep 1999 18:56:58 +0000 Subject: no_comment --- perl-install/common.pm | 21 ++++++++++--- perl-install/install_any.pm | 8 ----- perl-install/install_steps_interactive.pm | 3 +- perl-install/timezone.pm | 51 +++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 perl-install/timezone.pm (limited to 'perl-install') diff --git a/perl-install/common.pm b/perl-install/common.pm index 05091d546..084080959 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -55,6 +55,7 @@ sub round_up { my ($i, $r) = @_; $i += $r - ($i + $r - 1) % $r - 1; } sub round_down { my ($i, $r) = @_; $i -= $i % $r; } sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 } sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} } +sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = (); } keys %l } sub set_new(@) { my %l; @l{@_} = undef; { list => [ @_ ], hash => \%l } } sub set_add($@) { my $o = shift; foreach (@_) { exists $o->{hash}{$_} and next; push @{$o->{list}}, $_; $o->{hash}{$_} = undef } } @@ -242,9 +243,9 @@ sub getVarsFromSh($) { /^\s* # leading space (\w+) = # variable ( - "([^"]*)" # double-quoted text " - | '([^']*)' # single-quoted text ' - | [^'"\s]+ # normal text ' + "([^"]*)" # double-quoted text + | '([^']*)' # single-quoted text + | [^'"\s]+ # normal text ) \s*$ # end of line /x or next; @@ -262,4 +263,16 @@ sub setVarsInSh { $l->{$_} and print F "$_=$l->{$_}\n" foreach @fields; } - +sub bestMatchSentence { + my $best = -1; + my $bestSentence; + my @s = split /\W+/, shift; + foreach (@_) { + my $count = 0; + foreach my $e (@s) { + $count++ if /$e/i; + } + $best = $count, $bestSentence = $_ if $count > $best; + } + $bestSentence; +} diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index f57050115..5cec2da8a 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -126,14 +126,6 @@ sub addToBeDone(&$) { push @{$::o->{steps}{$step}{toBeDone}}, $f; } -sub getTimeZones { - local *F; - open F, "cd $::o->{prefix}/usr/share/zoneinfo && find [A-Z]* -type f |"; - my @l = sort map { chop; $_ } ; - close F or die "cannot list the available zoneinfos"; - @l; -} - sub upgrFindInstall { # int rc; # diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 9a98e16bb..f4e91fd2d 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -211,7 +211,8 @@ sub timeConfig { my ($o, $f) = @_; $o->{timezone}{GMT} = $o->ask_yesorno('', _("Is your hardware clock set to GMT?"), $o->{timezone}{GMT}); - $o->{timezone}{timezone} = $o->ask_from_list('', _("In which timezone are you"), [ install_any::getTimeZones() ], $o->{timezone}{timezone}); + $o->{timezone}{timezone} ||= + $o->{timezone}{timezone} = $o->ask_from_list('', _("In which timezone are you"), [ timezone::getTimeZones($o->{prefix}) ], $o->{timezone}{timezone}); install_steps::timeConfig($o,$f); } diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm new file mode 100644 index 000000000..8ff037a0f --- /dev/null +++ b/perl-install/timezone.pm @@ -0,0 +1,51 @@ +package timezone; + +use diagnostics; +use strict; + + + +sub getTimeZones { + my ($prefix) = @_; + local *F; + open F, "cd $prefix/usr/share/zoneinfo && find [A-Z]* -type f |"; + my @l = sort map { chop; $_ } ; + close F or die "cannot list the available zoneinfos"; + @l; +} + +my %l2t = ( +'Danish (Denmark)' => 'Europe/Copenhagen', +'English (USA)' => 'America/New_York', +'English (UK)' => 'Europe/London', +'Estonian (Estonia)' => 'Europe/Tallinn', +'Finnish (Finland)' => 'Europe/Helsinki', +'French (France)' => 'Europe/Paris', +'French (Belgium)' => 'Europe/Brussels', +'French (Canada)' => 'Canada/Atlantic', # or Newfoundland ? or Eastern ? +'German (Germany)' => 'Europe/Berlin', +'Hungarian (Hungary)' => 'Europe/Budapest', +'Icelandic (Iceland)' => 'Atlantic/Reykjavik', +'Indonesian (Indonesia)' => 'Asia/Jakarta', +'Italian (Italy)' => 'Europe/Rome', +'Italian (San Marino)' => 'Europe/San_Marino', +'Italian (Vatican)' => 'Europe/Vatican', +'Italian (Switzerland)' => 'Europe/Zurich', +'Japanese' => 'Asia/Tokyo', +'Latvian (Latvia)' => 'Europe/Riga', +'Lithuanian (Lithuania)' => 'Europe/Vilnius', +'Norwegian (Bokmaal)' => 'Europe/Oslo', +'Norwegian (Nynorsk)' => 'Europe/Oslo', +'Polish (Poland)' => 'Europe/Warsaw', +'Portuguese (Brazil)' => 'Brazil/East', # most people live on the east coast +'Portuguese (Portugal)' => 'Europe/Lisbon', +'Romanian (Rumania)' => 'Europe/Bucharest', +'Russian (Russia)' => 'Europe/Moscow', +'Slovak (Slovakia)' => 'Europe/Bratislava', +'Spanish (Spain)' => 'Europe/Madrid', +'Swedish (Finland)' => 'Europe/Helsinki' +'Swedish (Sweden)' => 'Europe/Stockholm', +'Turkish (Turkey)' => 'Europe/Istanbul', +'Ukrainian (Ukraine)' => 'Europe/Kiev', +'Walon (Belgium)' => 'Europe/Brussels', +); -- cgit v1.2.1