Fix typo causing empty directory error
[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                         {
40                                 verbose cd "$release_src"
41                                 git ls-files HEAD -- "$@"
42                         } | {
43                                 while IFS= read -r F; do
44                                         case "$F" in */*) mkdir -p "$release_dst/${F%/*}" ;; esac
45                                         verbose ln -f "$release_src/$F" "$release_dst/$F"
46                                 done
47                         }
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                 # get rid of this hack once we have done large enough changes
64                 # to be no longer rsync compatible (and then enable the below
65                 # code)
66                 sevenzipflags=-mx=9
67                 zipflags=-9
68                 find "$@" -exec touch -d "2001-01-01 01:01:01 +0000" {} \+ # ugly hack to make the pk3 files rsync-friendly
69                 ziplist=`mktemp`
70                 find "$@" -xtype f \( -executable -or -type l \) -print | sed 's,\([./][^./]*$\),\1 \1,' | sort -k2 | cut -d\  -f1 > "$ziplist"
71                 7za a -tzip $sevenzipflags -x@"$ziplist" "$archive" "$@" || true
72                 zip         $zipflags -y   -@<"$ziplist" "$archive"      || true
73                 rm -f "$ziplist"
74
75                 #zipflags=-1r
76                 #find "$@" -exec touch -d "2001-01-01 01:01:01 +0000" {} \+ # ugly hack to make the pk3 files rsync-friendly
77                 #zip $zipflags -y "$archive" "$@" || true
78                 #advzip -4 "$archive"
79         }
80
81         mkzip()
82         {
83                 archive=$1; shift
84                 zipflags=-1ry
85                 zip $zipflags "$archive" "$@" || true
86                 advzip -z -4 "$archive"
87         }
88
89         mkzip0()
90         {
91                 archive=$1; shift
92                 zipflags=-0ry
93                 zip $zipflags "$archive" "$@" || true
94         }
95
96         getversion()
97         {
98                 gv=`grep "^gameversion " "$1/xonotic-common.cfg" | awk '{ print $2 }'`
99                 major=$(($gv / 10000))
100                 minor=$((($gv / 100) - ($major * 100)))
101                 patch=$(($gv - ($major * 10000) - ($minor * 100)))
102                 versionstr="$major.$minor.$patch"
103         }
104 }
105
106 handled=true
107 case "$cmd" in
108         # release building goes here
109         release-prepare)
110                 release_common
111                 #"$SELF" each git clean -fxd
112                 case "$RELEASETYPE" in
113                         '')
114                                 $ECHO >&2 -n "$ESC[2J$ESC[H"
115                                 msg ""
116                                 msg ""
117                                 msg ""
118                                 msg ""
119                                 msg ""
120                                 msg ""
121                                 msg "        +---------------------------------------------------------.---+"
122                                 msg "        | NOTE                                                    | X |"
123                                 msg "        +---------------------------------------------------------^---+"
124                                 msg "        |   ____                                                      |"
125                                 msg "        |  /    \  This is the official release build system.         |"
126                                 msg "        | |      | If you are not a member of the Xonotic Core Team,  |"
127                                 msg "        | | STOP | you are not supposed to use this script and should |"
128                                 msg "        | |      | instead use ./all compile to compile the engine    |"
129                                 msg "        |  \____/  and game code.                                     |"
130                                 msg "        |                                                             |"
131                                 msg "        |                      [ I understand ]                       |"
132                                 msg "        +-------------------------------------------------------------+"
133                                 sleep 10
134                                 # A LOT of build infrastructure is required:
135                                 # - vorbis-tools
136                                 # - ImageMagick
137                                 # - .ssh/config must be configured so the following
138                                 #   host names are reachable and have a compile
139                                 #   infrastructure set up:
140                                 #   - xonotic-build-linux64 (with gcc on x86_64)
141                                 #   - xonotic-build-win32 (with i686-w64-mingw32)
142                                 #   - xonotic-build-win64 (with x86_64-w64-mingw32)
143                                 #   - xonotic-build-osx (with Xcode and SDL.framework)
144                                 # - AMD Compressonator installed in WINE
145                                 # - ResEdit installed in WINE
146                                 # - a lot of other requirements you will figure out
147                                 #   while reading the error messages
148                                 # - environment variable RELEASETYPE set
149                                 # - optionally, environment variable RELEASEDATE set
150                                 #   (YYYYMMDD)
151                                 exit 1
152                                 ;;
153                         release)
154                                 msg "Building a FINISHED RELEASE"
155                                 getversion data/xonotic-data.pk3dir
156                                 verbose "$SELF" each -k git tag -m "TEMP TAG" -f "xonotic-v$versionstr"
157                                 ;;
158                         *)
159                                 msg "Building a $RELEASETYPE"
160                                 ;;
161                 esac
162                 verbose rm -rf Xonotic Xonotic*.zip
163                 verbose mkdir -p Xonotic
164                 if [ -n "$RELEASEDATE" ]; then
165                         verbose $ECHO "$RELEASEDATE" > Xonotic/stamp.txt
166                         case "$RELEASETYPE" in
167                                 release)
168                                         verbose $ECHO "${RELEASEDATE%_*}" > Xonotic/pk3stamp.txt
169                                         ;;
170                                 *)
171                                         verbose $ECHO "$RELEASEDATE" > Xonotic/pk3stamp.txt
172                                         ;;
173                         esac
174                 else
175                         verbose date +%Y%m%d > Xonotic/stamp.txt
176                         verbose date +%Y%m%d > Xonotic/pk3stamp.txt
177                 fi
178                 release_git_extract_dir "." "Xonotic" Docs misc server xonotic-linux-glx.sh xonotic-linux-sdl.sh xonotic-linux-dedicated.sh Makefile misc/buildfiles key_0.d0pk COPYING GPL-2 GPL-3
179                 (
180                         verbose cd Xonotic
181                         verbose mkdir data source source/darkplaces source/gmqcc source/d0_blind_id mapping
182                         verbose rm -rf misc/builddeps
183                         #verbose mv bin32/SDL.dll . || true # Leftover?
184
185                         # We're going to be building these later
186                         #verbose mv misc/buildfiles/win32 bin32 || true
187                         #verbose mv misc/buildfiles/win64 bin64 || true
188
189                         verbose mv misc/buildfiles/osx/* . || true
190                         verbose rm -rf misc/buildfiles
191                         verbose rm -rf misc/pki
192                 )
193                 release_git_extract_dir "darkplaces" "Xonotic/source/darkplaces" .
194                 release_git_extract_dir "gmqcc" "Xonotic/source/gmqcc" .
195                 release_git_extract_dir "data/xonotic-data.pk3dir" "Xonotic/source" qcsrc Makefile
196                 release_git_extract_dir "d0_blind_id" "Xonotic/source/d0_blind_id" .
197                 (
198                         verbose cd Xonotic/source/d0_blind_id
199                         verbose sh autogen.sh
200                 )
201                 rm -f Xonotic/key_15.d0pk
202                 (
203                         verbose cd Xonotic/mapping
204                         # bones_was_here: don't ship 10 year old netradiant
205                         # also seems better to update netradiant independently of xonotic versions
206                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301.tar.bz2
207                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301-win32-7z.exe
208                         #for X in *-7z.exe; do
209                         #       7za x "$X"
210                         #       rm -f "$X"
211                         #done
212                         # TODO possibly include other tools?
213                         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
214                 )
215                 ./all each git rev-parse HEAD > Xonotic/misc/git-revisions.txt
216                 ;;
217         release-compile-run)
218                 release_common
219                 host=$1
220                 buildpath=$2
221                 maketargets=$3
222                 makeflags=$4
223                 srcdir=$5
224                 depsdir=$6
225                 targetfiles=$7
226                 set -x
227                 if [ -z "$targetfiles" ]; then
228                         exit
229                 fi
230                 case " $HOSTS_THAT_ARE_DISABLED " in
231                         *\ $host\ *)
232                                 exit
233                                 ;;
234                 esac
235                 case " $HOSTS_THAT_ARE_MYSELF " in
236                         *\ $host\ *)
237                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$buildpath/"
238                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$buildpath"/darkplaces.ico
239                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$buildpath.deps/"
240                                 verbose ln -snf "$buildpath.deps" "$buildpath/.deps"
241                                 verbose eval make -C "$buildpath" clean $maketargets $makeflags
242                                 for f in $targetfiles; do
243                                         verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
244                                 done
245                                 ;;
246                         *)
247                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$host":"$buildpath/"
248                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$host":"$buildpath"/darkplaces.ico
249                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$host":"$buildpath.deps/"
250                                 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"
251                                 for f in $targetfiles; do
252                                         verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
253                                 done
254                                 ;;
255                 esac
256                 ;;
257         release-compile)
258                 release_common
259                 suffix=$1
260                 makeflags=$2
261                 darkplaces_maketargets=$3
262                 darkplaces_files=$4
263                 host=xonotic-build-$suffix
264                 verbose "$SELF" release-compile-run "$host" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$d0/misc/builddeps/$suffix" "$darkplaces_files"
265                 ;;
266         release-getbinary)
267                 release_common
268                 binary=$1
269                 basename=${binary##*/}
270                 dpname=darkplaces${basename#xonotic}
271                 rev=`( cd "$d0/darkplaces" && git rev-parse HEAD )`
272                 verbose wget -O "$binary" "http://beta.xonotic.org/autobuild-bin/$rev/$dpname"
273                 [ -s "$binary" ] || rm -f "$binary"
274                 [ -f "$binary" ]
275                 case "$binary" in
276                         Xonotic/*osx*|Xonotic/*linux*)
277                                 chmod +x "$binary"
278                                 ;;
279                 esac
280                 ;;
281         release-dlls-compile)
282                 release_common
283                 arch=$1
284                 buildpath=$2
285                 targetdir=$3
286                 mkdir -p "$targetdir"
287                 (
288                         cd "misc/buildsrc"
289                         verbose ./dlls.sh all "$buildpath" "$arch"
290                 )
291                 verbose cp -v $buildpath/out/$arch/* "$targetdir"
292                 ;;
293         release-dlls-win32)
294                 release_common
295                 verbose "$SELF" release-dlls-compile win32 /tmp/dlls Xonotic/bin32
296                 ;;
297         release-dlls-win64)
298                 release_common
299                 verbose "$SELF" release-dlls-compile win64 /tmp/dlls Xonotic/bin64
300                 ;;
301         release-dlls)
302                 release_common
303                 verbose "$SELF" release-dlls-win32
304                 verbose "$SELF" release-dlls-win64
305                 verbose rm -rf /tmp/dlls
306                 ;;
307         release-engine-win32)
308                 release_common
309                 #good=true
310                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86.exe || good=false
311                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86-dedicated.exe || good=false
312                 #$good
313                 verbose "$SELF" release-compile win32 \
314                         'STRIP=: D3D=1 DP_MAKE_TARGET=mingw WIN32RELEASE=1 CC="i686-w64-mingw32-gcc -static -g1 -mstackrealign -Wl,--dynamicbase -Wl,--nxcompat -I../../../.deps/include -L../../../.deps/lib -DSUPPORTIPV6" WINDRES="i686-w64-mingw32-windres" 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' \
315                         release 'darkplaces.exe:Xonotic/xonotic-x86-wgl.exe darkplaces-sdl.exe:Xonotic/xonotic-x86.exe darkplaces-dedicated.exe:Xonotic/xonotic-x86-dedicated.exe'
316                 ;;
317         release-engine-win64)
318                 release_common
319                 #good=true
320                 #verbose "$SELF" release-getbinary Xonotic/xonotic.exe || good=false
321                 #verbose "$SELF" release-getbinary Xonotic/xonotic-dedicated.exe || good=false
322                 #$good
323                 verbose "$SELF" release-compile win64 \
324                         'STRIP=: D3D=1 DP_MAKE_TARGET=mingw WIN64RELEASE=1 CC="x86_64-w64-mingw32-gcc -static -g1 -Wl,--dynamicbase -Wl,--nxcompat -I../../../.deps/include -L../../../.deps/lib -DSUPPORTIPV6" WINDRES="x86_64-w64-mingw32-windres" 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' \
325                         release 'darkplaces.exe:Xonotic/xonotic-wgl.exe darkplaces-sdl.exe:Xonotic/xonotic.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
326                 ;;
327         release-engine-osx)
328                 release_common
329                 #good=true
330                 #verbose "$SELF" release-getbinary Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin || good=false
331                 #verbose "$SELF" release-getbinary Xonotic/xonotic-osx-dedicated || good=false
332                 #$good
333                 # Note: travis build script also had SDLCONFIG_MACOSX* flags; need to check if they're still needed with osxcross.
334                 verbose "$SELF" release-compile osx \
335                         'STRIP=: DP_MAKE_TARGET=macosx CC="$HOME/osxcross/out/bin/o64-clang -g1 -arch x86_64 -mmacosx-version-min=10.6 -Wl,-rpath -Wl,@loader_path/../Frameworks -Wl,-rpath -Wl,@loader_path -I../../../.deps/include -L../../../.deps/lib -DSUPPORTIPV6" 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' \
336                         'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
337                 ;;
338         release-engine-linux64)
339                 release_common
340                 #good=true
341                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-sdl || good=false
342                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-glx || good=false
343                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-dedicated || good=false
344                 #$good
345                 verbose "$SELF" release-compile linux64 \
346                         'STRIP=: CC="gcc -m64 -g1 -I../../../.deps/include -L../../../.deps/lib -DSUPPORTIPV6" DP_LINK_CRYPTO=shared LIB_CRYPTO="../../../.deps/lib/libd0_blind_id.a ../../../.deps/lib/libgmp.a" DP_LINK_CRYPTO_RIJNDAEL=shared DP_LINK_JPEG=shared LIB_JPEG=/usr/lib/x86_64-linux-gnu/libjpeg.a DP_LINK_ODE=shared CFLAGS_ODE="-DUSEODE -DLINK_TO_LIBODE -DdDOUBLE" LIB_ODE="../../../.deps/lib/libode.a -lstdc++ -pthread" DP_LINK_ZLIB=shared' \
347                         release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
348                 ;;
349         release-engine)
350                 release_common
351                 # TODO report failures here.
352                 good=false
353                 verbose "$SELF" release-engine-linux64 && good=true
354                 verbose "$SELF" release-engine-win32 && good=true
355                 verbose "$SELF" release-engine-win64 && good=true
356                 verbose "$SELF" release-engine-osx && good=true
357                 $good
358                 ;;
359         release-maps)
360                 release_common
361                 verbose "$SELF" update-maps
362                 ;;
363         release-qc)
364                 release_common
365                 verbose make -C "$d0/gmqcc" gmqcc
366                 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
367                 ;;
368         release-buildpk3-transform-raw)
369                 release_common
370                 dir=$1
371                 ;;
372         release-buildpk3-transform-normal)
373                 release_common
374                 dir=$1
375                 verbose cd "$dir"
376                 # texture: convert to jpeg and dds
377                 verbose export do_jpeg=true
378                 verbose export jpeg_qual_rgb=97
379                 verbose export jpeg_qual_a=99
380                 verbose export do_dds=false
381                 verbose export do_ogg=true
382                 verbose export ogg_ogg=false
383                 verbose export del_src=true
384                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
385                 ;;
386         release-buildpk3-transform-normaldds)
387                 release_common
388                 dir=$1
389                 verbose cd "$dir"
390                 # texture: convert to jpeg and dds
391                 # music: reduce bitrate
392                 verbose export do_jpeg=false
393                 verbose export do_jpeg_if_not_dds=true
394                 verbose export jpeg_qual_rgb=95
395                 verbose export jpeg_qual_a=99
396                 verbose export do_dds=true
397                 verbose export dds_flags=
398                 verbose export do_ogg=true
399                 verbose export ogg_ogg=false
400                 verbose export del_src=true
401                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
402                 ;;
403         release-buildpk3-transform-mapping)
404                 release_common
405                 dir=$1
406                 verbose cd "$dir"
407                 # remove stuff radiant has no use for
408                 verbose find . -name \*_norm.\* -exec rm -f {} \;
409                 verbose find . -name \*_bump.\* -exec rm -f {} \;
410                 verbose find . -name \*_glow.\* -exec rm -f {} \;
411                 verbose find . -name \*_gloss.\* -exec rm -f {} \;
412                 verbose find . -name \*_pants.\* -exec rm -f {} \;
413                 verbose find . -name \*_shirt.\* -exec rm -f {} \;
414                 verbose find . -name \*_reflect.\* -exec rm -f {} \;
415                 verbose find . -not \( -name \*.tga -o -name \*.png -o -name \*.jpg \) -exec rm -f {} \;
416                 # texture: convert to jpeg and dds
417                 # music: reduce bitrate
418                 verbose export do_jpeg=true
419                 verbose export jpeg_qual_rgb=80
420                 verbose export jpeg_qual_a=97
421                 verbose export do_dds=false
422                 verbose export do_ogg=true
423                 verbose export ogg_qual=1
424                 verbose export del_src=true
425                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
426                 ;;
427         release-buildpk3)
428                 release_common
429                 src=$1
430                 dst=$2
431                 transform=$3
432                 case "$dst" in
433                         /*)
434                                 ;;
435                         */)
436                                 dst="$PWD/$dst"
437                                 ;;
438                 esac
439                 release_timereport
440                 verbose rm -rf Xonotic/temp
441                 release_timereport "deleted temp directory"
442                 verbose mkdir -p Xonotic/temp
443                 release_git_extract_dir "$src" "Xonotic/temp" .
444                 release_timereport "extracted data"
445                 verbose cd Xonotic/temp
446                 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
447                         verbose cp ../source/progs.dat .
448                         verbose cp ../source/csprogs.dat .
449                         verbose cp ../source/menu.dat .
450                         # Include line numbers in qc errors
451                         verbose cp ../source/progs.lno .
452                         verbose cp ../source/csprogs.lno .
453                         verbose cp ../source/menu.lno .
454                         verbose rm -rf qcsrc
455                         getversion .
456                         case "$RELEASETYPE" in
457                                 release)
458                                         ;;
459                                 *)
460                                         versionstr="$versionstr$RELEASETYPE"
461                                         ;;
462                         esac
463                         if [ $gv -lt 9900 ]; then
464                                 # pre-1.0: compatible with any other pre-1.0
465                                 verbose sed "
466                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion $versionstr /;
467                                         s/^gameversion_max [0-9]*/gameversion_max  9999/;
468                                 " < xonotic-common.cfg > xonotic-common.cfg.new
469                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
470                                 # s/^gameversion_min [0-9]*/gameversion_min     0/;
471                         else
472                                 # >= 1.0
473                                 verbose sed "
474                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion $versionstr /;
475                                         s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
476                                 " < xonotic-common.cfg > xonotic-common.cfg.new
477                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
478                                 # s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
479                         fi
480                         mv xonotic-common.cfg.new xonotic-common.cfg
481                         case "$RELEASETYPE" in
482                                 release)
483                                         echo "" >> xonotic-common.cfg
484                                         echo "// nicer menu" >> xonotic-common.cfg
485                                         echo "set menu_watermark \"\"" >> xonotic-common.cfg
486                                         ;;
487                         esac
488                         (
489                                 verbose cd gfx/menu/luminos
490                                 verbose rm -f background_l2.tga background_ingame_l2.tga
491                                 verbose cp "$d0"/mediasource/gfx/menu/luminos_versionbuilder/background_l2.svg .
492                                 verbose "$d0"/mediasource/gfx/menu/luminos_versionbuilder/versionbuilder "$versionstr"
493                                 verbose rm background_l2.svg
494                         )
495                         verbose "$d0"/mediasource/gfx/luma/render-version.sh "$d0/mediasource/gfx/luma" "$PWD" "$versionstr"
496                 fi
497                 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
498                         for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
499                                 if [ -f "$X" ]; then
500                                         verbose unzip "$X"
501                                         verbose rm -f maps/*.log maps/*.irc maps/*.lin
502                                 fi
503                         done
504                 fi
505                 verbose export git_src_repo="$d0/$src" # skip hash-object
506                 release_timereport "processed data"
507                 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
508                 release_timereport "transformed data"
509                 find . -type f -size +4k | verbose "$d0"/misc/tools/symlink-deduplicate.sh
510                 release_timereport "deduplicated data"
511                 verbose mkzipr "../../$dst" *
512                 release_timereport "zipped data"
513                 verbose cd ../..
514                 verbose rm -rf Xonotic/temp
515                 release_timereport "deleted temp directory again"
516                 ;;
517         release-buildpk3s)
518                 release_common
519                 pk3stamp=`cat Xonotic/pk3stamp.txt`
520                 src=$1
521                 shift
522                 dst=${src%.pk3dir}
523                 case "$dst" in
524                         data/xonotic-*)
525                                 dst="data/xonotic-$pk3stamp-${dst#data/xonotic-}"
526                                 ;;
527                         *)
528                                 dst="$dst-$pk3stamp"
529                                 ;;
530                 esac
531                 while [ "$#" -gt 1 ]; do
532                         verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
533                         shift
534                         shift
535                 done
536                 ;;
537         release-pack)
538                 release_common
539                 verbose "$SELF" release-buildpk3s data/font-unifont.pk3dir      raw ''
540                 verbose "$SELF" release-buildpk3s data/font-xolonium.pk3dir     raw ''
541                 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir             normaldds ''                    normal '-high'
542                 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir             normaldds '' mapping '-mapping' normal '-high'
543                 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir     raw ''
544                 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir        normaldds ''                    normal '-high'
545                 ;;
546         release-pack-needsx11)
547                 release_common
548                 case "$DISPLAY" in
549                         '')
550                                 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
551                                 ;;
552                         *)
553                                 verbose "$SELF" release-pack
554                                 ;;
555                 esac
556                 ;;
557         release-zip)
558                 release_common
559                 stamp=`cat Xonotic/stamp.txt`
560                 pk3stamp=`cat Xonotic/pk3stamp.txt`
561                 # exe and dll files do not need +x, so this makes them eligible for 7zip compression too
562                 chmod a-x Xonotic/*.exe Xonotic/*.dll || true
563                 # build the archives
564                 verbose mkzip Xonotic-$stamp-enginesource.zip \
565                         Xonotic/Makefile \
566                         Xonotic/source/darkplaces/ \
567                         Xonotic/COPYING Xonotic/GPL-2 Xonotic/GPL-3
568                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-engine.zip
569                 verbose mkzip Xonotic-$stamp-engine.zip \
570                         Xonotic/*.dll \
571                         Xonotic/bin32/*.dll \
572                         Xonotic/bin64/*.dll \
573                         Xonotic/*.app \
574                         Xonotic/xonotic-* \
575                         Xonotic/xonotic.exe
576                 verbose cp Xonotic-$stamp-engine.zip Xonotic-$stamp-common.zip
577                 verbose mkzip Xonotic-$stamp-common.zip \
578                         Xonotic/source/d0_blind_id/ \
579                         Xonotic/source/gmqcc/ \
580                         Xonotic/source/qcsrc/ \
581                         Xonotic/Docs \
582                         Xonotic/misc \
583                         Xonotic/gmqcc \
584                         Xonotic/server \
585                         Xonotic/key_0.d0pk \
586                         Xonotic/data/font-unifont-$pk3stamp.pk3 \
587                         Xonotic/data/font-xolonium-$pk3stamp.pk3
588                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-source.zip
589                 verbose mkzip Xonotic-$stamp-source.zip \
590                         Xonotic/source/d0_blind_id/ \
591                         Xonotic/source/gmqcc/ \
592                         Xonotic/source/qcsrc/ \
593                         Xonotic/misc/logos
594                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
595                 verbose mkzip0 Xonotic-$stamp.zip \
596                         Xonotic/data/xonotic-$pk3stamp-data.pk3 \
597                         Xonotic/data/xonotic-$pk3stamp-maps.pk3 \
598                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
599                         Xonotic/data/xonotic-$pk3stamp-nexcompat.pk3
600                 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
601                 verbose mkzip0 Xonotic-$stamp-high.zip \
602                         Xonotic/data/xonotic-$pk3stamp-data-high.pk3 \
603                         Xonotic/data/xonotic-$pk3stamp-maps-high.pk3 \
604                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
605                         Xonotic/data/xonotic-$pk3stamp-nexcompat-high.pk3
606                 verbose mkzip Xonotic-$stamp-mappingsupport.zip \
607                         Xonotic/mapping
608                 verbose mkzip0 Xonotic-$stamp-mappingsupport.zip \
609                         Xonotic/data/xonotic-$pk3stamp-maps-mapping.pk3
610                 verbose mkzip gmqcc-$stamp.zip \
611                         Xonotic/gmqcc \
612                         Xonotic/source/gmqcc
613                 ;;
614         release)
615                 release_common
616                 verbose "$SELF" release-prepare
617                 verbose "$SELF" release-maps
618                 verbose "$SELF" release-dlls
619                 verbose "$SELF" release-engine
620                 verbose "$SELF" release-qc
621                 verbose "$SELF" release-pack
622                 verbose "$SELF" release-zip
623                 ;;
624         *)
625                 handled=false
626                 ;;
627 esac