1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/bin/sh
[ -d debian/locales ] || mkdir debian/locales
[ -d debian/sort-tmp ] || mkdir debian/sort-tmp
cd debian/sort-tmp
for package in `ls -1 ../console-keymaps-*.templates`
do
pkgname=`basename $package| sed 's/\.templates//g'`
echo Sorting keymaps in $pkgname...
mkdir $pkgname || true
cd $pkgname
sed -n -e "/^Template: $pkgname\\/keymap/,/^Description:/p" ../../$pkgname/DEBIAN/templates |
sed -e "s/\\\\,/--/g" |
sed -e "s/\.UTF-8:/\.UTF-8,/g" |
perl -p -e '
chomp;
if (m/Choices-([^.]*)\.UTF-8,/) {
open (OUT, "> list.$1");
@t = split(/, /);
shift(@t);
my $cnt = 0;
foreach my $name (@t) {$cnt++; print OUT "$cnt $name\n";}
close OUT;
}
$_="";'
for file in list.*
do
lang=${file#list.}
echo -n $lang...
unilang=$(grep "^$lang.*\\.UTF-8" /usr/share/i18n/SUPPORTED | sed -e 1q | sed -e 's/[@. ].*//' )
# The following languages do have a UTF-8 locale, but without .UTF-8 postfix
if [ -z "$unilang" ]; then
case $lang in
gu|hi|ml|mr|pa|ta)
unilang=${lang}_IN ;;
bn) unilang=bn_BD ;;
dz) unilang=dz_BT ;;
km) unilang=km_KH ;;
ne) unilang=ne_NP ;;
vi) unilang=vi_VN ;;
wo) unilang=wo_SN ;;
esac
fi
if [ -z "$unilang" ]; then
echo "Warning: lang $lang skipped because no UTF-8 variant found" 1>&2
else
[ -d ../../locales/$unilang.UTF-8 ] || localedef -c -f UTF-8 -i $unilang ../../locales/$unilang.UTF-8
LOCPATH=`pwd` LC_ALL=../../locales/$unilang.UTF-8 sort -k 2.1 $file | sed -e 's/ .*/, /' | tr -d '\n' | sed -e "s/^/Indices-$lang.UTF-8: /" -e 's/, $//' > sorted$file
echo "" >>sorted$file
echo Done.
fi
done
# Now ../../$pkgname/DEBIAN/templates must be patched: all sortedlist.*
# files have to be added to the $pkgname/keymap template.
sed -e "/$pkgname.*keymap/{n;q;}" ../../$pkgname/DEBIAN/templates >templates.tmp
cat sorted* >>templates.tmp
sed -e "/$pkgname.*keymap/!d;/$pkgname.*keymap/{:end;n;b end}" ../../$pkgname/DEBIAN/templates | sed '1,2d' | sed 's/--/\\\\,/g' >>templates.tmp
mv templates.tmp ../../$pkgname/DEBIAN/templates
cd ..
done
cd ../..
# rm -r debian/locales debian/sort-tmp
|