[mingw-filesystem] Own all the locale folders below %{mingw32_datadir}/locale and %{mingw64_datadir}/locale (RHBZ #7983

Erik van Pienbroek epienbro at fedoraproject.org
Sat Aug 10 14:56:40 UTC 2013


commit f67070450fe06027ab92e5d0fed9f6fc938ba994
Author: Erik van Pienbroek <epienbro at fedoraproject.org>
Date:   Sat Aug 3 20:39:44 2013 +0200

    Own all the locale folders below %{mingw32_datadir}/locale and %{mingw64_datadir}/locale (RHBZ #798329)

 iso_3166.sed          |   31 +++++++++++++++
 iso_639.sed           |   31 +++++++++++++++
 lang-exceptions       |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 mingw-filesystem.spec |   55 +++++++++++++++++++++++++++
 4 files changed, 216 insertions(+), 0 deletions(-)
---
diff --git a/iso_3166.sed b/iso_3166.sed
new file mode 100644
index 0000000..705dbdb
--- /dev/null
+++ b/iso_3166.sed
@@ -0,0 +1,31 @@
+1,/<iso_3166_entries/b
+
+# on each new iso-code process the current one
+\!\(<iso_3166_entry\|</iso_3166_entries>\)!{
+    x
+    s/^$//
+    # we are on the first iso-code--nothing to process here
+    t
+    # process and write to output
+    s/\s\+/ /g
+    s/<iso_3166_entry//
+    s!/\s*>!!
+    # use '%' as a separator of parsed and unparsed input
+    s/\(.*\)alpha_2_code="\([^"]\+\)"\(.*\)/\2 % \1 \3/
+    s/\([^%]\+\)%\(.*\)alpha_3_code="\([^"]\+\)"\(.*\)/\1% \2 \4/
+    #  clear subst. memory for the next t
+    t clear
+    :clear
+    s/\([^%]\+\)%\(.*\)numeric_code="\([^"]\+\)"\(.*\)/\1% \2 \4/
+    t name
+    # no 3166 code--write xx
+    s/%/\tXX %/
+    :name
+    s/\([^%]\+\)%\(.*\)name="\([^"]\+\)"\(.*\)/\1\t\3/
+    s/ \t/\t/g
+    p
+    b
+    :noout
+}
+
+H
diff --git a/iso_639.sed b/iso_639.sed
new file mode 100644
index 0000000..e7e4d05
--- /dev/null
+++ b/iso_639.sed
@@ -0,0 +1,31 @@
+1,/<iso_639_entries/b
+
+# on each new iso-code process the current one
+\!\(<iso_639_entry\|</iso_639_entries>\)!{
+    x
+    s/^$//
+    # we are on the first iso-code--nothing to process here
+    t
+    # process and write to output
+    s/\s\+/ /g
+    s/<iso_639_entry//
+    s!/\s*>!!
+    # use '%' as a separator of parsed and unparsed input
+    s/\(.*\)iso_639_2T_code="\([^"]\+\)"\(.*\)/\2 % \1 \3/
+    s/\([^%]\+\)%\(.*\)iso_639_2B_code="\([^"]\+\)"\(.*\)/\1\t\3 % \2 \4/
+    #  clear subst. memory for the next t
+    t clear
+    :clear
+    s/\([^%]\+\)%\(.*\)iso_639_1_code="\([^"]\+\)"\(.*\)/\1\t\3 % \2 \4/
+    t name
+    # no 639-1 code--write xx
+    s/%/\tXX %/
+    :name
+    s/\([^%]\+\)%\(.*\)name="\([^"]\+\)"\(.*\)/\1\t\3/
+    s/ \t/\t/g
+    p
+    b
+    :noout
+}
+
+H
diff --git a/lang-exceptions b/lang-exceptions
new file mode 100644
index 0000000..8568e5f
--- /dev/null
+++ b/lang-exceptions
@@ -0,0 +1,99 @@
+# This file contains a list of locality-specifc locales for which we ship
+# translations.
+#
+# The easiest way to generate this file is something along the lines of:
+#
+# repoquery -qal | awk -F '/' '/^\/usr\/share\/locale\/[a-z]*[_@]+/ { print $5 }' | sort -u
+# 
+# and then sorting out the various invalid entires. (all_languages, locales
+# with charset definitions (.UTF-8, etc.))
+af_ZA
+am_ET
+ast_ES
+az_IR
+bg_BG
+bn_IN
+ca at valencia
+ca_ES
+ca_ES at valencian
+cs_CZ
+de_AT
+de_CH
+de_DE
+default
+el_GR
+en_AU
+en_CA
+en_GB
+en_US
+en_NZ
+es_AR
+es_CL
+es_CO
+es_CR
+es_DO
+es_EC
+es_ES
+es_GT
+es_HN
+es_MX
+es_NI
+es_PA
+es_PE
+es_PR
+es_SV
+es_UY
+es_VE
+et_EE
+eu_ES
+fa_IR
+fi_FI
+fr_BE
+fr_CA
+fr_CH
+fr_FR
+gl_ES
+he_IL
+hr_HR
+hu_HU
+it_CH
+it_IT
+ja_JP
+ko_KR
+ks at devanagari
+lv_LV
+ms_MY
+my_MM
+nb_NO
+nds_DE
+nl_BE
+nl_NL
+pl_PL
+pt_BR
+pt_PT
+ru_RU
+sl_SI
+sq_AL
+sr_RS
+sv_SE
+uk_UA
+ur_PK
+zh_CN
+zh_CN.GB2312
+zh_HK
+zh_TW
+zh_TW.Big5
+en at boldquot
+en at quot
+nds at NFE
+sr at ije
+sr at ijekavian
+sr at ijekavianlatin
+sr at latin
+sr at Latn
+uz at cyrillic
+uz at Latn
+be at latin
+en at shaw
+brx
+brx_IN
diff --git a/mingw-filesystem.spec b/mingw-filesystem.spec
index 640e2e0..d8e141d 100644
--- a/mingw-filesystem.spec
+++ b/mingw-filesystem.spec
@@ -32,6 +32,13 @@ Source16:       standard-dlls-mingw32
 # (rpm -ql mingw64-crt | grep '\.a$' | while read f ; do x86_64-w64-mingw32-dlltool -I $f 2>/dev/null ; done) | sort | uniq | tr A-Z a-z > standard-dlls-mingw64
 Source17:       standard-dlls-mingw64
 
+# Taken from the Fedora filesystem package
+Source101:      https://fedorahosted.org/filesystem/browser/lang-exceptions
+Source102:      iso_639.sed
+Source103:      iso_3166.sed
+
+BuildRequires:  iso-codes
+
 
 %description
 This package contains the base filesystem layout, RPM macros and
@@ -187,6 +194,7 @@ mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/man/man
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/aclocal
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/themes
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/cmake
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/locale
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/pkgconfig
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/i686-w64-mingw32/sys-root/mingw/share/xml
 
@@ -198,9 +206,55 @@ mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/man/m
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/aclocal
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/themes
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/cmake
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/locale
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/pkgconfig
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/xml
 
+# Own folders for all locales
+# Snippet taken from the Fedora filesystem package
+sed -n -f %{SOURCE102} /usr/share/xml/iso-codes/iso_639.xml > $RPM_BUILD_ROOT/iso_639.tab
+sed -n -f %{SOURCE103} /usr/share/xml/iso-codes/iso_3166.xml > $RPM_BUILD_ROOT/iso_3166.tab
+
+grep -v "^$" $RPM_BUILD_ROOT/iso_639.tab | grep -v "^#" | while read a b c d ; do
+    [[ "$d" =~ "^Reserved" ]] && continue
+    [[ "$d" =~ "^No linguistic" ]] && continue
+
+    locale=$c
+    if [ "$locale" = "XX" ]; then
+        locale=$b
+    fi
+    echo "%lang(${locale}) %{_prefix}/i686-w64-mingw32/sys-root/mingw/share/locale/${locale}" >> filelist_mingw32
+    echo "%lang(${locale}) %{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/locale/${locale}" >> filelist_mingw64
+done
+
+cat %{SOURCE101} | grep -v "^#" | grep -v "^$" | while read loc ; do
+    locale=$loc
+    locality=
+    special=
+    [[ "$locale" =~ "@" ]] && locale=${locale%%%%@*}
+    [[ "$locale" =~ "_" ]] && locality=${locale##*_}
+    [[ "$locality" =~ "." ]] && locality=${locality%%%%.*}
+    [[ "$loc" =~ "_" ]] || [[ "$loc" =~ "@" ]] || special=$loc
+
+    # If the locality is not official, skip it
+    if [ -n "$locality" ]; then
+        grep -q "^$locality" $RPM_BUILD_ROOT/iso_3166.tab || continue
+    fi
+    # If the locale is not official and not special, skip it
+    if [ -z "$special" ]; then
+        egrep -q "[[:space:]]${locale%%_*}[[:space:]]" $RPM_BUILD_ROOT/iso_639.tab || continue
+    fi
+    echo "%lang(${locale}) %{_prefix}/i686-w64-mingw32/sys-root/mingw/share/locale/${loc}" >> filelist_mingw32
+    echo "%lang(${locale}) %{_prefix}/x86_64-w64-mingw32/sys-root/mingw/share/locale/${loc}" >> filelist_mingw64
+done
+
+rm -f $RPM_BUILD_ROOT/iso_639.tab
+rm -f $RPM_BUILD_ROOT/iso_3166.tab
+
+cat filelist_mingw32 filelist_mingw64 | grep "locale" | while read a b ; do
+    mkdir -p -m 755 %{buildroot}/$b/LC_MESSAGES
+done
+
 # NB. NOT _libdir
 mkdir -p $RPM_BUILD_ROOT/usr/lib/rpm
 install -m 0755 %{SOURCE6} $RPM_BUILD_ROOT%{_rpmconfigdir}
@@ -252,6 +306,7 @@ install -m 0644 %{SOURCE12} $RPM_BUILD_ROOT%{_datadir}/mingw/
 %changelog
 * Sat Aug  3 2013 Erik van Pienbroek <epienbro at fedoraproject.org> - 99-3
 - Own the folders %%{mingw32_libdir}/cmake and %%{mingw64_libdir}/cmake
+- Own all the locale folders below %%{mingw32_datadir}/locale and %%{mingw64_datadir}/locale (RHBZ #798329)
 
 * Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org>
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild


More information about the scm-commits mailing list