~ubuntu-branches/ubuntu/oneiric/localization-config/oneiric

« back to all changes in this revision

Viewing changes to conffiles.d/woody/timezone

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2005-05-23 00:36:51 UTC
  • Revision ID: james.westby@ubuntu.com-20050523003651-2xfe4l262j5ij3xa
Tags: 0.116
* Translatios
  - Bulgarian added. Closes: #308129
  - Updated Greek and Vietnamese. Closes: #309055
  - Fixed templates file that included extra test messages for session
  chooser
* Closes forgotten bugs. Closes: #306084, #306052.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
use strict;
6
6
use warnings;
7
7
 
 
8
require '/usr/lib/localization-config/common/log.pl';
 
9
 
8
10
# If no locale is given as argument, quit
9
 
my $lang = $ARGV[0] or die "No language given";
 
11
my $lang = $ARGV[0] or log_die("$0: No language given");
10
12
 
11
13
# Split locale entry into separate variables:
12
14
# language, country and extra information (eg '@euro')
19
21
my $zonedir     = "/usr/share/zoneinfo";
20
22
my $zonetabfile = "/usr/share/zoneinfo/zone.tab";
21
23
 
22
 
my $debug = 0;
23
 
 
24
24
#
25
25
# Look up countrycode (upper case) and return array with relevant time
26
26
# zone files.
30
30
 
31
31
    my @zones = ();
32
32
 
33
 
    open(ZT, "< $zonetabfile") || die "unable to open $zonetabfile";
 
33
    open(ZT, "< $zonetabfile") || log_die("$0: unable to open $zonetabfile");
34
34
    while (<ZT>) {
35
35
        chomp;
36
36
        next if (m/^\#/);
48
48
sub set_timezone {
49
49
    my $zonename = shift;
50
50
    my $path = $zonedir . "/" . $zonename;
51
 
    print "$path\n" if $debug;
 
51
    log_msg("$0:set_timezone(): $path");
52
52
    if ( ! -e $localtime || $path ne readlink $localtime ) {
53
53
        # Update symlink
54
54
        unlink $localtime;
55
55
        unless (symlink($path, $localtime) ) {
56
 
            print STDERR "error: Unable to symlink $localtime -> $path\n";
 
56
            log_die("$0:set_timezone(): error: Unable to symlink $localtime -> $path");
57
57
        }
58
58
    } else {
59
 
        print "Symlink already correct\n" if $debug;
 
59
        log_msg("$0:set_timezone(): Symlink already correct");
60
60
    }
61
61
}
62
62
 
139
139
 
140
140
# Lookup the country code and setup timezone file accordingly
141
141
my @zones = lookup_countrycode($countrycode);
142
 
print join("\n", @zones),"\n" if $debug;
 
142
log_msg("$0: ".join("\n", @zones));
143
143
if (1 < @zones) {
144
144
    # Hm, more then one zone available, should present a list using
145
145
    # debconf.  For now, just select the first one.
151
151
        my @zones = @{$conf->{'ZONE'}};
152
152
        set_timezone($zones[0]);
153
153
    } else {
154
 
        die "$0: No support for language '$lang'\n";
 
154
        log_msg("$0: No support for language $lang");
155
155
    }
156
156
}