Tue Dec 15 03:38:58 2009 UTC ()
Add a script to update the countries ISO/FIPS list.
(christos)
diff -r1.33 -r1.34 src/share/misc/Makefile
diff -r0 -r1.1 src/share/misc/make.country
--- src/share/misc/Makefile 2008/10/25 22:27:36 1.33
+++ src/share/misc/Makefile 2009/12/15 03:38:58 1.34
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: Makefile,v 1.33 2008/10/25 22:27:36 apb Exp $ | | 1 | # $NetBSD: Makefile,v 1.34 2009/12/15 03:38:58 christos Exp $ |
2 | # @(#)Makefile 8.1 (Berkeley) 6/8/93 | | 2 | # @(#)Makefile 8.1 (Berkeley) 6/8/93 |
3 | | | 3 | |
4 | NOOBJ= # defined | | 4 | NOOBJ= # defined |
5 | | | 5 | |
6 | FILES= NetBSD.el acronyms acronyms.comp airport ascii \ | | 6 | FILES= NetBSD.el acronyms acronyms.comp airport ascii \ |
7 | birthtoken bsd-family-tree \ | | 7 | birthtoken bsd-family-tree \ |
8 | country domains \ | | 8 | country domains \ |
9 | eqnchar flowers indent.pro inter.phone language man.template \ | | 9 | eqnchar flowers indent.pro inter.phone language man.template \ |
10 | mdoc.template na.phone na.postal operator style zipcodes | | 10 | mdoc.template na.phone na.postal operator style zipcodes |
11 | FILESDIR=${BINDIR}/misc | | 11 | FILESDIR=${BINDIR}/misc |
12 | | | 12 | |
13 | | | 13 | |
14 | # According to iana@ISI.EDU, the URL below is the authoritative list | | 14 | # According to iana@ISI.EDU, the URL below is the authoritative list |
| @@ -17,14 +17,17 @@ DOMAIN_URL= http://www.iana.org/root-who | | | @@ -17,14 +17,17 @@ DOMAIN_URL= http://www.iana.org/root-who |
17 | update-domains: | | 17 | update-domains: |
18 | ( \ | | 18 | ( \ |
19 | echo '# $$''NetBSD''$$' ; \ | | 19 | echo '# $$''NetBSD''$$' ; \ |
20 | echo '# ISO 3166 country codes, from ${DOMAIN_URL}' ; \ | | 20 | echo '# ISO 3166 country codes, from ${DOMAIN_URL}' ; \ |
21 | echo '# Last update:' `date` ; \ | | 21 | echo '# Last update:' `date` ; \ |
22 | echo '#' ; \ | | 22 | echo '#' ; \ |
23 | ftp -o - ${DOMAIN_URL} \ | | 23 | ftp -o - ${DOMAIN_URL} \ |
24 | | ${TOOL_SED} -n -f ${.CURDIR}/domains.sed \ | | 24 | | ${TOOL_SED} -n -f ${.CURDIR}/domains.sed \ |
25 | ) > domains ; \ | | 25 | ) > domains ; \ |
26 | | | 26 | |
27 | update-na.phone: | | 27 | update-na.phone: |
28 | < /dev/null ${TOOL_AWK} -f nanpa.awk > na.phone | | 28 | < /dev/null ${TOOL_AWK} -f nanpa.awk > na.phone |
29 | | | 29 | |
| | | 30 | update-country: |
| | | 31 | ${.CURDIR}/make.country > country |
| | | 32 | |
30 | .include <bsd.prog.mk> | | 33 | .include <bsd.prog.mk> |
#!/bin/sh
hdr() {
echo '#' '$'NetBSD'$'
cat << _EOF
#
# ISO 3166-1 Country Codes
#
# The format of an entry is:
# <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
#
# Further information can be found at the ISO 3166 Maintenance Agency
# (ISO 3166/MA) web site,
# <http://www.iso.org/iso/en/prods-services/iso3166ma/index.html>.
#
# FIPS 10-4 codes compiled from several sources, including
# http://www.statoids.com/wab.html
#
# ISO 3166-1 entities without exactly one corresponding FIPS code have a
# blank entry in the column. FIPS 10-4 codes without a corresponding
# ISO 3166-1 entity are excluded.
#
# This list is up-to-date as of $(date +%Y-%m-%d)
#
_EOF
}
I1=http://www.statoids.com/wab.html
O1=/tmp/wab.$$
I2=http://www.iso.org/iso/list-en1-semic-3.txt
O2=/tmp/list.$$
trap "rm -f wab.html list-en1-semic-3.txt $O1 $O2" 0 1 2 3 15
ftp $I1
ftp $I2
grep '<tr class="[oe]">' wab.html |
sed -e 's,<tr class="."><td>,,g' \
-e 's,\ ,,g' \
-e 's,<code>,,g' \
-e 's,</code>,,g' \
-e 's,<br>, ,g' \
-e 's,</td><td>, ,g' \
-e 's,Å,Aa,g' \
-e 's,ô,o,g' \
-e 's,</td></tr>,,g' |
awk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
grep -v href= |
sort > $O1
grep ';[A-Z][A-Z]' list-en1-semic-3.txt |
tr -d '\015' |
awk -F ';' '{ print $2 }' |
sort > $O2
hdr
join -t ' ' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort