]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/makebuild.sh
Merge branch 'master' of ssh://xonotic@git.xonotic.org/xonotic
[xonotic/xonotic.git] / misc / tools / 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 netradiant_release=1.5.0-svn402
14 basepk3=$base/data20090403.pk3 # 2.5
15 hotbasepk3=$base/data20091001.pk3 # hotfix
16 nexdir=$base/nexuiz
17 havocdir=$base/nexuiz/havoc
18 dpdir=$base/darkplaces
19 tmpdir=/tmp/NEX
20 zipdir=$base/builds
21 buildfiles=$base/nexuiz/misc/buildfiles
22 mingwdlls=$buildfiles/w32
23 osxapps=$buildfiles/osx
24 copystrip=$buildfiles/copystrip
25 zipdiff=$base/nexuiz/misc/tools/zipdiff
26 fteqccdir="$base/fteqcc"
27 fteqccflags=""
28 menuqc=menu
29 newest=NEWEST
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.5s
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                 [ -f nexuiz$P.dSYM ] && mv nexuiz$P.dSYM "$tmpdir/debuginfo/$prefix$P.dSYM"
98         done
99         case "$fteqccname" in
100                 *.exe)
101                         mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
102                         ;;
103                 *)
104                         mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
105                         ;;
106         esac
107         make clean
108 }
109
110 build()
111 {
112 #       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/dxheaders" WINDRES=/chroot/debian-etch/usr/bin/i586-mingw32msvc-windres SDL_CONFIG=$HOME/sdl-win32/SDL-1.2.13/bin/sdl-config' /chroot/debian-etch/usr/bin/i586-mingw32msvc-strip
113         buildon nex686build                           nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="$HOME/mingw32/bin/i386-mingw32-gcc -g -DSUPPORTDIRECTX -I$HOME/dxheaders" WINDRES="$HOME/mingw32/bin/i386-mingw32-windres" SDL_CONFIG="$HOME/sdl-win32/SDL-1.2.13/bin/sdl-config"' '"$HOME/mingw32/bin/i386-mingw32-strip"'
114         buildon nex686build                           nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=$HOME/modplug-i386/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/jpeg7/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/jpeg7/include"' strip
115 #       buildon eos.thruhere.net                      nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -g" DP_MODPLUG_STATIC_LIBDIR=$HOME/modplug-i386/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/jpeg7/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/jpeg7/include"' strip
116         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
117         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 DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/jpeg7/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/jpeg7/include"' strip
118                 mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
119                 mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
120 }
121
122 # avoid dupes
123 i=
124 while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
125         if [ -z "$i" ]; then
126                 i=a
127         else
128                 i=`echo "$i" | tr a-y b-z`
129         fi
130 done
131 ext=$i$ext
132
133 echo "Using build name nexuiz$date$ext"
134 sleep 3
135
136 # check for remains
137 conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
138 if [ -n "$conflicts" ]; then
139         echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
140         echo "NOT PROCEEDING"
141         echo
142         echo "$conflicts"
143         exit 1
144 fi
145
146 set -x
147
148 # prepare temp dir
149 rm -rf "$tmpdir"
150 mkdir -p "$tmpdir"
151
152 # clean up and patch DP
153 cd "$dpdir"
154 quilt pop -a || true
155 svn revert -R .
156 if [ -s patches/series ]; then
157         quilt push -a # apply all patches
158 fi
159
160 # prepare directory structure
161 cp -r "$osxapps"/*.app "$tmpdir"
162 mkdir "$tmpdir/debuginfo"
163 mkdir "$tmpdir/fteqcc"
164
165 # prepare fteqcc build
166 cd "$fteqccdir"
167 git checkout-index -a -f --prefix="$tmpdir/fteqcc/source/"
168 git log -1 > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
169 fteqccrev=`git show --pretty=%ct-%H | head -n 1`
170 echo "fteqcc rev $fteqccrev"
171
172 # build all executables
173 cd "$dpdir"
174 rm -rf nexuiz-* *.o
175 make clean
176 build
177 rm -rf nexuiz-* *.o
178 rm -rf fteqcc copystrip
179 make clean
180
181 # move shell scripts and license
182 cd "$tmpdir"
183 cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
184 cp "$nexdir/gpl.txt" "$tmpdir/"
185 cp "$nexdir/readme.html" "$tmpdir/"
186
187 # prepare data
188 cd "$nexdir/data"
189 svn export . "$tmpdir/data"
190 svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
191 svn log > "$tmpdir/data/ChangeLog"
192
193 # prepare havoc
194 cd "$havocdir"
195 svn export . "$tmpdir/havoc"
196
197 # prepare Docs
198 cd "$nexdir/Docs"
199 svn export . "$tmpdir/Docs"
200
201 # prepare server
202 cd "$nexdir/server"
203 svn export . "$tmpdir/server"
204
205 # make gamesource
206 cd "$tmpdir/data"
207 mkdir -p "$tmpdir/sources"
208 mk7z ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
209
210 # make enginesource
211 cd "$dpdir"
212 svn export . "$tmpdir/darkplaces"
213 svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
214 svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
215 svn log > "$tmpdir/darkplaces/ChangeLog"
216 cd "$tmpdir"
217 mk7z "$tmpdir/sources/enginesource$date.zip" "darkplaces"
218 rm -rf darkplaces
219
220 # make fteqcc archive
221 cd "$tmpdir"
222 zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
223 rm -rf fteqcc
224
225 # clean fteqcc dir
226 cd "$fteqccdir"
227 rm -f *.o *.bin
228 make
229
230 # make local compiler
231 cd "$tmpdir/data"
232 make FTEQCC="$fteqccdir/fteqcc.bin"
233
234 # prepare root
235 rm -rf "$tmpdir/data/qcsrc"
236 cd "$tmpdir/Docs"
237 cp "$dpdir/darkplaces.txt" .
238 cd "$tmpdir/data"
239 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' defaultNexuiz.cfg
240 if [ -z "$versiontag" ]; then
241         perl -pi -e 'm|^//!<showbrand| .. m|^//!>showbrand| and $_ = "";' defaultNexuiz.cfg
242         rm -f gfx/brand.tga
243 fi
244 echo >> defaultNexuiz.cfg
245 echo "$defaultcfg" >> defaultNexuiz.cfg
246
247 cd "$nexdir/misc/mediasource/menuskins/wickedz/background_builder"
248 sh append.sh "`echo "$version" | sed 's/svn/s/g'`" "$tmpdir/data/gfx/menu/wickedz/"
249 cd "$tmpdir/data"
250
251 pk3dirpk3s=
252 for X in *.pk3dir; do
253         Y=${X%.pk3dir}.pk3
254         cd "$X"
255                 mk7z ../../"$Y" .
256         cd ..
257         rm -rf "$X"
258         pk3dirpk3s="$pk3dirpk3s Nexuiz/data/$Y"
259 done
260 mv common-spog.pk3 ..
261 mk7z ../data.pk3 .
262
263 cd "$tmpdir/havoc"
264 mk7z ../havoc.pk3 .
265
266 # make data pk3
267 cd "$tmpdir"
268 rm -rf data
269 mkdir data
270 mv data.pk3 data/data$tag$date.pk3
271 rm -rf havoc
272 mkdir havoc
273 mv havoc.pk3 havoc/data$tag${date}havoc.pk3
274 mv *.pk3 data/
275
276 cp -r "$mingwdlls"/* .
277 # fix up permissions
278 chmod 644 *.dll *.exe
279
280 mkdir extra
281 cd extra
282 wget http://www.icculus.org/netradiant/files/netradiant-${netradiant_release}-win32.zip
283 #echo "Downloading netradiant, press enter and type the PWs"
284 #read -r DUMMY
285 #scp divverent@icculus.org:netradiant-webspace/files/netradiant-${netradiant_release}-win32.zip .
286 unzip netradiant-${netradiant_release}-win32.zip
287 mv NetRadiant netradiant-${netradiant_release}-win32
288 rm -f netradiant-${netradiant_release}-win32.zip
289 wget http://www.icculus.org/netradiant/files/netradiant-${netradiant_release}-osxintel.zip
290 #scp divverent@icculus.org:netradiant-webspace/files/netradiant-${netradiant_release}-osxintel.zip .
291 unzip netradiant-${netradiant_release}-osxintel.zip
292 mv NetRadiant.app NetRadiant-${netradiant_release}-osxintel.app
293 rm -f netradiant-${netradiant_release}-osxintel.zip
294 cat >> unsupported.txt <<EOF
295 This directory contains NetRadiant, a stabilized Q3 map editor,
296 configured for Nexuiz.
297
298 It is not officially supported by Alientrap.
299
300 Website: http://www.icculus.org/netradiant/
301 EOF
302 cd ..
303
304 # make main structure
305 mkdir Nexuiz
306 mv * Nexuiz/ || true
307
308 find . -name .svn -exec rm -rf {} \; -prune
309 find . -name .git -exec rm -rf {} \; -prune
310
311 rm -f "$zipdir/nexuiz$date$ext.zip"
312 zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/readme.html Nexuiz/server Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 $pk3dirpk3s Nexuiz/havoc/* Nexuiz/extra/*
313 ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
314
315 rm -f "$zipdir/nexuizengineonly$date$ext.zip"
316 zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
317 ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
318
319 rm -f "$zipdir/nexuizsource$date$ext.zip"
320 zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
321 ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
322
323 # TODO remove these excludes after the version after 2.4.2
324 $zipdiff -o "Nexuiz/data/data$tag$date""patch.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3
325 [ -n "$hotbasepk3" ] && $zipdiff -o "Nexuiz/data/data$tag$date""hotfix.pk3" $pk3dirpk3s -f "$hotbasepk3" -t Nexuiz/data/data$tag$date.pk3
326 mkdir -p gfx
327 if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
328         zip -9r "Nexuiz/data/data$tag$date""patch.pk3" gfx/brand.tga
329         [ -n "$hotbasepk3" ] && zip -9r "Nexuiz/data/data$tag$date""hotfix.pk3" gfx/brand.tga
330         rm -rf gfx
331 fi
332
333 rm -f "$zipdir/nexuizpatch$date$ext.zip"
334 zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/readme.html Nexuiz/server Nexuiz/data/data$tag$date""patch.pk3 $pk3dirpk3s Nexuiz/havoc/*
335 ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
336
337 [ -n "$hotbasepk3" ] && rm -f "$zipdir/nexuizhotfix$date$ext.zip"
338 [ -n "$hotbasepk3" ] && zip $zipflags -9yr "$zipdir/nexuizhotfix$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/readme.html Nexuiz/server Nexuiz/data/data$tag$date""hotfix.pk3 $pk3dirpk3s Nexuiz/havoc/*
339 [ -n "$hotbasepk3" ] && ln -snf nexuizhotfix$date$ext.zip "$zipdir/nexuizhotfix-$newest.zip"
340
341 rm -f "$zipdir/nexuizdocs$date$ext.zip"
342 zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs Nexuiz/readme.html
343 ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
344
345 rm -f "$zipdir/nexuizdebug$date$ext.zip"
346 zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
347 ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"
348
349 case "$versiontag" in
350         test)
351                 # these builds are public
352                 ssh atoffload "sh clean-builds.sh"
353                 rsync -vaSHP "$zipdir/nexuiz"*"$date$ext.zip" "$zipdir/nexuiz"*"-$newest.zip" atoffload:offload.alientrap.org/nexuiz/builds/
354                 ;;
355         *)
356                 ssh atoffload "sh clean-builds.sh"
357                 rsync -vaSHP "$zipdir/nexuiz"*"$date$ext.zip" "$zipdir/nexuiz"*"-$newest.zip" atoffload:offload.alientrap.org/nexuiz/builds.versioned/
358                 cat <<'EOF'
359
360 NOTE: This is a RELEASE BUILD.
361
362 To upload and finish the build, these things have to be done:
363
364 - Test the build:
365   - On Linux/ATI
366   - On Vista/nvidia
367   - On Vista/ATI
368   - On Vista/Intel
369   - On OSX/ATI
370   - Turn on "developer 1"; watch out for suspicious messages.
371   - While testing, make sure all campaign levels are tested. In CTF/KH levels,
372     try to do a capture. After that, finish the game by prvm_edictset server 1
373     frags 1000.
374   - Play on a server running the new code. Ideally, that server should be public
375     and "somewhat compatible" to old clients, and some other players should be
376     on it.
377 - Post the build on the forum as a test release. E.g. run this script again
378   with the "version" variable NOT SET, so the build gets marked "testing only",
379   and upload it and post it on the forum for testing. Mention the test server
380   that is already running the new code. Wait for at least one week for critical
381   bug reports.
382 - If needed, fix the reported bugs and re-run this script for a release build.
383   Possibly repeat the testing process.
384 - Upload the "final" build you have just made to Sourceforge (upload.sf.net,
385   incoming). Use the naming scheme nexuiz-25.zip, nexuizpatch-24-to-25.zip
386 - Make the download available on sourceforge.
387 - Announce the build on the forum; update the downloads website. Note that the
388   download may be still unavailable because of the SF mirror system.
389 - Wait for the mirrors to catch up.
390 - Edit the website: make a new news item for the new release, change the logo
391   image in the top left for the new version (ask [-z-]).
392
393 EOF
394                 ;;
395 esac