Updated Finnish translation.
[freeciv.git] / scripts / capabilities
blob698e940c2610ff64fe214ee30725ecce65a3da75
1 #!/bin/bash
2 #/**********************************************************************
3 # Freeciv - Copyright (C) 2010
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 #***********************************************************************/
16 # update capability string for
17 # - network
18 # - tilespec
19 # - soundspec
20 # - musicspec
21 # - spec
22 # - ruleset
24 # print usage
25 function usage()
27 echo ""
28 echo "USAGE:"
29 echo " ${basename} -h [-d <dir>] [-c <capability> -s <string>]"
30 echo ""
31 echo "OPTIONS:"
32 echo " -c the capability to change. One of:"
33 echo " aimodules: AI modules capability"
34 echo " (\"+Freeciv-ai-module-YYYY.MMM.DD\")"
35 echo " network: network capability"
36 echo " (\"+Freeciv.Devel.YYYY.MMM.DD\")"
37 echo " tilespec: tileset capability"
38 echo " (\"+Freeciv-tilespec-Devel-YYYY.MMM.DD\")"
39 echo " soundspec: soundset capability"
40 echo " (\"+Freeciv-soundspec-Devel-YYYY.MMM.DD\")"
41 echo " musicspec: musicset capability"
42 echo " (\"+Freeciv-musicspec-Devel-YYYY.MMM.DD\")"
43 echo " spec: spec file capability"
44 echo " (\"+Freeciv-spec-Devel-YYYY.MMM.DD\")"
45 echo " ruleset: ruleset capability"
46 echo " (\"+Freeciv-ruleset-Devel-YYYY.MMM.DD\")"
47 echo " -d base directory (defaults to './')"
48 echo " -h this help"
49 echo " -s new string value for the capability"
50 echo ""
51 echo "EXAMPLE:"
52 echo " ${basename} -c network -s +Freeciv.Devel.2011.JAN.30"
53 echo ""
56 # print carfulness hint
57 function careful()
59 echo ""
60 echo "Please check all changes done by this script carefully!"
61 echo ""
64 # process arguments
65 capability="usage"
66 string=
67 basedir="./"
68 while getopts "c:d:hs:" option
70 case $option in
71 h )
72 usage
73 exit 0
76 c )
77 capability=$OPTARG
80 d )
81 basedir=$OPTARG
84 s )
85 string=$OPTARG
88 * )
89 echo ""
90 echo "Unimplemented option chosen (${option})."
91 usage
92 exit 1
95 esac
96 done
98 if test "x$string" = "x" ; then
99 echo "Not setting empty capability string, use -s \"string\"" >&2
100 exit 1
103 case $capability in
104 aimodules )
105 careful
107 echo -e "setting ai module capability: ${string}\n"
108 file=`find $basedir -name "ai.h"`
110 old=`cat $file \
111 | grep "FC_AI_MOD_CAPSTR " \
112 | sed 's/#define FC_AI_MOD_CAPSTR "\(.*\)".*/\1/'`
114 echo "* Replacing \"${old}\" with \"${string}\" in:"
115 cat $file \
116 | sed "s/\"$old\"/\"$string\"/g" \
117 > $file.$$
119 cmp $file $file.$$ >/dev/null \
120 || (mv $file.$$ $file && echo " ${file}")
121 rm -f $file.$$
124 network )
125 careful
127 echo -e "setting network capability: ${string}\n"
128 file=`find $basedir -name "fc_version"`
130 old=`cat $file \
131 | grep "NETWORK_CAPSTRING_MANDATORY=" \
132 | sed 's/NETWORK_CAPSTRING_MANDATORY="\(.*\)".*/\1/'`
134 echo "* Replacing \"${old}\" with \"${string}\" in:"
135 cat $file \
136 | sed "s/\"$old\"/\"$string\"/g" \
137 > $file.$$
139 cmp $file $file.$$ >/dev/null \
140 || (mv $file.$$ $file && echo " ${file}")
141 rm -f $file.$$
144 tilespec )
145 careful
146 echo -e "setting tilespec capability: $string\n"
147 file=`find $basedir -name "tilespec\.c"`
149 old=`cat $file \
150 | grep "#define TILESPEC_CAPSTR" \
151 | sed 's/#define TILESPEC_CAPSTR "\(.*\) duplicates_ok".*/\1/'`
153 echo "* Replacing \"${old}\" with \"${string}\" in:"
154 cat $file \
155 | sed "s/\"$old/\"$string/g" \
156 > $file.$$
157 cmp $file $file.$$ >/dev/null \
158 || (mv $file.$$ $file && echo " ${file}")
159 rm -f $file.$$
161 files=`find $basedir -name "*\.tilespec"`
162 for file in $files; do
163 cat $file \
164 | sed "s/$old/$string/g" \
165 > $file.$$
167 cmp $file $file.$$ >/dev/null \
168 || (mv $file.$$ $file && echo " ${file}")
169 rm -f $file.$$
170 done
173 soundspec )
174 careful
175 echo -e "setting soundspec capability: $string\n"
176 file=`find $basedir -name "audio\.c"`
178 old=`cat $file \
179 | grep "#define SOUNDSPEC_CAPSTR" \
180 | sed 's/#define SOUNDSPEC_CAPSTR "\(.*\)".*/\1/'`
182 echo "* Replacing \"${old}\" with \"${string}\" in:"
183 cat $file \
184 | sed "s/\"$old/\"$string/g" \
185 > $file.$$
186 cmp $file $file.$$ >/dev/null \
187 || (mv $file.$$ $file && echo " ${file}")
188 rm -f $file.$$
190 files=`find $basedir -name "*\.soundspec"`
191 for file in $files; do
192 cat $file \
193 | sed "s/$old/$string/g" \
194 > $file.$$
196 cmp $file $file.$$ >/dev/null \
197 || (mv $file.$$ $file && echo " ${file}")
198 rm -f $file.$$
199 done
202 musicspec )
203 careful
204 echo -e "setting musicspec capability: $string\n"
205 file=`find $basedir -name "audio\.c"`
207 old=`cat $file \
208 | grep "#define MUSICSPEC_CAPSTR" \
209 | sed 's/#define MUSICSPEC_CAPSTR "\(.*\)".*/\1/'`
211 echo "* Replacing \"${old}\" with \"${string}\" in:"
212 cat $file \
213 | sed "s/\"$old/\"$string/g" \
214 > $file.$$
215 cmp $file $file.$$ >/dev/null \
216 || (mv $file.$$ $file && echo " ${file}")
217 rm -f $file.$$
219 files=`find $basedir -name "*\.musicspec"`
220 for file in $files; do
221 cat $file \
222 | sed "s/$old/$string/g" \
223 > $file.$$
225 cmp $file $file.$$ >/dev/null \
226 || (mv $file.$$ $file && echo " ${file}")
227 rm -f $file.$$
228 done
231 spec )
232 echo -e "setting spec capability: $string\n"
233 careful
234 file=`find $basedir -name "tilespec.c"`
236 old=`cat $file \
237 | grep "#define SPEC_CAPSTR " \
238 | sed 's/#define SPEC_CAPSTR "\(.*\)".*/\1/'`
240 echo "* Replacing \"${old}\" with \"${string}\" in:"
241 cat $file \
242 | sed "s/\"$old/\"$string/g" \
243 > $file.$$
244 cmp $file $file.$$ >/dev/null \
245 || (mv $file.$$ $file && echo " ${file}")
246 rm -f $file.$$
248 files=`find $basedir -name "*\.spec"`
249 for file in $files; do
250 cat $file \
251 | sed "s/$old/$string/g" \
252 > $file.$$
254 cmp $file $file.$$ >/dev/null \
255 || (mv $file.$$ $file && echo " ${file}")
256 rm -f $file.$$
257 done
260 ruleset )
261 echo -e "setting ruleset capability: $string\n"
262 careful
263 file=`find $basedir -name "ruleset\.h"`
265 old=`cat $file \
266 | grep "#define RULESET_CAPABILITIES " \
267 | sed 's/#define RULESET_CAPABILITIES "\(.*\)".*/\1/'`
269 echo "* Replacing \"${old}\" with \"${string}\" in:"
270 cat $file \
271 | sed "s/\"$old/\"$string/g" \
272 > $file.$$
273 cmp $file $file.$$ >/dev/null \
274 || (mv $file.$$ $file && echo " - ${file}")
275 rm -f $file.$$
277 files=`find $basedir -name "*\.ruleset"`
278 for file in $files; do
279 cat $file \
280 | sed "s/$old/$string/g" \
281 > $file.$$
283 cmp $file $file.$$ >/dev/null \
284 || (mv $file.$$ $file && echo " ${file}")
285 rm -f $file.$$
286 done
289 usage )
290 usage
291 exit 0
295 echo ""
296 echo "Unknown capability value: ${capability}"
297 usage
298 exit 1
301 esac