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