]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/makebuild.sh
7za can't be a variable :(
[divverent/nexuiz.git] / misc / makebuild.sh
1 #!/bin/bash
2
3 set -e
4
5 base=`pwd`
6
7
8 case "$pw" in
9         '')
10                 zipflags=
11                 ;;
12         *)
13                 zipflags="-P $pw"
14                 ;;
15 esac
16
17 : ${date:=`date +%Y%m%d`}
18 : ${versiontag:=}
19 echo "date stamp: $date"
20
21 case "$version" in
22         '')
23                 version=2-svntest-$date
24                 versiontag=test
25                 defaultcfg=
26                 ext=
27                 ;;
28         *)
29                 version=$version
30                 versiontag=$versiontag
31                 defaultcfg=
32                 ext=_$version
33                 ;;
34 esac
35
36 basepk3=$base/data20070531.pk3
37 nexdir=$base/nexuiz
38 nexprodir=$base/nexuiz/pro
39 dpdir=$base/darkplaces
40 tmpdir=/tmp/NEX
41 zipdir=$base/builds
42 buildfiles=$base/nexuiz/misc/buildfiles
43 mingwdlls=$buildfiles/w32
44 osxapps=$buildfiles/osx
45 copystrip=$buildfiles/copystrip
46 zipdiff=$base/nexuiz/misc/zipdiff
47 fteqccdir="$base/fteqcc"
48 fteqccflags=""
49 menuqc=menu
50 newest=NEWEST
51 aft="perl -I/chroot/debian-etch/usr/share/aft /chroot/debian-etch/usr/bin/aft"
52 tag=
53
54 #if [ -n "$EXPERIMENTAL" ]; then
55 #       basepk3=$base/data20071231.pk3 # newer build to make smaller patches
56 #       nexdir=$base/nexuiz
57 #fi
58
59 # TODO normalize the builds
60 platforms='x86 amd64 osx'
61 buildon()
62 {
63         host=$1
64         prefix=$2
65         fteqccname=$3
66         path=$4
67         makeflags=$5
68         strip=$6
69
70         fteqcc_cflags=
71         case "$fteqccname" in
72                 *.exe)
73                         fteqcc_cflags=win
74                         ;;
75         esac
76
77         rm -f "$fteqccdir"/*.o
78         rm -f "$fteqccdir"/*.bin
79         rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . "$copystrip" "$fteqccdir" "$host:$path"
80         ssh "$host" ". ~/.profile && cd $path && COPYSTRIP_STRIP=$strip PATH=$path/copystrip:\$PATH make $makeflags clean nexuiz && cd ${fteqccdir##*/} && make $makeflags $fteqcc_cflags"
81         rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$host:$path/." .
82         for P in -dedicated -sdl -glx -wgl -agl -dedicated.exe -sdl.exe .exe; do
83                 [ -f nexuiz$P ] && mv nexuiz$P "$tmpdir/$prefix$P"
84                 [ -f nexuiz$P-withdebug ] && mv nexuiz$P-withdebug "$tmpdir/debuginfo/$prefix$P"
85         done
86         case "$fteqccname" in
87                 *.exe)
88                         mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
89                         ;;
90                 *)
91                         mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
92                         ;;
93         esac
94         make clean
95 }
96
97 build()
98 {
99         buildon alientrap.org                         nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="/chroot/debian-etch/usr/bin/i586-mingw32msvc-gcc -g" 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
100         buildon alientrap.org                         nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -m32 -L/chroot/debian-etch/usr/include -L/chroot/debian-etch/lib -L/chroot/debian-etch/usr/lib -g -Wl,-rpath,/chroot/debian-etch/usr/lib" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-i386/lib SDL_CONFIG=/home/divverent/sdl-config-debian32' strip
101         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
102         buildon div0@nexmacbuild.endoftheinternet.org nexuiz-osx          fteqcc-osx          /tmp/Darkplaces.build 'CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -I/Library/Frameworks/SDL.framework/Headers"' strip
103                 mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
104                 mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
105 }
106
107 i=
108 while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
109         if [ -z "$i" ]; then
110                 i=a
111         else
112                 i=`echo "$i" | tr a-y b-z`
113         fi
114 done
115 ext=$i$ext
116
117 echo "Using build name nexuiz$date$ext"
118 sleep 3
119
120 if [ -n "$1" ]; then
121         osxhost="$1"
122 fi
123
124 conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
125 if [ -n "$conflicts" ]; then
126         echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
127         echo "NOT PROCEEDING"
128         echo
129         echo "$conflicts"
130         exit 1
131 fi
132
133 set -x
134
135 rm -rf "$tmpdir"
136 mkdir -p "$tmpdir"
137
138 cd "$dpdir"
139 quilt pop -a || true
140 svn revert -R .
141 quilt push -a # apply all patches
142
143 cp -r "$osxapps"/*.app "$tmpdir"
144 mkdir "$tmpdir/debuginfo"
145 mkdir "$tmpdir/fteqcc"
146
147 svn export "$fteqccdir" "$tmpdir/fteqcc/source"
148 svn info "$fteqccdir" > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
149 fteqccrev=$((`grep "Last Changed Rev:" "$tmpdir/fteqcc/source/fteqcc-base-revision.txt" | cut -d : -f 2`))
150 echo "fteqcc rev $fteqccrev"
151
152 rm -f *.exe nexuiz-* *-withdebug* *.o
153 make clean
154 build
155 rm -f *.exe nexuiz-* *-withdebug '.#'* *.o
156 rm -rf fteqcc copystrip
157 make clean
158
159 cd "$tmpdir"
160 cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
161 cp "$nexdir/gpl.txt" "$tmpdir/"
162
163 cd "$nexdir/data"
164 svn export . "$tmpdir/data"
165 svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
166 svn log > "$tmpdir/data/ChangeLog"
167
168 cd "$nexprodir"
169 svn export . "$tmpdir/pro"
170
171 cd "$nexdir/Docs"
172 svn export . "$tmpdir/Docs"
173
174 cd "$tmpdir/data"
175 mkdir -p "$tmpdir/sources"
176 #zip -9r ../sources/gamesource$date.zip qcsrc
177 7za a -mx=9 -tzip ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
178
179 cd "$dpdir"
180 svn export . "$tmpdir/darkplaces"
181 svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
182 svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
183 svn log > "$tmpdir/darkplaces/ChangeLog"
184
185 cd "$tmpdir"
186 7za a -mx=9 -tzip "$tmpdir/sources/enginesource$date.zip" "darkplaces"
187 rm -rf darkplaces
188
189 cd "$tmpdir"
190 zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
191 rm -rf fteqcc
192
193 cd "$fteqccdir"
194 rm -f *.o *.bin
195 make
196
197 cd "$tmpdir/data/qcsrc/$menuqc"
198 "$fteqccdir/fteqcc.bin" $fteqccflags
199
200 cd "$tmpdir/data/qcsrc/server"
201 "$fteqccdir/fteqcc.bin" $fteqccflags
202
203 rm -rf "$tmpdir/data/qcsrc"
204
205 cd "$tmpdir/Docs"
206 perl -pi -e '/^#---SET nexversion=([0-9.]*)$/ and $_ = "#---SET nexversion='$version'\n"' FAQ.aft
207 perl -pi -e '/^\s*Version ([0-9.]*)<\/div>$/ and $_ = "Version '$version'</div>\n"' Readme.htm
208 cp "$dpdir/darkplaces.txt" .
209 $aft FAQ.aft
210 $aft FAQ.aft
211 rm FAQ.aft-TOC
212
213 cd "$tmpdir/data"
214 mv common-spog.pk3 ..
215 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' default.cfg
216 if [ -n "$versiontag" ]; then
217         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
218         cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
219 fi
220 echo >> default.cfg
221 echo "$defaultcfg" >> default.cfg
222 7za a -mx=7 -tzip ../data.pk3 .
223
224 cd "$tmpdir/pro"
225 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version-pro'\n"' default.cfg
226 if [ -n "$versiontag" ]; then
227         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
228 fi
229 echo >> default.cfg
230 echo "$defaultcfg" >> default.cfg
231 7za a -mx=7 -tzip ../pro.pk3 .
232
233 cd "$tmpdir"
234 rm -rf data
235 mkdir data
236 mv data.pk3 data/data$tag$date.pk3
237 mv common-spog.pk3 data/
238 rm -rf pro
239 mkdir pro
240 mv pro.pk3 pro/data$tag${date}pro.pk3
241
242 cp -r "$mingwdlls"/* .
243 # fix up permissions
244 chmod 644 *.dll *.exe
245
246 mkdir Nexuiz
247 mv * Nexuiz/ || true
248
249 find . -name .svn -exec rm -rf {} \; -prune
250
251 rm -f "$zipdir/nexuiz$date$ext.zip"
252 zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 Nexuiz/pro/*
253 ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
254
255 rm -f "$zipdir/nexuizengineonly$date$ext.zip"
256 zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
257 ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
258
259 rm -f "$zipdir/nexuizsource$date$ext.zip"
260 zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
261 ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
262
263 $zipdiff -o "Nexuiz/data/datapatch$tag$date.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3 -x 'sound/cdtracks/track*.ogg'
264 mkdir -p gfx
265 if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
266         zip $zipflags -9r "Nexuiz/data/datapatch$tag$date.pk3" gfx/brand.tga
267         rm -rf gfx
268 fi
269
270 rm -f "$zipdir/nexuizpatch$date$ext.zip"
271 zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/datapatch$tag$date.pk3 Nexuiz/pro/*
272 ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
273
274 rm -f "$zipdir/nexuizdocs$date$ext.zip"
275 zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs
276 ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
277
278 rm -f "$zipdir/nexuizdebug$date$ext.zip"
279 zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
280 ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"