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)
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
29 echo " ${basename} -h [-d <dir>] [-c <capability> -s <string>]"
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 './')"
49 echo " -s new string value for the capability"
52 echo " ${basename} -c network -s +Freeciv.Devel.2011.JAN.30"
56 # print carfulness hint
60 echo "Please check all changes done by this script carefully!"
68 while getopts "c:d:hs:" option
90 echo "Unimplemented option chosen (${option})."
98 if test "x$string" = "x" ; then
99 echo "Not setting empty capability string, use -s \"string\"" >&2
107 echo -e "setting ai module capability: ${string}\n"
108 file=`find $basedir -name "ai.h"`
111 | grep "FC_AI_MOD_CAPSTR " \
112 | sed 's/#define FC_AI_MOD_CAPSTR "\(.*\)".*/\1/'`
114 echo "* Replacing \"${old}\" with \"${string}\" in:"
116 |
sed "s/\"$old\"/\"$string\"/g" \
119 cmp $file $file.$$
>/dev
/null \
120 ||
(mv $file.$$
$file && echo " ${file}")
127 echo -e "setting network capability: ${string}\n"
128 file=`find $basedir -name "fc_version"`
131 | grep "NETWORK_CAPSTRING_MANDATORY=" \
132 | sed 's/NETWORK_CAPSTRING_MANDATORY="\(.*\)".*/\1/'`
134 echo "* Replacing \"${old}\" with \"${string}\" in:"
136 |
sed "s/\"$old\"/\"$string\"/g" \
139 cmp $file $file.$$
>/dev
/null \
140 ||
(mv $file.$$
$file && echo " ${file}")
146 echo -e "setting tilespec capability: $string\n"
147 file=`find $basedir -name "tilespec\.c"`
150 | grep "#define TILESPEC_CAPSTR" \
151 | sed 's/#define TILESPEC_CAPSTR "\(.*\) duplicates_ok".*/\1/'`
153 echo "* Replacing \"${old}\" with \"${string}\" in:"
155 |
sed "s/\"$old/\"$string/g" \
157 cmp $file $file.$$
>/dev
/null \
158 ||
(mv $file.$$
$file && echo " ${file}")
161 files
=`find $basedir -name "*\.tilespec"`
162 for file in $files; do
164 |
sed "s/$old/$string/g" \
167 cmp $file $file.$$
>/dev
/null \
168 ||
(mv $file.$$
$file && echo " ${file}")
175 echo -e "setting soundspec capability: $string\n"
176 file=`find $basedir -name "audio\.c"`
179 | grep "#define SOUNDSPEC_CAPSTR" \
180 | sed 's/#define SOUNDSPEC_CAPSTR "\(.*\)".*/\1/'`
182 echo "* Replacing \"${old}\" with \"${string}\" in:"
184 |
sed "s/\"$old/\"$string/g" \
186 cmp $file $file.$$
>/dev
/null \
187 ||
(mv $file.$$
$file && echo " ${file}")
190 files
=`find $basedir -name "*\.soundspec"`
191 for file in $files; do
193 |
sed "s/$old/$string/g" \
196 cmp $file $file.$$
>/dev
/null \
197 ||
(mv $file.$$
$file && echo " ${file}")
204 echo -e "setting musicspec capability: $string\n"
205 file=`find $basedir -name "audio\.c"`
208 | grep "#define MUSICSPEC_CAPSTR" \
209 | sed 's/#define MUSICSPEC_CAPSTR "\(.*\)".*/\1/'`
211 echo "* Replacing \"${old}\" with \"${string}\" in:"
213 |
sed "s/\"$old/\"$string/g" \
215 cmp $file $file.$$
>/dev
/null \
216 ||
(mv $file.$$
$file && echo " ${file}")
219 files
=`find $basedir -name "*\.musicspec"`
220 for file in $files; do
222 |
sed "s/$old/$string/g" \
225 cmp $file $file.$$
>/dev
/null \
226 ||
(mv $file.$$
$file && echo " ${file}")
232 echo -e "setting spec capability: $string\n"
234 file=`find $basedir -name "tilespec.c"`
237 | grep "#define SPEC_CAPSTR " \
238 | sed 's/#define SPEC_CAPSTR "\(.*\)".*/\1/'`
240 echo "* Replacing \"${old}\" with \"${string}\" in:"
242 |
sed "s/\"$old/\"$string/g" \
244 cmp $file $file.$$
>/dev
/null \
245 ||
(mv $file.$$
$file && echo " ${file}")
248 files
=`find $basedir -name "*\.spec"`
249 for file in $files; do
251 |
sed "s/$old/$string/g" \
254 cmp $file $file.$$
>/dev
/null \
255 ||
(mv $file.$$
$file && echo " ${file}")
261 echo -e "setting ruleset capability: $string\n"
263 file=`find $basedir -name "ruleset\.h"`
266 | grep "#define RULESET_CAPABILITIES " \
267 | sed 's/#define RULESET_CAPABILITIES "\(.*\)".*/\1/'`
269 echo "* Replacing \"${old}\" with \"${string}\" in:"
271 |
sed "s/\"$old/\"$string/g" \
273 cmp $file $file.$$
>/dev
/null \
274 ||
(mv $file.$$
$file && echo " - ${file}")
277 files
=`find $basedir -name "*\.ruleset"`
278 for file in $files; do
280 |
sed "s/$old/$string/g" \
283 cmp $file $file.$$
>/dev
/null \
284 ||
(mv $file.$$
$file && echo " ${file}")
296 echo "Unknown capability value: ${capability}"