iso_codes package no longer provides tab files, do generate them on fly

with sed (thanks D. Tardon)
This commit is contained in:
Ondrej Vasik 2009-08-10 13:55:46 +00:00
parent 8ee335d694
commit 0548eab325
3 changed files with 83 additions and 4 deletions

View File

@ -1,6 +1,6 @@
Summary: The basic directory layout for a Linux system Summary: The basic directory layout for a Linux system
Name: filesystem Name: filesystem
Version: 2.4.28 Version: 2.4.29
Release: 1%{?dist} Release: 1%{?dist}
License: Public Domain License: Public Domain
URL: https://fedorahosted.org/filesystem URL: https://fedorahosted.org/filesystem
@ -8,6 +8,8 @@ Group: System Environment/Base
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# Raw source1 URL: https://fedorahosted.org/filesystem/browser/lang-exceptions?format=raw # Raw source1 URL: https://fedorahosted.org/filesystem/browser/lang-exceptions?format=raw
Source1: https://fedorahosted.org/filesystem/browser/lang-exceptions Source1: https://fedorahosted.org/filesystem/browser/lang-exceptions
Source2: iso_639.sed
Source3: iso_3166.sed
Requires(Pre): setup >= 2.5.4-1 Requires(Pre): setup >= 2.5.4-1
BuildRequires: iso-codes BuildRequires: iso-codes
@ -31,6 +33,8 @@ rm -f $RPM_BUILD_DIR/filelist
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
mkdir %{buildroot} mkdir %{buildroot}
install -p -c -m755 %SOURCE2 %{buildroot}/iso_639.sed
install -p -c -m755 %SOURCE3 %{buildroot}/iso_3166.sed
cd %{buildroot} cd %{buildroot}
@ -44,7 +48,12 @@ mkdir -p mnt/{floppy,cdrom} \
ln -snf ../var/tmp usr/tmp ln -snf ../var/tmp usr/tmp
ln -snf spool/mail var/mail ln -snf spool/mail var/mail
grep -v "^$" /usr/share/iso-codes/iso_639.tab | grep -v "^#" | while read a b c d ; do sed -n -f %{buildroot}/iso_639.sed /usr/share/xml/iso-codes/iso_639.xml \
>%{buildroot}/iso_639.tab
sed -n -f %{buildroot}/iso_3166.sed /usr/share/xml/iso-codes/iso_3166.xml \
>%{buildroot}/iso_3166.tab
grep -v "^$" %{buildroot}/iso_639.tab | grep -v "^#" | while read a b c d ; do
[[ "$d" =~ "^Reserved" ]] && continue [[ "$d" =~ "^Reserved" ]] && continue
[[ "$d" =~ "^No linguistic" ]] && continue [[ "$d" =~ "^No linguistic" ]] && continue
@ -66,17 +75,21 @@ cat %{SOURCE1} | grep -v "^#" | grep -v "^$" | while read loc ; do
# If the locality is not official, skip it # If the locality is not official, skip it
if [ -n "$locality" ]; then if [ -n "$locality" ]; then
grep -q "^$locality" /usr/share/iso-codes/iso_3166.tab || continue grep -q "^$locality" %{buildroot}/iso_3166.tab || continue
fi fi
# If the locale is not official and not special, skip it # If the locale is not official and not special, skip it
if [ -z "$special" ]; then if [ -z "$special" ]; then
egrep -q "[[:space:]]${locale%_*}[[:space:]]" \ egrep -q "[[:space:]]${locale%_*}[[:space:]]" \
/usr/share/iso-codes/iso_639.tab || continue %{buildroot}/iso_639.tab || continue
fi fi
echo "%lang(${locale}) /usr/share/locale/${loc}" >> $RPM_BUILD_DIR/filelist echo "%lang(${locale}) /usr/share/locale/${loc}" >> $RPM_BUILD_DIR/filelist
echo "%lang(${locale}) %ghost %config(missingok) /usr/share/man/${loc}" >> $RPM_BUILD_DIR/filelist echo "%lang(${locale}) %ghost %config(missingok) /usr/share/man/${loc}" >> $RPM_BUILD_DIR/filelist
done done
rm -f %{buildroot}/iso_639.tab
rm -f %{buildroot}/iso_639.sed
rm -f %{buildroot}/iso_3166.tab
rm -f %{buildroot}/iso_3166.sed
cat $RPM_BUILD_DIR/filelist | grep "locale" | while read a b ; do cat $RPM_BUILD_DIR/filelist | grep "locale" | while read a b ; do
mkdir -p -m 755 %{buildroot}/$b/LC_MESSAGES mkdir -p -m 755 %{buildroot}/$b/LC_MESSAGES
@ -167,6 +180,10 @@ rm -rf %{buildroot}
/var/yp /var/yp
%changelog %changelog
* Mon Aug 10 2009 Ondrej Vasik <ovasik@redhat.com> 2.4.29-1
- iso_codes package no longer provides tab files, do generate
them on fly with sed (thanks D. Tardon)
* Wed Aug 05 2009 Ondrej Vasik <ovasik@redhat.com> 2.4.28-1 * Wed Aug 05 2009 Ondrej Vasik <ovasik@redhat.com> 2.4.28-1
- Provide/obsolete pm-utils-filesystem, own dirs for pm-utils - Provide/obsolete pm-utils-filesystem, own dirs for pm-utils
hooks(#515362) hooks(#515362)

31
iso_3166.sed Normal file
View File

@ -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

31
iso_639.sed Normal file
View File

@ -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