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.
15 echo "finalize <type>' to package standard localization"
16 echo "type must be one of { monetdef, msgdef, numericdef, timedef, colldef, ctypedef }"
21 [ $1 = "monetdef" -o $1 = "msgdef" -o $1 = "colldef" -o \
22 $1 = "numericdef" -o $1 = "timedef" -o $1 = "ctypedef" ] || usage
25 base=$(dirname ${self})
26 old=${base}/../${1}.draft
28 TEMP=/tmp/${1}.locales
29 TEMP2=/tmp/${1}.hashes
30 TEMP3=/tmp/${1}.symlinks
31 TEMP4=/tmp/${1}.mapped
33 FULLEXTRACT=/tmp/extracted-names
34 AWKCMD="/## PLACEHOLDER/ { \
35 while ( getline line < \"${TEMP}\" ) {print line} } \
37 while ( getline line < \"${TEMP3}\" ) {print line} } \
38 /## LOCALES_MAPPED/ { \
39 while ( getline line < \"${TEMP4}\" ) {print line} } \
42 # Rename the sources with 3 components name into the POSIX version of the name using @modifier
45 for i in *_*_*.*.src; do
46 if [ "$i" = "*_*_*.*.src" ]; then
50 nname=`echo $oldname | awk '{ split($0, a, "_"); print a[1]"_"a[3]"@"a[2];} '`
51 mv -f ${oldname}.src ${nname}.src
52 sed -i '' -e "s/${oldname}/${nname}/g" Makefile
53 COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${oldname}/${nname}/g")
56 # For variable without @modifier ambiguity do not keep the @modifier
58 if [ "$i" = "*@*.src" ]; then
62 shortname=${oldname%@*}
63 if [ $(ls ${shortname}@* | wc -l) -eq 1 ] ; then
64 mv -f $i ${shortname}.src
65 sed -i '' -e "s/${oldname}/${shortname}/g" Makefile
66 COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${oldname}/${shortname}/g")
70 # Rename the modifiers into non abbreviated version
71 for i in *@Latn.src; do
72 if [ "$i" = "*@Latn.src" ]; then
75 mv -f ${i} ${i%@*}@latin.src
76 sed -i '' -e "s/${i%.*}/${i%@*}@latin/g" Makefile
77 COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${i%.*}/${i%@*}@latin/g")
80 for i in *@Cyrl.src; do
81 if [ "$i" = "*@Cyrl.src" ]; then
84 mv -f ${i} ${i%@*}@cyrillic.src
85 sed -i '' -e "s/${i%.*}/${i%@*}@cyrillic/g" Makefile
86 COLLATIONS_SPECIAL=$(echo ${COLLATIONS_SPECIAL} | sed -e "s/${i%.*}/${i%@*}@cyrillic/g")
89 # On locales with multiple modifiers rename the "default" version without the @modifier
90 default_locales="sr_RS@cyrillic"
91 for i in ${default_locales}; do
94 for l in ${localename}.*@${mod}.src; do
95 if [ "$l" = "${localename}.*@${mod}.src" ]; then
98 mv -f ${l} ${l%@*}.src
99 sed -i '' -e "s/${l%.*}/${l%@*}/g" Makefile
104 grep '^LOCALES+' ${old}/Makefile > ${TEMP}
106 if [ $1 = "ctypedef" ]
108 keep=$(cat ${TEMP} | awk '{ print $2 ".src" }')
109 (cd ${old} && md5 -r ${keep} | sort) > ${TEMP2}
110 keep=$(awk '{ if ($1 != last1) print $2; last1 = $1; }' ${TEMP2})
111 for original in ${keep}
113 cp ${old}/${original} ${new}/
115 awk '{ if ($1 == last1) { print "SYMPAIRS+=\t" last2 " " $2 } \
116 else {last1 = $1; last2 = $2}}' ${TEMP2} > ${TEMP3}
118 /usr/bin/sed -E -e 's/[ ]+/ /g' \
119 ${CLDRDIR}/posix/UTF-8.cm \
120 > ${base}/../etc/final-maps/map.UTF-8
121 /usr/bin/sed -E -e 's/[ ]+/ /g' \
122 ${CLDRDIR}/posix/eucCN.cm \
123 > ${base}/../etc/final-maps/map.eucCN
124 /usr/bin/sed -E -e 's/[ ]+/ /g' \
125 ${CLDRDIR}/posix/eucCN.cm \
126 > ${base}/../etc/final-maps/map.GB2312
127 CHARMAPS="ARMSCII-8 Big5 CP1131 CP1251 \
128 CP866 GBK ISCII-DEV ISO8859-1 \
129 ISO8859-13 ISO8859-15 ISO8859-2 ISO8859-4 \
130 ISO8859-5 ISO8859-7 ISO8859-9 KOI8-R KOI8-U \
131 PT154 SJIS US-ASCII eucJP eucKR"
133 # GB18030 blows up, use pre-generate Illumos version
135 for map in ${CHARMAPS}
138 /usr/local/bin/perl ${base}/convert_map.pl \
139 ${base}/../etc/charmaps/${map}.TXT ${encoding} \
140 | /usr/bin/sed -E -e 's/ +/ /g' \
141 > ${base}/../etc/final-maps/map.${map}
142 echo map ${map} converted.
145 elif [ $1 = "colldef" ]
147 awk -v tmp4=${TEMP4} '$1 == "SAME+=" && $0 !~ /legacy/ {
150 gsub(/.*\./, "", orig)
151 gsub(/.*\./, "", dest)
153 print "LOCALES_MAPPED+=\t"$2 " "$3 > tmp4
156 for line in $(awk '{ print $3 }' ${TEMP4}); do
157 sed -i '' "/^SAME.*$line$/d" ${old}/Makefile
160 for enc in ${COLLATIONS_SPECIAL}; do
161 sed -i '' "/^.*${enc}$/d" ${TEMP4}
162 echo "LOCALES+= ${enc}" >> ${TEMP4}
165 keep=$(cat ${TEMP} | awk '{ print $2 }')
166 for original in ${keep} ${COLLATIONS_SPECIAL}
168 cp ${old}/${original}.src ${new}/
170 else # below is everything but ctypedef
172 keep=$(cat ${TEMP} | awk '{ print $2 }')
173 for original in ${keep}
175 cp ${old}/${original}.src ${new}/
180 grep -v '^LOCALES+' ${old}/Makefile | awk "${AWKCMD}" > ${new}/Makefile
182 rm -f ${TEMP} ${TEMP3} ${TEMP4}