]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/all/release.subr
Minor optimisation and cleanup of builds, mainly for rsync
[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/buildsrc misc/logos misc/tools server xonotic-linux-glx.sh 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                 )
184                 release_git_extract_dir "darkplaces" "Xonotic/source/darkplaces" .
185                 release_git_extract_dir "gmqcc" "Xonotic/source/gmqcc" .
186                 release_git_extract_dir "data/xonotic-data.pk3dir" "Xonotic/source" qcsrc Makefile
187                 release_git_extract_dir "d0_blind_id" "Xonotic/source/d0_blind_id" .
188 # bones_was_here: the main Makefile runs autogen.sh (and configure) when necessary
189 #               (
190 #                       verbose cd Xonotic/source/d0_blind_id
191 #                       verbose sh autogen.sh
192 #               )
193                 rm -f Xonotic/key_15.d0pk
194                 (
195                         verbose cd Xonotic/mapping
196                         # bones_was_here: don't ship 10 year old netradiant
197                         # also seems better to update netradiant independently of xonotic versions
198                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301.tar.bz2
199                         #verbose wget http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301-win32-7z.exe
200                         #for X in *-7z.exe; do
201                         #       7za x "$X"
202                         #       rm -f "$X"
203                         #done
204                         # TODO possibly include other tools?
205                         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
206                 )
207                 ./all each git rev-parse HEAD > Xonotic/misc/git-revisions.txt
208                 ;;
209         release-compile-run)
210                 release_common
211                 host=$1
212                 buildpath=$2
213                 maketargets=$3
214                 makeflags=$4
215                 srcdir=$5
216                 depsdir=$6
217                 targetfiles=$7
218                 set -x
219                 if [ -z "$targetfiles" ]; then
220                         exit
221                 fi
222                 case " $HOSTS_THAT_ARE_DISABLED " in
223                         *\ $host\ *)
224                                 exit
225                                 ;;
226                 esac
227                 case " $HOSTS_THAT_ARE_MYSELF " in
228                         *\ $host\ *)
229                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$buildpath/"
230                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$buildpath"/darkplaces.ico
231                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$buildpath.deps/"
232                                 verbose ln -snf "$buildpath.deps" "$buildpath/.deps"
233                                 verbose eval make -C "$buildpath" clean $maketargets $makeflags
234                                 for f in $targetfiles; do
235                                         verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
236                                 done
237                                 ;;
238                         *)
239                                 verbose rsync --delete -zLvaSHP "$srcdir"/ "$host":"$buildpath/"
240                                 verbose rsync --delete -zLvaSHP misc/logos/icons_ico/xonotic.ico "$host":"$buildpath"/darkplaces.ico
241                                 verbose rsync --delete -zLvaSHP "$depsdir"/*/ "$host":"$buildpath.deps/"
242                                 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"
243                                 for f in $targetfiles; do
244                                         verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
245                                 done
246                                 ;;
247                 esac
248                 ;;
249         release-compile)
250                 release_common
251                 suffix=$1
252                 makeflags=$2
253                 darkplaces_maketargets=$3
254                 darkplaces_files=$4
255                 host=xonotic-build-$suffix
256                 verbose "$SELF" release-compile-run "$host" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$d0/misc/builddeps/$suffix" "$darkplaces_files"
257                 ;;
258         release-getbinary)
259                 release_common
260                 binary=$1
261                 basename=${binary##*/}
262                 dpname=darkplaces${basename#xonotic}
263                 rev=`( cd "$d0/darkplaces" && git rev-parse HEAD )`
264                 verbose wget -O "$binary" "http://beta.xonotic.org/autobuild-bin/$rev/$dpname"
265                 [ -s "$binary" ] || rm -f "$binary"
266                 [ -f "$binary" ]
267                 case "$binary" in
268                         Xonotic/*osx*|Xonotic/*linux*)
269                                 chmod +x "$binary"
270                                 ;;
271                 esac
272                 ;;
273         release-dlls-compile)
274                 release_common
275                 arch=$1
276                 buildpath=$2
277                 targetdir=$3
278                 mkdir -p "$targetdir"
279                 (
280                         cd "misc/buildsrc"
281                         verbose ./dlls.sh all "$buildpath" "$arch"
282                 )
283                 verbose cp -v $buildpath/out/$arch/* "$targetdir"
284                 ;;
285         release-dlls-win32)
286                 release_common
287                 verbose "$SELF" release-dlls-compile win32 /tmp/dlls Xonotic/bin32
288                 ;;
289         release-dlls-win64)
290                 release_common
291                 verbose "$SELF" release-dlls-compile win64 /tmp/dlls Xonotic/bin64
292                 ;;
293         release-dlls)
294                 release_common
295                 verbose "$SELF" release-dlls-win32
296                 verbose "$SELF" release-dlls-win64
297                 verbose rm -rf /tmp/dlls
298                 ;;
299         release-engine-win32)
300                 release_common
301                 #good=true
302                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86.exe || good=false
303                 #verbose "$SELF" release-getbinary Xonotic/xonotic-x86-dedicated.exe || good=false
304                 #$good
305                 verbose "$SELF" release-compile win32 \
306                         'STRIP=: D3D=1 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 -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' \
307                         release 'darkplaces.exe:Xonotic/xonotic-x86-wgl.exe darkplaces-sdl.exe:Xonotic/xonotic-x86.exe darkplaces-dedicated.exe:Xonotic/xonotic-x86-dedicated.exe'
308                 ;;
309         release-engine-win64)
310                 release_common
311                 #good=true
312                 #verbose "$SELF" release-getbinary Xonotic/xonotic.exe || good=false
313                 #verbose "$SELF" release-getbinary Xonotic/xonotic-dedicated.exe || good=false
314                 #$good
315                 verbose "$SELF" release-compile win64 \
316                         'STRIP=: D3D=1 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 -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' \
317                         release 'darkplaces.exe:Xonotic/xonotic-wgl.exe darkplaces-sdl.exe:Xonotic/xonotic.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
318                 ;;
319         release-engine-osx)
320                 release_common
321                 #good=true
322                 #verbose "$SELF" release-getbinary Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin || good=false
323                 #verbose "$SELF" release-getbinary Xonotic/xonotic-osx-dedicated || good=false
324                 #$good
325                 # Note: travis build script also had SDLCONFIG_MACOSX* flags; need to check if they're still needed with osxcross.
326                 verbose "$SELF" release-compile osx \
327                         'STRIP=: DP_MAKE_TARGET=macosx CC="$HOME/osxcross/out/bin/o64-clang -flto -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' \
328                         'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
329                 ;;
330         release-engine-linux64)
331                 release_common
332                 #good=true
333                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-sdl || good=false
334                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-glx || good=false
335                 #verbose "$SELF" release-getbinary Xonotic/xonotic-linux64-dedicated || good=false
336                 #$good
337                 verbose "$SELF" release-compile linux64 \
338                         'STRIP=: CC="gcc -m64 -flto=auto -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' \
339                         release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
340                 ;;
341         release-engine)
342                 release_common
343                 # TODO report failures here.
344                 good=false
345                 verbose "$SELF" release-engine-linux64 && good=true
346                 verbose "$SELF" release-engine-win32 && good=true
347                 verbose "$SELF" release-engine-win64 && good=true
348                 verbose "$SELF" release-engine-osx && good=true
349                 $good
350                 ;;
351         release-maps)
352                 release_common
353                 verbose "$SELF" update-maps
354                 ;;
355         release-qc)
356                 release_common
357                 verbose make -C "$d0/gmqcc" gmqcc
358                 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
359                 ;;
360         release-buildpk3-transform-raw)
361                 release_common
362                 dir=$1
363                 ;;
364         release-buildpk3-transform-normal)
365                 release_common
366                 dir=$1
367                 verbose cd "$dir"
368                 # texture: convert to jpeg and dds
369                 verbose export do_jpeg=true
370                 verbose export jpeg_qual_rgb=97
371                 verbose export jpeg_qual_a=99
372                 verbose export do_dds=false
373                 verbose export do_ogg=true
374                 verbose export ogg_ogg=false
375                 verbose export del_src=true
376                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
377                 ;;
378         release-buildpk3-transform-normaldds)
379                 release_common
380                 dir=$1
381                 verbose cd "$dir"
382                 # texture: convert to jpeg and dds
383                 # music: reduce bitrate
384                 verbose export do_jpeg=false
385                 verbose export do_jpeg_if_not_dds=true
386                 verbose export jpeg_qual_rgb=95
387                 verbose export jpeg_qual_a=99
388                 verbose export do_dds=true
389                 verbose export dds_flags=
390                 verbose export do_ogg=true
391                 verbose export ogg_ogg=false
392                 verbose export del_src=true
393                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
394                 ;;
395         release-buildpk3-transform-mapping)
396                 release_common
397                 dir=$1
398                 verbose cd "$dir"
399                 # don't include levelshots, lightmaps and minimaps from official map builds, as well as other unneeded folders
400                 rm -rf gfx maps scripts sound
401                 # remove stuff radiant has no use for
402                 verbose find . -name \*_norm.\* -exec rm -f {} \;
403                 verbose find . -name \*_bump.\* -exec rm -f {} \;
404                 verbose find . -name \*_glow.\* -exec rm -f {} \;
405                 verbose find . -name \*_gloss.\* -exec rm -f {} \;
406                 verbose find . -name \*_pants.\* -exec rm -f {} \;
407                 verbose find . -name \*_shirt.\* -exec rm -f {} \;
408                 verbose find . -name \*_reflect.\* -exec rm -f {} \;
409                 verbose find . -not \( -name \*.tga -o -name \*.png -o -name \*.jpg \) -exec rm -f {} \;
410                 # texture: convert to jpeg and dds
411                 # music: reduce bitrate
412                 verbose export do_jpeg=true
413                 verbose export jpeg_qual_rgb=80
414                 verbose export jpeg_qual_a=97
415                 verbose export do_dds=false
416                 verbose export do_ogg=true
417                 verbose export ogg_qual=1
418                 verbose export del_src=true
419                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
420                 ;;
421         release-buildpk3)
422                 release_common
423                 src=$1
424                 dst=$2
425                 transform=$3
426                 case "$dst" in
427                         /*)
428                                 ;;
429                         */)
430                                 dst="$PWD/$dst"
431                                 ;;
432                 esac
433                 release_timereport
434                 verbose rm -rf Xonotic/temp
435                 release_timereport "deleted temp directory"
436                 verbose mkdir -p Xonotic/temp
437                 release_git_extract_dir "$src" "Xonotic/temp" .
438                 release_timereport "extracted data"
439                 verbose cd Xonotic/temp
440                 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
441                         verbose cp ../source/progs.dat .
442                         verbose cp ../source/csprogs.dat .
443                         verbose cp ../source/menu.dat .
444                         # Include line numbers in qc errors
445                         verbose cp ../source/progs.lno .
446                         verbose cp ../source/csprogs.lno .
447                         verbose cp ../source/menu.lno .
448                         verbose rm -rf qcsrc
449                         getversion .
450                         case "$RELEASETYPE" in
451                                 release)
452                                         ;;
453                                 RC*)
454                                         versionstr="$versionstr $RELEASETYPE"
455                                         ;;
456                                 *)
457                                         versionstr="$versionstr$RELEASETYPE"
458                                         ;;
459                         esac
460                         if [ $gv -lt 9900 ]; then
461                                 # pre-1.0: compatible with any other pre-1.0
462                                 verbose sed "
463                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion \"$versionstr\" /;
464                                         s/^gameversion_max [0-9]*/gameversion_max  9999/;
465                                 " < xonotic-common.cfg > xonotic-common.cfg.new
466                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
467                                 # s/^gameversion_min [0-9]*/gameversion_min     0/;
468                         else
469                                 # >= 1.0
470                                 verbose sed "
471                                         s/^set g_xonoticversion [^ ]* /set g_xonoticversion \"$versionstr\" /;
472                                         s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
473                                 " < xonotic-common.cfg > xonotic-common.cfg.new
474                                 # Following line was included in sed above, ref https://gitlab.com/xonotic/xonotic-data.pk3dir/-/merge_requests/1034
475                                 # s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
476                         fi
477                         mv xonotic-common.cfg.new xonotic-common.cfg
478                         case "$RELEASETYPE" in
479                                 release|RC*)
480                                         echo "" >> xonotic-common.cfg
481                                         echo "// nicer menu" >> xonotic-common.cfg
482                                         echo "set menu_watermark \"\"" >> xonotic-common.cfg
483                                         ;;
484                         esac
485                         (
486                                 verbose cd gfx/menu/luminos
487                                 verbose rm -f background_l2.tga background_ingame_l2.tga
488                                 verbose cp "$d0"/mediasource/gfx/menu/luminos_versionbuilder/background_l2.svg .
489                                 verbose "$d0"/mediasource/gfx/menu/luminos_versionbuilder/versionbuilder "$versionstr"
490                                 verbose rm background_l2.svg
491                         )
492                         verbose "$d0"/mediasource/gfx/luma/render-version.sh "$d0/mediasource/gfx/luma" "$PWD" "$versionstr"
493                 fi
494                 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
495                         for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
496                                 if [ -f "$X" ]; then
497                                         verbose unzip "$X"
498                                         verbose rm -f maps/*.log maps/*.irc maps/*.lin
499                                 fi
500                         done
501                 fi
502                 verbose export git_src_repo="$d0/$src" # skip hash-object
503                 release_timereport "processed data"
504                 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
505                 release_timereport "transformed data"
506                 find . -type f -size +4k | verbose "$d0"/misc/tools/symlink-deduplicate.sh
507                 release_timereport "deduplicated data"
508                 verbose mkzipr "../../$dst" *
509                 release_timereport "zipped data"
510                 verbose cd ../..
511                 verbose rm -rf Xonotic/temp
512                 release_timereport "deleted temp directory again"
513                 ;;
514         release-buildpk3s)
515                 release_common
516                 pk3stamp=`cat Xonotic/pk3stamp.txt`
517                 src=$1
518                 shift
519                 dst=${src%.pk3dir}
520                 case "$dst" in
521                         data/xonotic-*)
522                                 dst="data/xonotic-$pk3stamp-${dst#data/xonotic-}"
523                                 ;;
524                         *)
525                                 dst="$dst-$pk3stamp"
526                                 ;;
527                 esac
528                 while [ "$#" -gt 1 ]; do
529                         verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
530                         shift
531                         shift
532                 done
533                 ;;
534         release-pack)
535                 release_common
536                 verbose "$SELF" release-buildpk3s data/font-unifont.pk3dir      raw ''
537                 verbose "$SELF" release-buildpk3s data/font-xolonium.pk3dir     raw ''
538                 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir             normaldds ''                    normal '-high'
539                 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir             normaldds '' mapping '-mapping' normal '-high'
540                 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir     raw ''
541                 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir        normaldds ''                    normal '-high'
542                 verbose "$SELF" release-buildpk3s data/xonotic-xoncompat.pk3dir        normaldds ''                    normal '-high'
543                 ;;
544         release-pack-needsx11)
545                 release_common
546                 case "$DISPLAY" in
547                         '')
548                                 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
549                                 ;;
550                         *)
551                                 verbose "$SELF" release-pack
552                                 ;;
553                 esac
554                 ;;
555         release-zip)
556                 release_common
557                 stamp=`cat Xonotic/stamp.txt`
558                 pk3stamp=`cat Xonotic/pk3stamp.txt`
559                 # exe and dll files do not need +x, so this makes them eligible for 7zip compression too
560                 chmod a-x Xonotic/*.exe Xonotic/*.dll || true
561                 # build the archives
562                 verbose mkzipr Xonotic-$stamp-enginesource.zip \
563                         Xonotic/Makefile \
564                         Xonotic/source/darkplaces/ \
565                         Xonotic/COPYING Xonotic/GPL-2 Xonotic/GPL-3
566                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-engine.zip
567                 verbose mkzipr Xonotic-$stamp-engine.zip \
568                         Xonotic/*.dll \
569                         Xonotic/bin32/*.dll \
570                         Xonotic/bin64/*.dll \
571                         Xonotic/*.app \
572                         Xonotic/xonotic-* \
573                         Xonotic/xonotic.exe
574                 verbose cp Xonotic-$stamp-engine.zip Xonotic-$stamp-common.zip
575                 verbose mkzipr Xonotic-$stamp-common.zip \
576                         Xonotic/source/d0_blind_id/ \
577                         Xonotic/source/gmqcc/ \
578                         Xonotic/source/qcsrc/ \
579                         Xonotic/Docs \
580                         Xonotic/misc \
581                         Xonotic/gmqcc \
582                         Xonotic/server \
583                         Xonotic/key_0.d0pk \
584                         Xonotic/data/font-unifont-$pk3stamp.pk3 \
585                         Xonotic/data/font-xolonium-$pk3stamp.pk3
586                 verbose cp Xonotic-$stamp-enginesource.zip Xonotic-$stamp-source.zip
587                 verbose mkzipr Xonotic-$stamp-source.zip \
588                         Xonotic/source/d0_blind_id/ \
589                         Xonotic/source/gmqcc/ \
590                         Xonotic/source/qcsrc/ \
591                         Xonotic/misc/logos
592                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
593                 verbose mkzip0 Xonotic-$stamp.zip \
594                         Xonotic/data/xonotic-$pk3stamp-data.pk3 \
595                         Xonotic/data/xonotic-$pk3stamp-maps.pk3 \
596                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
597                         Xonotic/data/xonotic-$pk3stamp-nexcompat.pk3 \
598                         Xonotic/data/xonotic-$pk3stamp-xoncompat.pk3
599                 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
600                 verbose mkzip0 Xonotic-$stamp-high.zip \
601                         Xonotic/data/xonotic-$pk3stamp-data-high.pk3 \
602                         Xonotic/data/xonotic-$pk3stamp-maps-high.pk3 \
603                         Xonotic/data/xonotic-$pk3stamp-music.pk3 \
604                         Xonotic/data/xonotic-$pk3stamp-nexcompat-high.pk3 \
605                         Xonotic/data/xonotic-$pk3stamp-xoncompat-high.pk3
606                 verbose mkzipr Xonotic-$stamp-mappingsupport.zip \
607                         Xonotic/mapping
608                 verbose mkzip0 Xonotic-$stamp-mappingsupport.zip \
609                         Xonotic/data/xonotic-$pk3stamp-maps-mapping.pk3
610                 verbose mkzipr 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