]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/all/release.subr
Fix Windows autobuild
[xonotic/xonotic.git] / misc / tools / all / release.subr
1 release_common()
2 {
3         export LC_ALL=C
4
5         if [ -z "$MAKEFLAGS" ]; then
6                 ncpus=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`
7                 if [ $ncpus -gt 1 ]; then
8                         export MAKEFLAGS=-j$ncpus
9                 fi
10         fi
11
12         release_args="$cmd $*"
13         msg "*** $release_args: start"
14         release_starttime=`date +%s`
15         release_end()
16         {
17                 release_endtime=`date +%s`
18                 release_deltatime=$(($release_endtime - $release_starttime))
19                 msg "*** $release_args: $release_deltatime seconds"
20         }
21         trap release_end EXIT
22         release_tempstarttime=$release_starttime
23         release_timereport()
24         {
25                 release_endtime=`date +%s` # RELEASE NOW!!!
26                 if [ -n "$*" ]; then
27                         release_deltatime=$(($release_endtime - $release_tempstarttime))
28                         msg "**** $release_args: $*: $release_deltatime seconds"
29                 fi
30                 release_tempstarttime=$release_endtime
31         }
32         release_git_extract_dir()
33         {
34                 release_src=$1; shift
35                 release_dst=$1; shift
36                 # try to create a hardlink
37                 if ln -f "$release_src/.git/HEAD" "$release_dst/.hardlink-test"; then
38                         rm -f "$release_dst/.hardlink-test"
39                         git -C "$release_src" ls-files HEAD -- "$@" |
40                                 while IFS= read -r F; do
41                                         case "$F" in */*) mkdir -p "$release_dst/${F%/*}" ;; esac
42                                         verbose ln -f "$release_src/$F" "$release_dst/$F"
43                                 done
44                         git -C "$release_src" ls-tree -rd --name-only HEAD -- "$@" |
45                                 while IFS= read -r D; do
46                                         touch -cr "$release_src/$D" "$release_dst/$D"
47                                 done
48                 else
49                         {
50                                 verbose cd "$release_src"
51                                 verbose git archive --format=tar HEAD -- "$@"
52                         } | {
53                                 verbose cd "$release_dst"
54                                 verbose tar xvf -
55                         }
56                 fi
57         }
58
59         mkzipr()
60         {
61                 archive=$1; shift
62
63                 # bones_was_here: 7za still doesn't store symlinks correctly (even with -snl)
64                 # but it does now store the executable bit.
65                 # compared to advzip, 7za achieves very similar final zip size, is multi threaded,
66                 # and avoids https://gitlab.com/xonotic/xonotic/-/issues/371
67
68                 sevenzipflags=-mx=9
69                 zipflags=-9
70                 # git restore-mtime replaces this hack:
71                 #find "$@" -exec touch -d "2001-01-01 01:01:01 +0000" {} \+ # ugly hack to make the pk3 files rsync-friendly
72                 ziplist=`mktemp`
73                 find "$@" -xtype f \( -type l \) -print | sed 's,\([./][^./]*$\),\1 \1,' | sort -k2 | cut -d\  -f1 > "$ziplist"
74                 7za a -tzip $sevenzipflags -x@"$ziplist" "$archive" "$@" || true
75                 zip         $zipflags -y   -@<"$ziplist" "$archive"      || true
76                 rm -f "$ziplist"
77         }
78
79         mkzip()
80         {
81                 # not using this currently, see above
82                 archive=$1; shift
83                 zipflags=-1ry
84                 zip $zipflags "$archive" "$@" || true
85                 advzip -z -4 "$archive"
86         }
87
88         mkzip0()
89         {
90                 archive=$1; shift
91                 zipflags=-0ry
92                 zip $zipflags "$archive" "$@" || true
93         }
94
95         getversion()
96         {
97                 gv=`grep "^gameversion " "$1/xonotic-common.cfg" | awk '{ print $2 }'`
98                 major=$(($gv / 10000))
99                 minor=$((($gv / 100) - ($major * 100)))
100                 patch=$(($gv - ($major * 10000) - ($minor * 100)))
101                 versionstr="$major.$minor.$patch"
102         }
103 }
104
105 handled=true
106 case "$cmd" in
107         # release building goes here
108         release-prepare)
109                 release_common
110                 #"$SELF" each git clean -fxd
111                 case "$RELEASETYPE" in
112                         '')
113                                 $ECHO >&2 -n "$ESC[2J$ESC[H"
114                                 msg ""
115                                 msg ""
116                                 msg ""
117                                 msg ""
118                                 msg ""
119                                 msg ""
120                                 msg "        +---------------------------------------------------------.---+"
121                                 msg "        | NOTE                                                    | X |"
122                                 msg "        +---------------------------------------------------------^---+"
123                                 msg "        |   ____                                                      |"
124                                 msg "        |  /    \  This is the official release build system.         |"
125                                 msg "        | |      | If you are not a member of the Xonotic Core Team,  |"
126                                 msg "        | | STOP | you are not supposed to use this script and should |"
127                                 msg "        | |      | instead use ./all compile to compile the engine    |"
128                                 msg "        |  \____/  and game code.                                     |"
129                                 msg "        |                                                             |"
130                                 msg "        |                      [ I understand ]                       |"
131                                 msg "        +-------------------------------------------------------------+"
132                                 sleep 10
133                                 # A LOT of build infrastructure is required:
134                                 # - vorbis-tools
135                                 # - ImageMagick
136                                 # - .ssh/config must be configured so the following
137                                 #   host names are reachable and have a compile
138                                 #   infrastructure set up:
139                                 #   - xonotic-build-linux64 (with gcc on x86_64)
140                                 #   - xonotic-build-win32 (with i686-w64-mingw32)
141                                 #   - xonotic-build-win64 (with x86_64-w64-mingw32)
142                                 #   - xonotic-build-osx (with Xcode and SDL.framework)
143                                 # - AMD Compressonator installed in WINE
144                                 # - ResEdit installed in WINE
145                                 # - a lot of other requirements you will figure out
146                                 #   while reading the error messages
147                                 # - environment variable RELEASETYPE set
148                                 # - optionally, environment variable RELEASEDATE set
149                                 #   (YYYYMMDD)
150                                 exit 1
151                                 ;;
152                         release|RC*)
153                                 msg "Building a FINISHED RELEASE"
154                                 getversion data/xonotic-data.pk3dir
155                                 verbose "$SELF" each -k git tag -m "TEMP TAG" -f "xonotic-v$versionstr"
156                                 ;;
157                         *)
158                                 msg "Building a $RELEASETYPE"
159                                 ;;
160                 esac
161                 verbose rm -rf Xonotic Xonotic*.zip
162                 verbose mkdir -p Xonotic
163                 if [ -n "$RELEASEDATE" ]; then
164                         verbose $ECHO "$RELEASEDATE" > Xonotic/stamp.txt
165                         case "$RELEASETYPE" in
166                                 release|RC*)
167                                         verbose $ECHO "${RELEASEDATE%_*}" > Xonotic/pk3stamp.txt
168                                         ;;
169                                 *)
170                                         verbose $ECHO "$RELEASEDATE" > Xonotic/pk3stamp.txt
171                                         ;;
172                         esac
173                 else
174                         verbose date +%Y%m%d > Xonotic/stamp.txt
175                         verbose date +%Y%m%d > Xonotic/pk3stamp.txt
176                 fi
177                 release_git_extract_dir "." "Xonotic" Docs misc/buildfiles/osx misc/logos misc/tools server xonotic-linux-sdl.sh xonotic-linux-dedicated.sh Makefile key_0.d0pk COPYING GPL-2 GPL-3
178                 (
179                         verbose cd Xonotic
180                         verbose mkdir data source source/darkplaces source/gmqcc source/d0_blind_id mapping
181                         verbose mv misc/buildfiles/osx/* . || true
182                         verbose rm -rf misc/buildfiles
183                         verbose rm -rf misc/tools/all
184                 )
185                 release_git_extract_dir "darkplaces" "Xonotic/source/darkplaces" .
186                 release_git_extract_dir "gmqcc" "Xonotic/source/gmqcc" .
187                 release_git_extract_dir "data/xonotic-data.pk3dir" "Xonotic/source" qcsrc Makefile
188                 release_git_extract_dir "d0_blind_id" "Xonotic/source/d0_blind_id" .
189 # bones_was_here: the main Makefile runs autogen.sh (and configure) when necessary
190 #               (
191 #                       verbose cd Xonotic/source/d0_blind_id
192 #                       verbose sh autogen.sh
193 #               )
194                 rm -f Xonotic/key_15.d0pk
195                 (
196                         verbose cd Xonotic/mapping
197                         # bones_was_here: don't ship 10 year old netradiant
198                         # also seems better to update netradiant independently of xonotic versions
199                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301.tar.bz2
200                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301-win32-7z.exe
201                         #for X in *-7z.exe; do
202                         #       7za x "$X"
203                         #       rm -f "$X"
204                         #done
205                         # TODO possibly include other tools?
206                         printf "Please find links to NetRadiant builds at https://netradiant.gitlab.io or https://xonotic.org/download\nNetRadiant source available at https://gitlab.com/xonotic/netradiant\n" > NetRadiant\ links.txt
207                 )
208                 ./all each git rev-parse HEAD > Xonotic/misc/git-revisions.txt
209                 ;;
210         release-compile-run)
211                 release_common
212                 host=$1
213                 buildpath=$2
214                 maketargets=$3
215                 makeflags=$4
216                 srcdir=$5
217                 depsdir=$6
218                 targetfiles=$7
219                 schroot=
220                 set -x
221                 if [ -z "$targetfiles" ]; then
222                         exit
223                 fi
224                 case " $HOSTS_THAT_ARE_DISABLED " in
225                         *\ $host\ *)
226                                 exit
227                                 ;;
228                 esac
229                 case " $HOSTS_THAT_ARE_SCHROOT " in
230                         *\ $host\ *)
231                                 schroot="schroot -c $host --"
232                                 ;;
233                 esac
234                 case " $HOSTS_THAT_ARE_MYSELF $HOSTS_THAT_ARE_SCHROOT " in
235                         *\ $host\ *)
236                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$buildpath/"
237                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$buildpath"/darkplaces.ico
238                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$buildpath.deps/"
239                                 verbose ln -snf "$buildpath.deps" "$buildpath/.deps"
240                                 verbose eval $schroot make -C "$buildpath" clean $maketargets $makeflags
241                                 for f in $targetfiles; do
242                                         verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
243                                 done
244                                 ;;
245                         *)
246                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$host":"$buildpath/"
247                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$host":"$buildpath"/darkplaces.ico
248                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$host":"$buildpath.deps/"
249                                 verbose ssh "$host" "[ -f /etc/profile ] && . /etc/profile; [ -f ~/.profile ] && . ~/.profile; export LC_ALL=C; ln -snf $buildpath.deps $buildpath/.deps && cd $buildpath && nice -`nice` make clean $maketargets $makeflags"
250                                 for f in $targetfiles; do
251                                         verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
252                                 done
253                                 ;;
254                 esac
255                 ;;
256         release-compile)
257                 release_common
258                 suffix=$1
259                 makeflags=$2
260                 darkplaces_maketargets=$3
261                 darkplaces_files=$4
262                 host=xonotic-build-$suffix
263                 verbose "$SELF" release-compile-run "$host" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$d0/misc/builddeps/$suffix" "$darkplaces_files"
264                 ;;
265         release-getbinary)
266                 release_common
267                 binary=$1
268                 basename=${binary##*/}
269                 dpname=darkplaces${basename#xonotic}
270                 rev=`( cd "$d0/darkplaces" && git rev-parse HEAD )`
271                 verbose wget -O "$binary" "http://beta.xonotic.org/autobuild-bin/$rev/$dpname"
272                 [ -s "$binary" ] || rm -f "$binary"
273                 [ -f "$binary" ]
274                 case "$binary" in
275                         Xonotic/*osx*|Xonotic/*linux*)
276                                 chmod +x "$binary"
277                                 ;;
278                 esac
279                 ;;
280         release-libs-compile)
281                 release_common
282                 arch=$1
283                 makeflags=$2
284                 host=$3
285                 (
286                         verbose cd "$d0/d0_blind_id"
287                         verbose ./autogen.sh
288                         verbose ./configure --enable-static --disable-shared \
289                                             --host="$host" \
290                                             --prefix="$d0/misc/builddeps/$arch/d0_blind_id"
291                         verbose make clean
292                         verbose eval make "$makeflags"
293                         verbose make install
294                 )
295                 ;;
296         release-libs-linux64)
297                 release_common
298                 # TODO schroot support for libs so we can LTO this
299                 verbose "$SELF" release-libs-compile linux64 \
300                         'CC="gcc -m64"' \
301                         x86_64-pc-linux-gnu
302                 ;;
303         release-dlls-compile)
304                 release_common
305                 arch=$1
306                 buildpath=$2
307                 targetdir=$3
308                 verbose mkdir -p "$targetdir"
309                 (
310                         cd "misc/buildsrc"
311                         verbose ./dlls.sh clean "$buildpath"
312                         verbose ./dlls.sh all "$buildpath" "$arch"
313                 )
314                 verbose cp -v $buildpath/out/$arch/* "$targetdir"
315                 verbose mkdir -p "$d0/misc/builddeps/$arch/"
316                 verbose rsync --delete -avP "$buildpath/pkg/$arch/sdl" "$d0/misc/builddeps/$arch/"
317                 # PKG_CONFIG HACK: avoids needing to modify sdl2-config
318                 verbose printf '#!/bin/sh\nprintf ../../../.deps/lib\n' > "$d0/misc/builddeps/$arch/sdl/libdir_hack.sh"
319                 verbose chmod +x "$d0/misc/builddeps/$arch/sdl/libdir_hack.sh"
320                 ;;
321         release-dlls-win32)
322                 release_common
323                 verbose "$SELF" release-dlls-compile win32 /tmp/dlls Xonotic/bin32
324                 ;;
325         release-dlls-win64)
326                 release_common
327                 verbose "$SELF" release-dlls-compile win64 /tmp/dlls Xonotic/bin64
328                 ;;
329         release-libs-osx)
330                 release_common
331                 verbose mkdir -p "$d0/misc/builddeps/osx"
332                 (
333                         verbose cd "$d0/misc/builddeps/osx"
334                         verbose rm -rf sdl SDL2
335                         verbose wget https://libsdl.org/release/SDL2-2.28.5.dmg
336                         verbose 7z x *.dmg
337                         # 7z still fails to extract working symlinks from any archive format, hackaround:
338                         verbose ln -sf $(cat SDL2/SDL2.framework/Versions/Current) SDL2/SDL2.framework/Versions/Current
339                         verbose ln -sf $(cat SDL2/SDL2.framework/Headers) SDL2/SDL2.framework/Headers
340                         verbose ln -sf $(cat SDL2/SDL2.framework/Resources) SDL2/SDL2.framework/Resources
341                         verbose ln -sf $(cat SDL2/SDL2.framework/SDL2) SDL2/SDL2.framework/SDL2
342                         # THE HEADERS ARE NOT IN A SUBDIRECTORY CALLED SDL2
343                         # YET SDL2/ WAS ADDED TO ALL THE INCLUDES, WHY?!?
344                         # OLD VERSIONS WITHOUT IT WORKED
345                         verbose sed -i "s/#include <SDL2\//#include </g" SDL2/SDL2.framework/Versions/Current/Headers/*.h
346                 )
347                 ;;
348         release-libs)
349                 release_common
350                 verbose "$SELF" release-libs-linux64
351                 verbose "$SELF" release-dlls-win32
352                 verbose "$SELF" release-dlls-win64
353                 verbose "$SELF" release-libs-osx
354                 verbose rm -rf /tmp/dlls
355                 ;;
356         release-engine-win32)
357                 release_common
358                 #good=true
359                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86.exe || good=false
360                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86-dedicated.exe || good=false
361                 #$good
362                 verbose "$SELF" release-compile win32 \
363                         'DP_MAKE_TARGET=mingw WIN32RELEASE=1 CC="i686-w64-mingw32-gcc -static -flto=auto -mstackrealign -Wl,--dynamicbase -Wl,--nxcompat -I../../../.deps/include -L../../../.deps/lib" WINDRES="i686-w64-mingw32-windres" DP_LINK_SDL=static PKG_CONFIG="../../../.deps/libdir_hack.sh" SDL_CONFIG="../../../.deps/bin/sdl2-config" DP_LINK_CRYPTO=dlopen DP_LINK_CRYPTO_RIJNDAEL=dlopen DP_LINK_JPEG=dlopen DP_LINK_ODE=dlopen DP_LINK_ZLIB=dlopen' \
364                         release 'darkplaces-sdl.exe:Xonotic/xonotic-x86.exe darkplaces-dedicated.exe:Xonotic/xonotic-x86-dedicated.exe'
365                 ;;
366         release-engine-win64)
367                 release_common
368                 #good=true
369                 #verbose "$SELF" release-getbinary Xonotic/xonotic.exe || good=false
370                 #verbose "$SELF" release-getbinary Xonotic/xonotic-dedicated.exe || good=false
371                 #$good
372                 # PKG_CONFIG HACK: avoids needing to modify sdl2-config
373                 verbose "$SELF" release-compile win64 \
374                         'DP_MAKE_TARGET=mingw WIN64RELEASE=1 CC="x86_64-w64-mingw32-gcc -static -flto=auto -Wl,--dynamicbase -Wl,--nxcompat -I../../../.deps/include -L../../../.deps/lib" WINDRES="x86_64-w64-mingw32-windres" DP_LINK_SDL=static PKG_CONFIG="../../../.deps/libdir_hack.sh" SDL_CONFIG="../../../.deps/bin/sdl2-config" DP_LINK_CRYPTO=dlopen DP_LINK_CRYPTO_RIJNDAEL=dlopen DP_LINK_JPEG=dlopen DP_LINK_ODE=dlopen DP_LINK_ZLIB=dlopen' \
375                         release 'darkplaces-sdl.exe:Xonotic/xonotic.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
376                 ;;
377         release-engine-osx)
378                 release_common
379                 #good=true
380                 #verbose "$SELF" release-getbinary Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin || good=false
381                 #verbose "$SELF" release-getbinary Xonotic/xonotic-osx-dedicated || good=false
382                 #$good
383                 # Note: travis build script also had SDLCONFIG_MACOSX* flags; need to check if they're still needed with osxcross.
384                 # Note: Mac bins cannot be stripped by the standard tool.
385                 verbose "$SELF" release-compile osx \
386                         'STRIP=: DP_MAKE_TARGET=macosx PATH="$HOME/osxcross/out/bin:$PATH" CC="$HOME/osxcross/out/bin/o64-clang -flto -arch x86_64 -mmacosx-version-min=10.7 -Wl,-rpath -Wl,@loader_path/../Frameworks -Wl,-rpath -Wl,@loader_path -I../../../.deps/include -L../../../.deps/lib" SDLCONFIG_MACOSXCFLAGS="-I../../../.deps/SDL2.framework/Headers" SDLCONFIG_MACOSXLIBS="-F../../../.deps -framework SDL2 -framework Cocoa -I../../../.deps/SDL2.framework/Headers" SDLCONFIG_MACOSXSTATICLIBS="-F../../../.deps -framework SDL2 -framework Cocoa -I../../../.deps/SDL2.framework/Headers" DP_LINK_CRYPTO=dlopen DP_LINK_CRYPTO_RIJNDAEL=dlopen DP_LINK_JPEG=dlopen DP_LINK_ODE=dlopen DP_LINK_ZLIB=shared' \
387                         release 'darkplaces-sdl:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
388                 ;;
389         release-engine-linux64)
390                 release_common
391                 #good=true
392                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-sdl || good=false
393                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-glx || good=false
394                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-dedicated || good=false
395                 #$good
396                 verbose "$SELF" release-compile linux64 \
397                         'CC="gcc -m64 -flto=auto -I../../../.deps/include -L../../../.deps/lib" DP_LINK_CRYPTO=static DP_LINK_CRYPTO_RIJNDAEL=static DP_LINK_JPEG=shared LIB_JPEG=/usr/lib/x86_64-linux-gnu/libjpeg.a DP_LINK_ODE=dlopen DP_LINK_ZLIB=shared' \
398                         release 'darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
399                 ;;
400         release-engine)
401                 release_common
402                 # TODO report failures here.
403                 good=false
404                 verbose "$SELF" release-engine-linux64 && good=true
405                 verbose "$SELF" release-engine-win32 && good=true
406                 verbose "$SELF" release-engine-win64 && good=true
407                 verbose "$SELF" release-engine-osx && good=true
408                 $good
409                 ;;
410         release-maps)
411                 release_common
412                 verbose "$SELF" update-maps
413                 ;;
414         release-qc)
415                 release_common
416                 verbose make -C "$d0/gmqcc" gmqcc
417                 verbose env GIT_DIR="$d0/data/xonotic-data.pk3dir/.git" make -C Xonotic/source QCC="$d0/gmqcc/gmqcc" XON_BUILDSYSTEM=1 QCCFLAGS_WATERMARK='$(shell git describe --tags)' clean qc
418                 ;;
419         release-buildpk3-transform-raw)
420                 release_common
421                 dir=$1
422                 ;;
423         release-buildpk3-transform-normal)
424                 release_common
425                 dir=$1
426                 verbose cd "$dir"
427                 # texture: convert to jpeg and dds
428                 verbose export do_jpeg=true
429                 verbose export jpeg_qual_rgb=97
430                 verbose export jpeg_qual_a=99
431                 verbose export do_dds=false
432                 verbose export do_ogg=true
433                 verbose export ogg_ogg=false
434                 verbose export del_src=true
435                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
436                 ;;
437         release-buildpk3-transform-normaldds)
438                 release_common
439                 dir=$1
440                 verbose cd "$dir"
441                 # texture: convert to jpeg and dds
442                 # music: reduce bitrate
443                 verbose export do_jpeg=false
444                 verbose export do_jpeg_if_not_dds=true
445                 verbose export jpeg_qual_rgb=95
446                 verbose export jpeg_qual_a=99
447                 verbose export do_dds=true
448                 verbose export dds_flags=
449                 verbose export do_ogg=true
450                 verbose export ogg_ogg=false
451                 verbose export del_src=true
452                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
453                 ;;
454         release-buildpk3-transform-mapping)
455                 release_common
456                 dir=$1
457                 verbose cd "$dir"
458                 # don't include levelshots, lightmaps and minimaps from official map builds, as well as other unneeded folders
459                 rm -rf gfx maps scripts sound
460                 # remove stuff radiant has no use for
461                 verbose find . -name \*_norm.\* -exec rm -f {} \;
462                 verbose find . -name \*_bump.\* -exec rm -f {} \;
463                 verbose find . -name \*_glow.\* -exec rm -f {} \;
464                 verbose find . -name \*_gloss.\* -exec rm -f {} \;
465                 verbose find . -name \*_pants.\* -exec rm -f {} \;
466                 verbose find . -name \*_shirt.\* -exec rm -f {} \;
467                 verbose find . -name \*_reflect.\* -exec rm -f {} \;
468                 verbose find . -not \( -name \*.tga -o -name \*.png -o -name \*.jpg \) -exec rm -f {} \;
469                 # texture: convert to jpeg and dds
470                 # music: reduce bitrate
471                 verbose export do_jpeg=true
472                 verbose export jpeg_qual_rgb=80
473                 verbose export jpeg_qual_a=97
474                 verbose export do_dds=false
475                 verbose export do_ogg=true
476                 verbose export ogg_qual=1
477                 verbose export del_src=true
478                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
479                 ;;
480         release-buildpk3)
481                 release_common
482                 src=$1
483                 dst=$2
484                 transform=$3
485                 case "$dst" in
486                         /*)
487                                 ;;
488                         */)
489                                 dst="$PWD/$dst"
490                                 ;;
491                 esac
492                 release_timereport
493                 verbose rm -rf Xonotic/temp
494                 release_timereport "deleted temp directory"
495                 verbose mkdir -p Xonotic/temp
496                 release_git_extract_dir "$src" "Xonotic/temp" .
497                 release_timereport "extracted data"
498                 verbose cd Xonotic/temp
499                 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
500                         verbose cp ../source/progs.dat .
501                         verbose cp ../source/csprogs.dat .
502                         verbose cp ../source/menu.dat .
503                         # Include line numbers in qc errors
504                         verbose cp ../source/progs.lno .
505                         verbose cp ../source/csprogs.lno .
506                         verbose cp ../source/menu.lno .
507                         verbose rm -rf qcsrc
508                         getversion .
509                         case "$RELEASETYPE" in
510                                 release)
511                                         ;;
512                                 RC*)
513                                         versionstr="$versionstr $RELEASETYPE"
514                                         ;;
515                                 *)
516                                         versionstr="$versionstr$RELEASETYPE"
517                                         ;;
518                         esac
519                         if [ $gv -lt 9900 ]; then
520                                 # pre-1.0: compatible with any other pre-1.0
521                                 verbose sed "
522                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion \"$versionstr\" /;
523                                         s/^gameversion_max [0-9]*/gameversion_max  9999/;
524                                 " < xonotic-common.cfg > xonotic-common.cfg.new
525                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
526                                 # s/^gameversion_min [0-9]*/gameversion_min     0/;
527                         else
528                                 # >= 1.0
529                                 verbose sed "
530                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion \"$versionstr\" /;
531                                         s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
532                                 " < xonotic-common.cfg > xonotic-common.cfg.new
533                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
534                                 # s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
535                         fi
536                         mv xonotic-common.cfg.new xonotic-common.cfg
537                         case "$RELEASETYPE" in
538                                 release|RC*)
539                                         echo "" >> xonotic-common.cfg
540                                         echo "// nicer menu" >> xonotic-common.cfg
541                                         echo "set menu_watermark \"\"" >> xonotic-common.cfg
542                                         ;;
543                         esac
544                         (
545                                 verbose cd gfx/menu/luminos
546                                 verbose rm -f background_l2.tga background_ingame_l2.tga
547                                 verbose cp "$d0"/mediasource/gfx/menu/luminos_versionbuilder/background_l2.svg .
548                                 verbose "$d0"/mediasource/gfx/menu/luminos_versionbuilder/versionbuilder "$versionstr"
549                                 verbose rm background_l2.svg
550                         )
551                         verbose "$d0"/mediasource/gfx/luma/render-version.sh "$d0/mediasource/gfx/luma" "$PWD" "$versionstr"
552                 fi
553                 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
554                         for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
555                                 if [ -f "$X" ]; then
556                                         verbose unzip "$X"
557                                         verbose rm -f maps/*.log maps/*.irc maps/*.lin
558                                 fi
559                         done
560                 fi
561                 verbose export git_src_repo="$d0/$src" # skip hash-object
562                 release_timereport "processed data"
563                 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
564                 release_timereport "transformed data"
565                 find . -type f -size +4k | verbose "$d0"/misc/tools/symlink-deduplicate.sh
566                 release_timereport "deduplicated data"
567                 verbose mkzipr "../../$dst" *
568                 release_timereport "zipped data"
569                 verbose cd ../..
570                 verbose rm -rf Xonotic/temp
571                 release_timereport "deleted temp directory again"
572                 ;;
573         release-buildpk3s)
574                 release_common
575                 pk3stamp=`cat Xonotic/pk3stamp.txt`
576                 src=$1
577                 shift
578                 dst=${src%.pk3dir}
579                 case "$dst" in
580                         data/xonotic-*)
581                                 dst="data/xonotic-$pk3stamp-${dst#data/xonotic-}"
582                                 ;;
583                         *)
584                                 dst="$dst-$pk3stamp"
585                                 ;;
586                 esac
587                 while [ "$#" -gt 1 ]; do
588                         verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
589                         shift
590                         shift
591                 done
592                 ;;
593         release-pack)
594                 release_common
595                 verbose "$SELF" release-buildpk3s data/font-unifont.pk3dir      raw ''
596                 verbose "$SELF" release-buildpk3s data/font-xolonium.pk3dir     raw ''
597                 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir             normaldds ''                    normal '-high'
598                 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir             normaldds '' mapping '-mapping' normal '-high'
599                 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir     raw ''
600                 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir        normaldds ''                    normal '-high'
601                 verbose "$SELF" release-buildpk3s data/xonotic-xoncompat.pk3dir        normaldds ''                    normal '-high'
602                 ;;
603         release-pack-needsx11)
604                 release_common
605                 case "$DISPLAY" in
606                         '')
607                                 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
608                                 ;;
609                         *)
610                                 verbose "$SELF" release-pack
611                                 ;;
612                 esac
613                 ;;
614         release-zip)
615                 release_common
616                 stamp=`cat Xonotic/stamp.txt`
617                 pk3stamp=`cat Xonotic/pk3stamp.txt`
618                 # exe and dll files do not need +x
619                 chmod a-x Xonotic/*.exe Xonotic/*.dll Xonotic/bin64/*.dll Xonotic/bin32/*.dll || true
620                 # build the archives
621                 verbose mkzipr Xonotic-$stamp-enginesource.zip \
622                         Xonotic/Makefile \
623                         Xonotic/source/darkplaces/ \
624                         Xonotic/COPYING Xonotic/GPL-2 Xonotic/GPL-3
625                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-engine.zip
626                 verbose mkzipr Xonotic-$stamp-engine.zip \
627                         Xonotic/*.dll \
628                         Xonotic/bin32/*.dll \
629                         Xonotic/bin64/*.dll \
630                         Xonotic/*.app \
631                         Xonotic/xonotic-* \
632                         Xonotic/xonotic.exe
633                 verbose cp Xonotic-$stamp-engine.zip Xonotic-$stamp-common.zip
634                 verbose mkzipr Xonotic-$stamp-common.zip \
635                         Xonotic/source/d0_blind_id/ \
636                         Xonotic/source/gmqcc/ \
637                         Xonotic/source/qcsrc/ \
638                         Xonotic/Docs \
639                         Xonotic/misc \
640                         Xonotic/gmqcc \
641                         Xonotic/server \
642                         Xonotic/key_0.d0pk \
643                         Xonotic/data/font-unifont-$pk3stamp.pk3 \
644                         Xonotic/data/font-xolonium-$pk3stamp.pk3
645                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-source.zip
646                 verbose mkzipr Xonotic-$stamp-source.zip \
647                         Xonotic/source/d0_blind_id/ \
648                         Xonotic/source/gmqcc/ \
649                         Xonotic/source/qcsrc/ \
650                         Xonotic/misc/logos
651                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
652                 verbose mkzip0 Xonotic-$stamp.zip \
653                         Xonotic/data/xonotic-$pk3stamp-data.pk3 \
654                         Xonotic/data/xonotic-$pk3stamp-maps.pk3 \
655                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
656                         Xonotic/data/xonotic-$pk3stamp-nexcompat.pk3 \
657                         Xonotic/data/xonotic-$pk3stamp-xoncompat.pk3
658                 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
659                 verbose mkzip0 Xonotic-$stamp-high.zip \
660                         Xonotic/data/xonotic-$pk3stamp-data-high.pk3 \
661                         Xonotic/data/xonotic-$pk3stamp-maps-high.pk3 \
662                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
663                         Xonotic/data/xonotic-$pk3stamp-nexcompat-high.pk3 \
664                         Xonotic/data/xonotic-$pk3stamp-xoncompat-high.pk3
665                 verbose mkzipr Xonotic-$stamp-mappingsupport.zip \
666                         Xonotic/mapping
667                 verbose mkzip0 Xonotic-$stamp-mappingsupport.zip \
668                         Xonotic/data/xonotic-$pk3stamp-maps-mapping.pk3
669                 verbose mkzipr gmqcc-$stamp.zip \
670                         Xonotic/gmqcc \
671                         Xonotic/source/gmqcc
672                 ;;
673         release)
674                 release_common
675                 verbose "$SELF" release-prepare
676                 verbose "$SELF" release-maps
677                 verbose "$SELF" release-libs
678                 verbose "$SELF" release-engine
679                 verbose "$SELF" release-qc
680                 verbose "$SELF" release-pack
681                 verbose "$SELF" release-zip
682                 ;;
683         *)
684                 handled=false
685                 ;;
686 esac