]> git.proxmox.com Git - pve-installer.git/commitdiff
copied country.pl form pve-manager
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Nov 2017 08:29:28 +0000 (09:29 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Nov 2017 08:29:28 +0000 (09:29 +0100)
Makefile
country.pl [new file with mode: 0755]
proxinstall

index 034ce2f796aa138a0076b24115767d15becab842..c969620db1acb72f262f0f7f8ceda0b88e754b65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,12 +12,16 @@ INSTALLER_SOURCES=          \
        checktime               \
        xinitrc                 \
        Xdefaults               \
+       country.dat             \
        proxinstall
 
 HTML_SOURCES=$(wildcard html/*.htm)
 HTML_COMMON_SOURCES=$(wildcard html-common/*.htm) $(wildcard html-common/*.css) $(wildcard html-common/*.png)
 
-all:
+all: ${INSTALLER_SOURCES} ${HTML_COMMON_SOURCES} ${HTML_SOURCES}
+
+country.dat: country.pl
+       ./country.pl > country.dat
 
 deb: ${DEB}
 ${DEB}: ${INSTALLER_SOURCES} ${HTML_COMMON_SOURCES} ${HTML_SOURCES} Makefile html/Makefile
@@ -34,6 +38,7 @@ install: ${INSTALLER_SOURCES} ${HTML_COMMON_SOURCES} ${HTML_SOURCES}
        ln -s /tmp/resolv.conf.dhclient-new ${DESTDIR}/etc/resolv.conf.dhclient-new
        install -D -m 755 fake-start-stop-daemon ${DESTDIR}/var/lib/pve-installer/fake-start-stop-daemon
        install -D -m 755 policy-disable-rc.d ${DESTDIR}/var/lib/pve-installer/policy-disable-rc.d
+       install -D -m 755 country.dat ${DESTDIR}/var/lib/pve-installer/country.dat
        install -D -m 755 unconfigured.sh ${DESTDIR}/sbin/unconfigured.sh
        install -D -m 755 proxinstall ${DESTDIR}/usr/bin/proxinstall
        install -D -m 755 checktime ${DESTDIR}/usr/bin/checktime
@@ -58,5 +63,5 @@ check: packages test.img
 .phony: clean
 clean:
        make -C html-common clean
-       rm -rf *~ *.deb target build packages packages.tmp test.img pve-final.pkglist *.buildinfo *.changes
+       rm -rf *~ *.deb target build packages packages.tmp test.img pve-final.pkglist *.buildinfo *.changes country.dat
        find . -name '*~' -exec rm {} ';'
diff --git a/country.pl b/country.pl
new file mode 100755 (executable)
index 0000000..119a5c7
--- /dev/null
@@ -0,0 +1,82 @@
+#!/usr/bin/perl -w
+
+use strict;
+use PVE::Tools;
+
+# see also: http://en.wikipedia.org/wiki/Keyboard_layout
+#
+# country codes from: /usr/share/zoneinfo/iso3166.tab
+# timezones from: /usr/share/zoneinfo/zone.tab
+# keymaps: find /usr/share/keymaps/i386/ -type f -name '*.kmap.gz'
+# x11 layouts: /usr/share/X11/xkb/rules/xorg.lst
+
+my $country = {};
+
+my $line;
+open (TMP, "</usr/share/zoneinfo/iso3166.tab");
+while (defined ($line = <TMP>)) {
+    if ($line =~ m/^([A-Z][A-Z])\s+(.*\S)\s*$/) {
+       $country->{lc($1)} = $2;
+    }
+}
+close (TMP);
+
+# we need mappings for X11, console, and kvm vnc
+
+# LC(-LC)? => [DESC, kvm, console, X11, X11variant]
+my $keymaps = PVE::Tools::kvmkeymaps();
+
+foreach my $km (sort keys %$keymaps) {
+    my ($desc, $kvm, $console, $x11, $x11var) = @{$keymaps->{$km}};
+
+    if ($km =~m/^([a-z][a-z])-([a-z][a-z])$/i) {
+       defined ($country->{$2}) || die "undefined country code '$2'";
+    } else {
+       defined ($country->{$km}) || die "undefined country code '$km'";
+    }
+
+    $x11var = '' if !defined ($x11var);
+    print "map:$km:$desc:$kvm:$console:$x11:$x11var:\n";
+}
+
+my $defmap = {
+   'us' => 'en-us',
+   'be' => 'fr-be',
+   'br' => 'pt-br',
+   'ca' => 'en-us',
+   'dk' => 'dk',
+   'nl' => 'en-us', # most Dutch people us US layout
+   'fi' => 'fi',
+   'fr' => 'fr',
+   'de' => 'de',
+   'at' => 'de',
+   'hu' => 'hu',
+   'is' => 'is',
+   'it' => 'it',
+   'va' => 'it',
+   'jp' => 'jp',
+   'lt' => 'lt',
+   'mk' => 'mk',
+   'no' => 'no',
+   'pl' => 'pl',
+   'pt' => 'pt',
+   'si' => 'si',
+   'es' => 'es',
+   'gi' => 'es',
+   'ch' => 'de-ch',
+   'gb' => 'en-gb',
+   'lu' => 'fr-ch',
+   'li' => 'de-ch',
+};
+
+
+my $mirrors = PVE::Tools::debmirrors();
+foreach my $cc (keys %$mirrors) {
+    die "undefined country code '$cc'" if !defined ($country->{$cc});
+}
+
+foreach my $cc (sort keys %$country) {
+    my $map = $defmap->{$cc} || '';
+    my $mir = $mirrors->{$cc} || '';
+    print "$cc:$country->{$cc}:$map:$mir:\n";
+}
index 6bd3607eb42998be755f0e64b4025202c10659d6..785ddfc479b506bf1f9414354c1718416a5235b3 100755 (executable)
@@ -542,8 +542,8 @@ sub hd_list {
 }
 
 sub read_cmap {
-    my $countryfn = $opt_testmode ? "/usr/share/pve-manager/country.dat" :
-       "/cdrom/proxmox/country.dat";
+    my $countryfn = $opt_testmode ? "country.dat" :
+       "/var/lib/pve-installer/country.dat";
     open (TMP, "<$countryfn") || die "unable to open '$countryfn' - $!\n";
     my $line;
     my $country = {};