]> git.proxmox.com Git - pve-installer.git/blob - country.pl
also umount efivars and minor improvements
[pve-installer.git] / country.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use PVE::Tools;
7 use JSON;
8
9 # country codes from:
10 my $country_codes_file = "/usr/share/iso-codes/json/iso_3166-1.json";
11
12 my $iso_3166_codes = from_json(PVE::Tools::file_get_contents($country_codes_file, 64 * 1024));
13
14 my $country = { map { lc($_->{'alpha_2'}) => $_->{'common_name'} // $_->{'name'} } @{$iso_3166_codes->{'3166-1'}} };
15
16 # we need mappings for X11, console, and kvm vnc
17
18 # LC(-LC)? => [DESC, kvm, console, X11, X11variant]
19 my $keymaps = PVE::Tools::kvmkeymaps();
20
21 foreach my $km (sort keys %$keymaps) {
22 my ($desc, $kvm, $console, $x11, $x11var) = @{$keymaps->{$km}};
23
24 if ($km =~m/^([a-z][a-z])-([a-z][a-z])$/i) {
25 defined ($country->{$2}) || die "undefined country code '$2'";
26 } else {
27 defined ($country->{$km}) || die "undefined country code '$km'";
28 }
29
30 $x11var = '' if !defined ($x11var);
31 print "map:$km:$desc:$kvm:$console:$x11:$x11var:\n";
32 }
33
34 my $defmap = {
35 'us' => 'en-us',
36 'be' => 'fr-be',
37 'br' => 'pt-br',
38 'ca' => 'en-us',
39 'dk' => 'dk',
40 'nl' => 'en-us', # most Dutch people us US layout
41 'fi' => 'fi',
42 'fr' => 'fr',
43 'de' => 'de',
44 'at' => 'de',
45 'hu' => 'hu',
46 'is' => 'is',
47 'it' => 'it',
48 'va' => 'it',
49 'jp' => 'jp',
50 'lt' => 'lt',
51 'mk' => 'mk',
52 'no' => 'no',
53 'pl' => 'pl',
54 'pt' => 'pt',
55 'si' => 'si',
56 'es' => 'es',
57 'gi' => 'es',
58 'ch' => 'de-ch',
59 'gb' => 'en-gb',
60 'lu' => 'fr-ch',
61 'li' => 'de-ch',
62 };
63
64
65 my $mirrors = PVE::Tools::debmirrors();
66 foreach my $cc (keys %$mirrors) {
67 die "undefined country code '$cc'" if !defined ($country->{$cc});
68 }
69
70 foreach my $cc (sort keys %$country) {
71 my $map = $defmap->{$cc} || '';
72 my $mir = $mirrors->{$cc} || '';
73 print "$cc:$country->{$cc}:$map:$mir:\n";
74 }