|
- #!/bin/sh
-
- 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
- ISO3166TAB=/usr/share/iso-codes/iso_3166.tab
- export ISO3166TAB
- # Translations location (relative to the build root directory)
- ISO3166TRANSLATIONS=debian/iso-codes
-
- # Get the ordered list of countries from the iso_3166.tab, sorted
- # according to the regionmap.
- #
- # We need to escape commas by preceding them with a backslash.
- HTTPCODECHOICES=`cat debian/httplist-countries`
- FTPCODECHOICES=`cat debian/ftplist-countries`
-
- printf "Creating the list of countries for HTTP mirrors..."
- # We need building the choices list with English names rather than codes
- HTTPCHOICES=$(cat debian/httplist-countries | \
- (read a; echo -n `grep -i "^$a" $ISO3166TAB | cut -b 4-` ; while read b; do echo -n ", "`grep -i "^$b" $ISO3166TAB | cut -b 4- | sed 's/,/\\\\\\\\,/g'`; done; echo))
- printf " Done.\n"
-
- printf "Creating the list of countries for FTP mirrors..."
- FTPCHOICES=$(cat debian/ftplist-countries | \
- (read a; echo -n `grep -i "^$a" $ISO3166TAB | cut -b 4-` ; while read b; do echo -n ", "`grep -i "^$b" $ISO3166TAB | cut -b 4- | sed 's/,/\\\\\\\\,/g'`; done; echo))
- printf " Done.\n"
-
- printf "Insert the lists of choices into the templates file..."
- # Now put this list as the choices in the templates
- # and defined this field as translatable (__Choices hack)
- cat debian/templates-in | \
- perl -pe 's/\@httpcountrylist\@/'"$HTTPCHOICES"'/g' | \
- perl -pe 's/\@ftpcountrylist\@/'"$FTPCHOICES"'/g' | \
- sed "/^_Choices: enter/s/_Choices:/__Choices:/g" \
- >debian/templates.tmp
- printf " Done.\n"
-
- # Create a temporary "pobuild" directory
- rm -rf debian/pobuild >/dev/null 2>&1
- mkdir debian/pobuild
-
- # Create the appropriate POTFILES.in file there
- cat >debian/pobuild/POTFILES.in <<EOF
- [type: gettext/rfc822deb] templates.tmp
- EOF
-
- # Create the appropriate output file also
- cat >debian/pobuild/output <<EOF
- 2 utf8
- EOF
-
- # Run debconf-updatepo on this directory
- # -->this will create pobuild/templates.pot
- debconf-updatepo --podir debian/pobuild
-
- printf "Include country names translations into the templates file:\n"
- # The following takes place for each language
- # (each existing file in debian/po)
- for pofile in debian/po/*.po ; do
- pofilename=`basename $pofile`
- langname=`basename $pofilename .po`
- printf " $langname..."
- # If the country names are translated, we need to merge
- # the translation with the templates translations
- if [ -f $ISO3166TRANSLATIONS/$pofilename ]
- then
- # Output is verbose, don't worry
- # Copy other templates translations
- cp debian/po/$pofilename debian/pobuild/$pofilename.copied
- # Update it with templates.pot
- msgmerge -U debian/pobuild/$pofilename.copied \
- debian/pobuild/templates.pot 2>/dev/null
- # merge with iso-codes translations
- # if charsets differ, this may output some "error" messages we ignore
- msgmerge debian/iso-codes/$pofilename \
- debian/pobuild/$pofilename.copied \
- > debian/pobuild/$pofilename 2>/dev/null
- # clean out the generated file
- msgmerge -U debian/pobuild/$pofilename \
- debian/pobuild/templates.pot 2>/dev/null
- # Else we just use what's translated
- else
- cp $pofile debian/pobuild/$pofilename && true
- fi
- printf "Done.\n"
- done
-
- # and now we generate the templates file from all this
- PODEBCONF_LIB=. po2debconf --podir debian/pobuild debian/templates.tmp >debian/choose-mirror.templates
|