/[packages]/cauldron/myspell-dictionaries/current/SOURCES/myspell-genpackages.sh
ViewVC logotype

Contents of /cauldron/myspell-dictionaries/current/SOURCES/myspell-genpackages.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35973 - (show annotations) (download) (as text)
Mon Jan 24 02:16:51 2011 UTC (14 years ago) by spuhler
File MIME type: application/x-sh
File size: 3942 byte(s)
imported package myspell-dictionaries
1 #!/bin/bash
2
3 ##
4 ## Common section
5 ##
6
7 function GeneratePackageFilelist() {
8 dict=
9 hyph=
10 thes=
11 EXTRA=
12 if [ -z "${CONTENTS/*DICT*}" ]; then
13 dict="%doc doc/DICT/$PLANG/*"
14 EXTRA=" -f $PLANG.files"
15 fi
16 if [ -z "${CONTENTS/*HYPH*}" ]; then
17 hyph="%doc doc/HYPH/hyph_$PLANG/*"
18 fi
19 if [ -z "${CONTENTS/*THES*}" ]; then
20 thes="%doc doc/THES/th_$PLANG/*"
21 fi
22 cat << EOF
23
24 %files -n $PACKAGE$EXTRA
25 %defattr(-,root,root)
26 $dict
27 $hyph
28 $thes
29 #avoid marking dictionaries with %lang, to workaround
30 #https://qa.mandriva.com/show_bug.cgi?id=42782
31 #%lang($ISOCODE) %{dictdir}/*$PLANG*
32 %{dictdir}/*$PLANG*
33 %dir %{dictdir}
34 %dir %{mozdictdir}
35
36 EOF
37 }
38
39 function GeneratePackageScripts() {
40 echo "%post -n $PACKAGE"
41 for ptype in $CONTENTS; do
42 if [ $ptype == "DICT" ]; then
43 FILE="$PLANG"
44 else
45 FILE="$(echo ${ptype/THES/th} | tr [A-Z] [a-z])_$PLANG"
46 fi
47
48 for country in $ISOCOUNTRY; do
49 cat << EOF
50 if [[ ! -f "%{dictdir}/dictionary.lst" ]] || \
51 ! grep -q "^$ptype[ \t]*$ISOCODE[ \t]*$country[ \t]*$FILE" %{dictdir}/dictionary.lst
52 then
53 echo "$ptype $ISOCODE $country $FILE" >> %{dictdir}/dictionary.lst
54 fi
55 EOF
56 done
57 done
58
59 echo
60 echo "%preun -n $PACKAGE"
61 for ptype in $CONTENTS; do
62 if [ $ptype == "DICT" ]; then
63 FILE="$PLANG"
64 else
65 FILE="$(echo ${ptype/THES/th} | tr [A-Z] [a-z])_$PLANG"
66 fi
67
68 for country in $ISOCOUNTRY; do
69 cat << EOF
70 if [[ "\$1" = "0" ]]; then
71 perl -ni -e "/^$ptype\s*$ISOCODE\s*$country\s*$FILE\$/ or print" %{dictdir}/dictionary.lst
72 fi
73 EOF
74 done
75 done
76 }
77
78 ##
79 ## Handle PackageInfo
80 ##
81
82 function GeneratePackageInfo() {
83 dict=
84 hyph=
85 thes=
86 if [ -z "${CONTENTS/*DICT*}" ]; then
87 dict="
88 Provides: myspell-dictionary = %{version}-%{release}
89 # aspell = 1, myspell = 2, lang-specific = 3
90 Provides: enchant-dictionary = 2
91 "
92 fi
93 if [ -z "${CONTENTS/*HYPH*}" ]; then
94 unset hyph
95 if [ -n "$LOCALECODE" ]; then
96 hyph="
97 Obsoletes: myspell-hyph-$LOCALECODE < %{version}-%{release}
98 Provides: myspell-hyph-$LOCALECODE = %{version}-%{release}"
99 fi
100 hyph="$hyph
101 Obsoletes: myspell-hyph-$PLANG < %{version}-%{release}
102 Provides: myspell-hyph-$PLANG = %{version}-%{release}
103 Provides: myspell-hyphenation = %{version}-%{release}
104 "
105 fi
106 if [ -z "${CONTENTS/*THES*}" ]; then
107 unset thes
108 if [ -n "$LOCALECODE" ]; then
109 thes="
110 Obsoletes: myspell-thes-$LOCALECODE < %{version}-%{release}
111 Provides: myspell-thes-$LOCALECODE = %{version}-%{release}"
112 fi
113 thes="$thes
114 Obsoletes: myspell-thes-$PLANG < %{version}-%{release}
115 Provides: myspell-thes-$PLANG = %{version}-%{release}
116 Provides: myspell-thesaurus = %{version}-%{release}
117 "
118 fi
119 cat << EOF
120 %package -n $PACKAGE
121 Summary: MySpell spelling, hyphenation and thesaurus dictionaries for $PNAME
122 Version: %{version}
123 Release: %{release}
124 License: $LICENSE
125 Group: System/Internationalization
126 EOF
127 [ -z "$LOCALECODE" ] || cat << EOF
128 Provides: myspell-$LOCALECODE = %{version}-%{release}
129 EOF
130 cat << EOF
131 $dict
132 $hyph
133 $thes
134 EOF
135 [ -z "$LOCALECODE" ] || cat << EOF
136 Requires: locales-$LOCALECODE
137 EOF
138 cat << EOF
139
140 %description -n $PACKAGE
141 $PACKAGE contains spell checking data in $PNAME
142 to be used by OpenOffice.org or MySpell-capable applications like Mozilla. With this extension, you can compose a document in
143 $SHORT_LANGNAME and check for the typos easily.
144
145 EOF
146 }
147
148 ##
149 ## Main
150 ##
151
152 PLANG=$1
153 CONTENTS=$2
154 PNAME=$3
155 LICENSE=$4
156
157 [[ -z "$COMMAND$PLANG$PNAME$LICENSE" ]] && {
158 echo "%{error: ${0##*/}: Bad arguments}"
159 exit 0
160 }
161
162 ISOCODE=${PLANG%%_*} ISOCOUNTRY=${PLANG#*_}
163 [[ "$ISOCODE" = "$ISOCOUNTRY" ]] && ISOCOUNTRY=""
164
165 case $ISOCODE:$ISOCOUNTRY in
166 cop:EG|fj:FJ|la:LA|ny:MW|qu:BO|tet:ID)
167 LOCALECODE=
168 ;;
169 csb:CSB)
170 LOCALECODE=pl
171 ;;
172 gsc:FR)
173 LOCALECODE=oc
174 ;;
175 nb:NO|nn:NO)
176 LOCALECODE=no
177 ;;
178 ns:ZA)
179 LOCALECODE=nso
180 ;;
181 *)
182 LOCALECODE=$ISOCODE
183 ;;
184 esac
185
186 PACKAGE="myspell-$PLANG"
187
188 SHORT_LANGNAME=`echo "$PNAME" | sed -e "s/\([A-Z][^ ]*\).*/\1/"`
189 GeneratePackageInfo
190
191 #ISOCOUNTRY="$PLANG"
192 GeneratePackageScripts
193
194 GeneratePackageFilelist
195
196 exit 0

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30