Browse Source

* Use isoquery instead of a python script to generate iso_3166.tab and

generate the file only once instead of every time its needed.
* Remove obsolete versions in build dependencies.

r56080
tags/2.27
Frans Pop 12 years ago
parent
commit
ed82ab771a
8 changed files with 38 additions and 128 deletions
  1. +9
    -5
      Makefile
  2. +8
    -0
      debian/changelog
  3. +1
    -1
      debian/control
  4. +12
    -11
      get-iso-codes
  5. +0
    -97
      iso3166tab.py
  6. +3
    -5
      map-cc
  7. +2
    -3
      mirrorlist
  8. +3
    -6
      mktemplates

+ 9
- 5
Makefile View File

@@ -52,22 +52,25 @@ $(MASTERLIST): force-try-update
force-try-update: ;
endif

debian/httplist-countries: $(MASTERLIST)
debian/iso_3166.tab:
isoquery -c | cut -f 1,4 | sort >debian/iso_3166.tab

debian/httplist-countries: $(MASTERLIST) debian/iso_3166.tab
./mirrorlist httplist $^

debian/ftplist-countries: $(MASTERLIST)
debian/ftplist-countries: $(MASTERLIST) debian/iso_3166.tab
./mirrorlist ftplist $^

debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/ftplist-countries
debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/ftplist-countries debian/iso_3166.tab
# Grab ISO codes from iso-codes package
./get-iso-codes
# Build the templates
./mktemplates $(templates)

mirrors_http.h: $(MASTERLIST)
mirrors_http.h: $(MASTERLIST) debian/iso_3166.tab
if [ "$$USE_HTTP" ]; then ./mirrorlist http $^; fi

mirrors_ftp.h: $(MASTERLIST)
mirrors_ftp.h: $(MASTERLIST) debian/iso_3166.tab
if [ "$$USE_FTP" ]; then ./mirrorlist ftp $^; fi

choose-mirror.o: mirrors_http.h mirrors_ftp.h
@@ -96,6 +99,7 @@ clean:
rm -f debian/templates-countries debian/httplist-countries debian/ftplist-countries
rm -f demo demo.templates
rm -rf debian/iso-codes debian/pobuild
rm -f debian/iso_3166.tab

reallyclean: clean
rm -f debian/choose-mirror-bin.templates


+ 8
- 0
debian/changelog View File

@@ -1,3 +1,11 @@
choose-mirror (2.27) UNRELEASED; urgency=low

* Use isoquery instead of a python script to generate iso_3166.tab and
generate the file only once instead of every time its needed.
* Remove obsolete versions in build dependencies.

-- Frans Pop <fjp@debian.org> Mon, 22 Sep 2008 11:24:53 +0200

choose-mirror (2.26) unstable; urgency=low

[ Updated translations ]


+ 1
- 1
debian/control View File

@@ -3,7 +3,7 @@ Section: debian-installer
Priority: extra
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Uploaders: Joey Hess <joeyh@debian.org>, Christian Perrier <bubulle@debian.org>, Colin Watson <cjwatson@debian.org>, Frans Pop <fjp@debian.org>
Build-Depends: debhelper (>= 5.0.22), dpkg-dev (>= 1.7.0), libdebconfclient0-dev (>= 0.47), wget, po-debconf (>= 0.5.0), libdebian-installer4-dev (>= 0.41), locales, iso-codes (>= 0.35-1), python (>= 2.4)
Build-Depends: debhelper (>= 5.0.22), libdebconfclient0-dev, wget, po-debconf, libdebian-installer4-dev, locales, iso-codes, isoquery
Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/choose-mirror

Package: choose-mirror


+ 12
- 11
get-iso-codes View File

@@ -2,16 +2,17 @@

set -e

#
# Get ISO codes from the iso-codes package and extract translations
set -e
[ -r /usr/share/xml/iso-codes/iso_3166.xml ] || exit 1
rm -rf debian/iso-codes >/dev/null 2>&1

[ -r debian/iso_3166.tab ] || exit 1

rm -rf debian/iso-codes
mkdir debian/iso-codes
for i in `find /usr/share/locale/ -name iso_3166.mo` ; do
language=`echo $i | cut -f5 -d/`
# Extract translations from the iso-codes package
msgunfmt $i >debian/iso-codes/${language}.po 2>/dev/null

for i in $(find /usr/share/locale/ -name iso_3166.mo) ; do
language=$(echo $i | cut -f5 -d/)
# Extract translations from the iso-codes package
msgunfmt $i >debian/iso-codes/${language}.po 2>/dev/null
done

DATE="$(date +'%Y-%m-%d %H:%M%z')"
@@ -27,6 +28,6 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\\n"

EOF
./iso3166tab.py /usr/share/xml/iso-codes/iso_3166.xml \
| perl -pe 's/.*?\t(.*)/msgid "$1"\nmsgstr "$1"\n/' \
>>debian/iso-codes/en.po
perl -pe 's/.*?\t(.*)/msgid "$1"\nmsgstr "$1"\n/' \
<debian/iso_3166.tab >>debian/iso-codes/en.po

+ 0
- 97
iso3166tab.py View File

@@ -1,97 +0,0 @@
#!/usr/bin/python
#
# Read iso-codes data file and output a .tab file
#
# Copyright (C) 2004 Alastair McKinstry <mckinstry@debian.org>
# Released under the GPL.
# $Id: iso3166tab.py,v 1.2 2005/01/08 18:06:46 mckinstry Exp $

from xml.sax import _exceptions, handler, make_parser, SAXException, ContentHandler
from xml.sax.handler import feature_namespaces
import sys, os, getopt, urllib2

class ErrorPrinter:
"A simple class that just prints error messages to standard out."

def __init__(self, level=0, outfile=sys.stderr):
self._level = level
self._outfile = outfile

def warning(self, exception):
if self._level <= 0:
self._outfile.write("WARNING in %s: %s\n" %
(self.__getpos(exception),
exception.getMessage()))

def error(self, exception):
if self._level <= 1:
self._outfile.write("ERROR in %s: %s\n" %
(self.__getpos(exception),
exception.getMessage()))

def fatalError(self, exception):
if self._level <= 2:
self._outfile.write("FATAL ERROR in %s: %s\n" %
(self.__getpos(exception),
exception.getMessage()))

def __getpos(self, exception):
if isinstance(exception, _exceptions.SAXParseException):
return "%s:%s:%s" % (exception.getSystemId(),
exception.getLineNumber(),
exception.getColumnNumber())
else:
return "<unknown>"

class DefaultHandler(handler.EntityResolver, handler.DTDHandler,
handler.ContentHandler, handler.ErrorHandler):
"""Default base class for SAX2 event handlers. Implements empty
methods for all callback methods, which can be overridden by
application implementors. Replaces the deprecated SAX1 HandlerBase
class."""


class printLines(DefaultHandler):
def __init__(self, ofile):
self.ofile = ofile

def startElement(self, name, attrs):
if name != 'iso_3166_entry':
return
code = attrs.get('alpha_2_code', None)
if code == None:
raise RunTimeError, "Bad file"
if type(code) == unicode:
code = code.encode('UTF-8')
name = attrs.get('name', None)
if name == None:
raise RunTimeError, " BadFile"
if type(name) == unicode:
name = name.encode('UTF-8')
common_name = attrs.get('common_name', None)
if common_name != None:
if type(common_name) == unicode:
name = common_name.encode('UTF-8')
else:
name = common_name
self.ofile.write (code + '\t' + name + '\n')


##
## MAIN
##


ofile = sys.stdout
p = make_parser()
p.setErrorHandler(ErrorPrinter())
try:
dh = printLines(ofile)
p.setContentHandler(dh)
p.parse(sys.argv[1])
except IOError,e:
print in_sysID+": "+str(e)
except SAXException,e:
print str(e)

ofile.close()

+ 3
- 5
map-cc View File

@@ -1,13 +1,11 @@
#! /usr/bin/perl -w
use strict;

my $iso3166xml = shift;
my $iso3166tab = 'debian/iso_3166.tab';

# Get mapping of country names to country codes (i.e. reverse of
# iso3166tab.py output).
# Get mapping of country names to country codes
my %iso3166rev;
open ISO3166TAB, '-|:utf8', './iso3166tab.py', "$iso3166xml"
or die "open iso3166tab.py $iso3166xml: $!";
open(ISO3166TAB, "< $iso3166tab") || die "Unable to read $iso3166tab";
while (<ISO3166TAB>) {
/^([A-Z]+)\t(.*)$/ or next;
$iso3166rev{$2} = $1;


+ 2
- 3
mirrorlist View File

@@ -18,10 +18,9 @@ if (! defined $hostarch) {
chomp $hostarch;
}

my $iso3166xml = '/usr/share/xml/iso-codes/iso_3166.xml';
my $iso3166tab = 'debian/iso_3166.tab';
my %iso3166;
open ISO3166TAB, '-|:utf8', './iso3166tab.py', "$iso3166xml"
or die "open iso3166tab.py $iso3166xml: $!";
open(ISO3166TAB, "< $iso3166tab") || die "Unable to read $iso3166tab";
while (<ISO3166TAB>) {
/^([A-Z]+)\t(.*)$/ or next;
$iso3166{$1} = $2;


+ 3
- 6
mktemplates View File

@@ -5,10 +5,7 @@ set -e
# Script for generating a debconf templates file from both files
# in debian/po/*.po and country names translations from the
# iso-codes package
#
# Some variables
ISO3166XML=/usr/share/xml/iso-codes/iso_3166.xml
export ISO3166XML

# Translations location (relative to the build root directory)
ISO3166TRANSLATIONS=debian/iso-codes

@@ -81,7 +78,7 @@ for pofile in debian/po/*.po ; do
msgconv -t UTF-8 debian/po/$pofilename \
> debian/pobuild/$pofilename.other
msgconv -t UTF-8 "$ISO3166TRANSLATIONS/$pofilename" \
| ./map-cc "$ISO3166XML" \
| ./map-cc \
> debian/pobuild/$pofilename.iso-codes
# Update other template translations with templates.pot
msgmerge -U debian/pobuild/$pofilename.other \
@@ -102,7 +99,7 @@ done

if [ ! -f debian/po/en.po ]; then
printf " en..."
./map-cc "$ISO3166XML" < "$ISO3166TRANSLATIONS/en.po" > debian/pobuild/en.po
./map-cc < "$ISO3166TRANSLATIONS/en.po" > debian/pobuild/en.po
msgmerge -U debian/pobuild/en.po debian/pobuild/templates.pot 2>/dev/null
printf "Done.\n"
fi


Loading…
Cancel
Save