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
29 TEMP4=/tmp/${1}.mapped
31 FULLEXTRACT=/tmp/extracted-names
32 AWKCMD="/## PLACEHOLDER/ { \
33 while ( getline line < \"${TEMP}\" ) {print line} } \
35 while ( getline line < \"${TEMP3}\" ) {print line} } \
36 /## LOCALES_MAPPED/ { \
37 while ( getline line < \"${TEMP4}\" ) {print line} } \
40 grep '^LOCALES+' ${old}/Makefile > ${TEMP}
42 if [ $1 = "ctypedef" ]
44 keep=$(cat ${TEMP} | awk '{ print $2 ".src" }')
45 (cd ${old} && md5 -r ${keep} | sort) > ${TEMP2}
46 keep=$(awk '{ if ($1 != last1) print $2; last1 = $1; }' ${TEMP2})
47 for original in ${keep}
49 cp ${old}/${original} ${new}/
51 awk '{ if ($1 == last1) { print "SYMPAIRS+=\t" last2 " " $2 } \
52 else {last1 = $1; last2 = $2}}' ${TEMP2} > ${TEMP3}
54 /usr/bin/sed -E -e 's/[ ]+/ /g' \
55 ${CLDRDIR}/posix/UTF-8.cm \
56 > ${base}/../etc/final-maps/map.UTF-8
57 /usr/bin/sed -E -e 's/[ ]+/ /g' \
58 ${CLDRDIR}/posix/eucCN.cm \
59 > ${base}/../etc/final-maps/map.eucCN
60 /usr/bin/sed -E -e 's/[ ]+/ /g' \
61 ${CLDRDIR}/posix/eucCN.cm \
62 > ${base}/../etc/final-maps/map.GB2312
63 CHARMAPS="ARMSCII-8 Big5 CP1131 CP1251 \
64 CP866 GBK ISCII-DEV ISO8859-1 \
65 ISO8859-13 ISO8859-15 ISO8859-2 ISO8859-4 \
66 ISO8859-5 ISO8859-7 ISO8859-9 KOI8-R KOI8-U \
67 PT154 SJIS US-ASCII eucJP eucKR"
69 # GB18030 blows up, use pre-generate Illumos version
71 for map in ${CHARMAPS}
74 /usr/local/bin/perl ${base}/convert_map.pl \
75 ${base}/../etc/charmaps/${map}.TXT ${encoding} \
76 | /usr/bin/sed -E -e 's/ +/ /g' \
77 > ${base}/../etc/final-maps/map.${map}
78 echo map ${map} converted.
81 elif [ $1 = "colldef" ]
83 awk -v tmp4=${TEMP4} '$1 == "SAME+=" && $0 !~ /legacy/ {
86 gsub(/.*\./, "", orig)
87 gsub(/.*\./, "", dest)
89 print "LOCALES_MAPPED+=\t"$2 " "$3 > tmp4
92 for line in $(awk '{ print $3 }' ${TEMP4}); do
93 sed -i '' "/^SAME.*$line$/d" ${old}/Makefile
96 for enc in ${COLLATIONS_SPECIAL}; do
97 sed -i '' "/^.*${enc}$/d" ${TEMP4}
98 echo "LOCALES+= ${enc}" >> ${TEMP4}
101 keep=$(cat ${TEMP} | awk '{ print $2 }')
102 for original in ${keep}
104 cp ${old}/${original}.src ${new}/
106 else # below is everything but ctypedef
108 keep=$(cat ${TEMP} | awk '{ print $2 }')
109 for original in ${keep}
111 cp ${old}/${original}.src ${new}/
116 grep -v '^LOCALES+' ${old}/Makefile | awk "${AWKCMD}" > ${new}/Makefile
118 rm -f ${TEMP} ${TEMP3} ${TEMP4}