1#!/bin/sh 2# 3# This is a helper script for the Makefile in the parent directory. 4# When the localization definitions are generated in the draft area, 5# this script will copy base ones that others symlink to, and rearrange 6# the generate makefile to pull the LOCALES first. 7# 8 9usage () 10{ 11 echo "finalize <type>' to package standard localization" 12 echo "type must be one of { monetdef, msgdef, numericdef, timedef, colldef, ctypedef }" 13 exit 1 14} 15 16[ $# -ne 1 ] && usage 17[ $1 = "monetdef" -o $1 = "msgdef" -o $1 = "colldef" -o \ 18 $1 = "numericdef" -o $1 = "timedef" -o $1 = "ctypedef" ] || usage 19 20self=$(realpath $0) 21base=$(dirname ${self}) 22old=${base}/../${1}.draft 23new=${base}/../${1} 24TEMP=/tmp/${1}.locales 25TEMP2=/tmp/${1}.hashes 26TEMP3=/tmp/${1}.symlinks 27FULLMAP=/tmp/utf8-map 28FULLEXTRACT=/tmp/extracted-names 29AWKCMD="/## PLACEHOLDER/ { \ 30 while ( getline line < \"${TEMP}\" ) {print line} } \ 31 /## SYMPAIRS/ { \ 32 while ( getline line < \"${TEMP3}\" ) {print line} } \ 33 !/## / { print \$0 }" 34 35grep '^LOCALES+' ${old}/Makefile > ${TEMP} 36 37if [ $1 = "ctypedef" ] 38then 39keep=$(cat ${TEMP} | awk '{ print $2 ".src" }') 40(cd ${old} && md5 -r ${keep} | sort) > ${TEMP2} 41keep=$(awk '{ if ($1 != last1) print $2; last1 = $1; }' ${TEMP2}) 42for original in ${keep} 43do 44 cp ${old}/${original} ${new}/ 45done 46awk '{ if ($1 == last1) { print "SYMPAIRS+=\t" last2 ":" $2 } \ 47else {last1 = $1; last2 = $2}}' ${TEMP2} > ${TEMP3} 48rm -f ${TEMP2} 49 /usr/bin/sed -E -e 's/[ ]+/ /g' \ 50 ${CLDRDIR}/posix/UTF-8.cm \ 51 > ${base}/../etc/final-maps/map.UTF-8 52CHARMAPS="ARMSCII-8 Big5 Big5HKSCS CP1131 CP1251 \ 53 CP866 GB2312 GBK ISCII-DEV ISO8859-1 \ 54 ISO8859-13 ISO8859-15 ISO8859-2 ISO8859-4 \ 55 ISO8859-5 ISO8859-7 ISO8859-9 KOI8-R KOI8-U \ 56 PT154 SJIS US-ASCII eucCN eucJP eucKR" 57 58# GB18030 blows up, use pre-generate Illumos version 59 60for map in ${CHARMAPS} 61do 62encoding=${map} 63if [ ${map} = "Big5HKSCS" ] 64then 65encoding="Big5" 66fi 67/usr/local/bin/perl ${base}/convert_map.pl \ 68 ${base}/../etc/charmaps/${map}.TXT ${encoding} \ 69 | /usr/bin/sed -E -e 's/ +/ /g' \ 70 > ${base}/../etc/final-maps/map.${map} 71 echo map ${map} converted. 72done 73 74else # below is everything but ctypedef 75 76keep=$(cat ${TEMP} | awk '{ print $2 }') 77for original in ${keep} 78do 79 cp ${old}/${original}.src ${new}/ 80done 81 82fi 83 84grep -v '^LOCALES+' ${old}/Makefile | awk "${AWKCMD}" > ${new}/Makefile 85 86rm -f ${TEMP} ${TEMP3} 87