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