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