]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/makebuild.sh
move the server examples out of Docs and into a dir of its own so more people will...
[divverent/nexuiz.git] / misc / makebuild.sh
1 #!/bin/bash
2
3 set -e
4
5 # Options:
6 #   pw=foo          extract password
7 #   version=2.5     make a FINAL build
8 #   tag=FOO         insert FOO before the date in build names
9
10 base=`pwd`
11
12 # customizable specific stuff
13 basepk3=$base/data20080229.pk3 # 2.4
14 hotbasepk3= # hotfix
15 nexdir=$base/nexuiz
16 havocdir=$base/nexuiz/havoc
17 dpdir=$base/darkplaces
18 tmpdir=/tmp/NEX
19 zipdir=$base/builds
20 buildfiles=$base/nexuiz/misc/buildfiles
21 mingwdlls=$buildfiles/w32
22 osxapps=$buildfiles/osx
23 copystrip=$buildfiles/copystrip
24 zipdiff=$base/nexuiz/misc/zipdiff
25 fteqccdir="$base/fteqcc"
26 fteqccflags=""
27 menuqc=menu
28 newest=NEWEST
29 aft="perl -I/chroot/debian-etch/usr/share/aft /chroot/debian-etch/usr/bin/aft"
30 # end system specific stuff
31
32 case "$pw" in
33         '')
34                 zipflags=
35                 ;;
36         *)
37                 zipflags="-P $pw"
38                 ;;
39 esac
40
41 : ${date:=`date +%Y%m%d`}
42 : ${versiontag:=}
43 echo "date stamp: $date"
44
45 case "$version" in
46         '')
47                 version=2-svntest-$date
48                 versiontag=test
49                 defaultcfg=
50                 ext=
51                 ;;
52         *)
53                 version=$version
54                 versiontag=$versiontag
55                 defaultcfg=
56                 ext=_$version
57                 ;;
58 esac
59
60 mk7z()
61 {
62         7za a -tzip -mx=9 "$@"
63         chmod 644 "$1"
64 }
65
66 #if [ -n "$EXPERIMENTAL" ]; then
67 #       basepk3=$base/data20071231.pk3 # newer build to make smaller patches
68 #       nexdir=$base/nexuiz
69 #fi
70
71 # TODO normalize the builds
72 platforms='x86 amd64 osx'
73 buildon()
74 {
75         host=$1
76         prefix=$2
77         fteqccname=$3
78         path=$4
79         makeflags=$5
80         strip=$6
81
82         fteqcc_cflags=
83         case "$fteqccname" in
84                 *.exe)
85                         fteqcc_cflags=win
86                         ;;
87         esac
88
89         rm -f "$fteqccdir"/*.o
90         rm -f "$fteqccdir"/*.bin
91         rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . "$copystrip" "$fteqccdir" "$host:$path"
92         ssh "$host" ". ~/.profile && cd $path && COPYSTRIP_STRIP=$strip PATH=$path/copystrip:\$PATH make $makeflags clean nexuiz && cd ${fteqccdir##*/} && make $makeflags $fteqcc_cflags"
93         rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$host:$path/." .
94         for P in -dedicated -sdl -glx -wgl -agl -dedicated.exe -sdl.exe .exe; do
95                 [ -f nexuiz$P ] && mv nexuiz$P "$tmpdir/$prefix$P"
96                 [ -f nexuiz$P-withdebug ] && mv nexuiz$P-withdebug "$tmpdir/debuginfo/$prefix$P"
97         done
98         case "$fteqccname" in
99                 *.exe)
100                         mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
101                         ;;
102                 *)
103                         mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
104                         ;;
105         esac
106         make clean
107 }
108
109 build()
110 {
111         buildon nexmacbuild                           nexuiz-osx          fteqcc-osx          /tmp/Darkplaces.build 'CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"' strip
112         buildon eos.thruhere.net                      nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -g" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-i386/lib' strip
113         buildon alientrap.org                         nexuiz-linux-x86_64 fteqcc-linux-x86_64 /tmp/Darkplaces.build 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-x86_64/lib' strip
114         buildon alientrap.org                         nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="/chroot/debian-etch/usr/bin/i586-mingw32msvc-gcc -g -DSUPPORTDIRECTX -I/home/divverent/dxheaders" WINDRES=/chroot/debian-etch/usr/bin/i586-mingw32msvc-windres SDL_CONFIG=/home/divverent/sdl-win32/SDL-1.2.13/bin/sdl-config' /chroot/debian-etch/usr/bin/i586-mingw32msvc-strip
115                 mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
116                 mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
117 }
118
119 # avoid dupes
120 i=
121 while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
122         if [ -z "$i" ]; then
123                 i=a
124         else
125                 i=`echo "$i" | tr a-y b-z`
126         fi
127 done
128 ext=$i$ext
129
130 echo "Using build name nexuiz$date$ext"
131 sleep 3
132
133 # check for remains
134 conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
135 if [ -n "$conflicts" ]; then
136         echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
137         echo "NOT PROCEEDING"
138         echo
139         echo "$conflicts"
140         exit 1
141 fi
142
143 set -x
144
145 # prepare temp dir
146 rm -rf "$tmpdir"
147 mkdir -p "$tmpdir"
148
149 # clean up and patch DP
150 cd "$dpdir"
151 quilt pop -a || true
152 svn revert -R .
153 if [ -s patches/series ]; then
154         quilt push -a # apply all patches
155 fi
156
157 # prepare directory structure
158 cp -r "$osxapps"/*.app "$tmpdir"
159 mkdir "$tmpdir/debuginfo"
160 mkdir "$tmpdir/fteqcc"
161
162 # prepare fteqcc build
163 svn export "$fteqccdir" "$tmpdir/fteqcc/source"
164 svn info "$fteqccdir" > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
165 fteqccrev=$((`grep "Last Changed Rev:" "$tmpdir/fteqcc/source/fteqcc-base-revision.txt" | cut -d : -f 2`))
166 echo "fteqcc rev $fteqccrev"
167
168 # build all executables
169 rm -f *.exe nexuiz-* *-withdebug* *.o
170 make clean
171 build
172 rm -f *.exe nexuiz-* *-withdebug '.#'* *.o
173 rm -rf fteqcc copystrip
174 make clean
175
176 # move shell scripts and license
177 cd "$tmpdir"
178 cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
179 cp "$nexdir/gpl.txt" "$tmpdir/"
180
181 # prepare data
182 cd "$nexdir/data"
183 svn export . "$tmpdir/data"
184 svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
185 svn log > "$tmpdir/data/ChangeLog"
186
187 # prepare havoc
188 cd "$havocdir"
189 svn export . "$tmpdir/havoc"
190
191 # prepare Docs
192 cd "$nexdir/Docs"
193 svn export . "$tmpdir/Docs"
194
195 # prepare server
196 cd "$nexdir/server"
197 svn export . "$tmpdir/server"
198
199 # make gamesource
200 cd "$tmpdir/data"
201 mkdir -p "$tmpdir/sources"
202 mk7z ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
203
204 # make enginesource
205 cd "$dpdir"
206 svn export . "$tmpdir/darkplaces"
207 svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
208 svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
209 svn log > "$tmpdir/darkplaces/ChangeLog"
210 cd "$tmpdir"
211 mk7z "$tmpdir/sources/enginesource$date.zip" "darkplaces"
212 rm -rf darkplaces
213
214 # make fteqcc archive
215 cd "$tmpdir"
216 zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
217 rm -rf fteqcc
218
219 # clean fteqcc dir
220 cd "$fteqccdir"
221 rm -f *.o *.bin
222 make
223
224 # make local compiler
225 cd "$tmpdir/data"
226 make FTEQCC="$fteqccdir/fteqcc.bin"
227
228 # prepare root
229 rm -rf "$tmpdir/data/qcsrc"
230 cd "$tmpdir/Docs"
231 perl -pi -e '/^#---SET nexversion=([0-9.]*)$/ and $_ = "#---SET nexversion='$version'\n"' FAQ.aft
232 perl -pi -e '/^\s*Version ([0-9.]*)<\/div>$/ and $_ = "Version '$version'</div>\n"' Readme.htm
233 cp "$dpdir/darkplaces.txt" .
234 $aft FAQ.aft
235 $aft FAQ.aft
236 rm FAQ.aft-TOC
237 cd "$tmpdir/data"
238 mv common-spog.pk3 ..
239 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' default.cfg
240 if [ -n "$versiontag" ]; then
241         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
242         cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
243 fi
244 echo >> default.cfg
245 echo "$defaultcfg" >> default.cfg
246 mk7z ../data.pk3 .
247 cd "$tmpdir/havoc"
248 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version-havoc'\n"' default.cfg
249 if [ -n "$versiontag" ]; then
250         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
251 fi
252 echo >> default.cfg
253 echo "$defaultcfg" >> default.cfg
254 mk7z ../havoc.pk3 .
255
256 # make data pk3
257 cd "$tmpdir"
258 rm -rf data
259 mkdir data
260 mv data.pk3 data/data$tag$date.pk3
261 mv common-spog.pk3 data/
262 rm -rf havoc
263 mkdir havoc
264 mv havoc.pk3 havoc/data$tag${date}havoc.pk3
265
266 cp -r "$mingwdlls"/* .
267 # fix up permissions
268 chmod 644 *.dll *.exe
269
270 # make main structure
271 mkdir Nexuiz
272 mv * Nexuiz/ || true
273
274 find . -name .svn -exec rm -rf {} \; -prune
275
276 rm -f "$zipdir/nexuiz$date$ext.zip"
277 zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 Nexuiz/havoc/*
278 ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
279
280 rm -f "$zipdir/nexuizengineonly$date$ext.zip"
281 zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
282 ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
283
284 rm -f "$zipdir/nexuizsource$date$ext.zip"
285 zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
286 ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
287
288 # TODO remove these excludes after the version after 2.4.2
289 $zipdiff -o "Nexuiz/data/datapatch$tag$date.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3 \
290         -x 'sound/cdtracks/track*.ogg' \
291         -x 'sound/cdtracks/brainsukker.ogg' \
292         -x 'sound/cdtracks/breakdown-easy.ogg' \
293         -x 'sound/cdtracks/calling-bogus.ogg' \
294         -x 'sound/cdtracks/chaos-fog.ogg' \
295         -x 'sound/cdtracks/digital-pursuit.ogg' \
296         -x 'sound/cdtracks/infight.ogg' \
297         -x 'sound/cdtracks/neuronal-diving.ogg' \
298         -x 'sound/cdtracks/subcities.ogg' \
299         -x 'sound/cdtracks/thru-the-mirror.ogg'
300 mkdir -p sound/cdtracks
301 ln -snf track001.ogg sound/cdtracks/digital-pursuit.ogg
302 ln -snf track002.ogg sound/cdtracks/breakdown-easy.ogg
303 ln -snf track003.ogg sound/cdtracks/brainsukker.ogg
304 ln -snf track004.ogg sound/cdtracks/chaos-fog.ogg
305 ln -snf track005.ogg sound/cdtracks/infight.ogg
306 ln -snf track006.ogg sound/cdtracks/neuronal-diving.ogg
307 ln -snf track007.ogg sound/cdtracks/subcities.ogg
308 ln -snf track008.ogg sound/cdtracks/thru-the-mirror.ogg
309 ln -snf track009.ogg sound/cdtracks/calling-bogus.ogg
310 zip -9yr "Nexuiz/data/datapatch$tag$date.pk3" sound/cdtracks/*
311 rm -rf sound
312 [ -n "$hotbasepk3" ] && $zipdiff -o "Nexuiz/data/datapatch$tag$date""hotfix.pk3" -f "$hotbasepk3" -t Nexuiz/data/data$tag$date.pk3
313 mkdir -p gfx
314 if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
315         zip -9r "Nexuiz/data/datapatch$tag$date.pk3" gfx/brand.tga
316         [ -n "$hotbasepk3" ] && zip -9r "Nexuiz/data/datapatch$tag$date""hotfix.pk3" gfx/brand.tga
317         rm -rf gfx
318 fi
319
320 rm -f "$zipdir/nexuizpatch$date$ext.zip"
321 zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date.pk3 Nexuiz/havoc/*
322 ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
323
324 [ -n "$hotbasepk3" ] && rm -f "$zipdir/nexuizhotfix$date$ext.zip"
325 [ -n "$hotbasepk3" ] && zip $zipflags -9yr "$zipdir/nexuizhotfix$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date""hotfix.pk3 Nexuiz/havoc/*
326 [ -n "$hotbasepk3" ] && ln -snf nexuizhotfix$date$ext.zip "$zipdir/nexuizhotfix-$newest.zip"
327
328 rm -f "$zipdir/nexuizdocs$date$ext.zip"
329 zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs
330 ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
331
332 rm -f "$zipdir/nexuizdebug$date$ext.zip"
333 zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
334 ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"
335
336 case "$versiontag" in
337         test)
338                 ;;
339         *)
340                 cat <<'EOF'
341
342 NOTE: This is a RELEASE BUILD.
343
344 To upload and finish the build, these things have to be done:
345
346 - Test the build:
347   - On Linux/ATI
348   - On Vista/nvidia
349   - On Vista/ATI
350   - On Vista/Intel
351   - On OSX/ATI
352   - Turn on "developer 1"; watch out for suspicious messages.
353   - While testing, make sure all campaign levels are tested. In CTF/KH levels,
354     try to do a capture. After that, finish the game by prvm_edictset server 1
355     frags 1000.
356   - Play on a server running the new code. Ideally, that server should be public
357     and "somewhat compatible" to old clients, and some other players should be
358     on it.
359 - Post the build on the forum as a test release. E.g. run this script again
360   with the "version" variable NOT SET, so the build gets marked "testing only",
361   and upload it and post it on the forum for testing. Mention the test server
362   that is already running the new code. Wait for at least one week for critical
363   bug reports.
364 - If needed, fix the reported bugs and re-run this script for a release build.
365   Possibly repeat the testing process.
366 - Upload the "final" build you have just made to Sourceforge (upload.sf.net,
367   incoming). Use the naming scheme nexuiz-25.zip, nexuizpatch-24-to-25.zip
368 - Make the download available on sourceforge.
369 - Announce the build on the forum; update the downloads website. Note that the
370   download may be still unavailable because of the SF mirror system.
371 - Wait for the mirrors to catch up.
372 - Edit the website: make a new news item for the new release, change the logo
373   image in the top left for the new version (ask [-z-]).
374
375 EOF
376                 ;;
377 esac