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