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