]> git.proxmox.com Git - pve-installer.git/blob - country.pl
fix file permissions in html-pmg
[pve-installer.git] / country.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use PVE::Tools;
7
8 # see also: http://en.wikipedia.org/wiki/Keyboard_layout
9 #
10 # country codes from: /usr/share/zoneinfo/iso3166.tab
11 # timezones from: /usr/share/zoneinfo/zone.tab
12 # keymaps: find /usr/share/keymaps/i386/ -type f -name '*.kmap.gz'
13 # x11 layouts: /usr/share/X11/xkb/rules/xorg.lst
14
15 my $country = {};
16
17 my $line;
18 open (TMP, "</usr/share/zoneinfo/iso3166.tab");
19 while (defined ($line = <TMP>)) {
20 if ($line =~ m/^([A-Z][A-Z])\s+(.*\S)\s*$/) {
21 $country->{lc($1)} = $2;
22 }
23 }
24 close (TMP);
25
26 # we need mappings for X11, console, and kvm vnc
27
28 # LC(-LC)? => [DESC, kvm, console, X11, X11variant]
29 my $keymaps = PVE::Tools::kvmkeymaps();
30
31 foreach my $km (sort keys %$keymaps) {
32 my ($desc, $kvm, $console, $x11, $x11var) = @{$keymaps->{$km}};
33
34 if ($km =~m/^([a-z][a-z])-([a-z][a-z])$/i) {
35 defined ($country->{$2}) || die "undefined country code '$2'";
36 } else {
37 defined ($country->{$km}) || die "undefined country code '$km'";
38 }
39
40 $x11var = '' if !defined ($x11var);
41 print "map:$km:$desc:$kvm:$console:$x11:$x11var:\n";
42 }
43
44 my $defmap = {
45 'us' => 'en-us',
46 'be' => 'fr-be',
47 'br' => 'pt-br',
48 'ca' => 'en-us',
49 'dk' => 'dk',
50 'nl' => 'en-us', # most Dutch people us US layout
51 'fi' => 'fi',
52 'fr' => 'fr',
53 'de' => 'de',
54 'at' => 'de',
55 'hu' => 'hu',
56 'is' => 'is',
57 'it' => 'it',
58 'va' => 'it',
59 'jp' => 'jp',
60 'lt' => 'lt',
61 'mk' => 'mk',
62 'no' => 'no',
63 'pl' => 'pl',
64 'pt' => 'pt',
65 'si' => 'si',
66 'es' => 'es',
67 'gi' => 'es',
68 'ch' => 'de-ch',
69 'gb' => 'en-gb',
70 'lu' => 'fr-ch',
71 'li' => 'de-ch',
72 };
73
74
75 my $mirrors = PVE::Tools::debmirrors();
76 foreach my $cc (keys %$mirrors) {
77 die "undefined country code '$cc'" if !defined ($country->{$cc});
78 }
79
80 foreach my $cc (sort keys %$country) {
81 my $map = $defmap->{$cc} || '';
82 my $mir = $mirrors->{$cc} || '';
83 print "$cc:$country->{$cc}:$map:$mir:\n";
84 }