disable div0-gittools, mediasource, data/xonotic-nexcompat.pk3 repository download...
[xonotic/xonotic.git] / all
1 #!/bin/sh
2 # vim: filetype=zsh
3
4 set -e
5
6 # I use this in EVERY shell script ;)
7 LF="
8 "
9
10 d00=`pwd`
11 while ! [ -f ./all ]; do
12         if [ x"`pwd`" = x"/" ]; then
13                 echo "Cannot find myself."
14                 echo "Please run this script with the working directory inside a Xonotic checkout."
15                 exit 1
16         fi
17         cd ..
18 done
19 export d0=`pwd`
20 SELF="$d0/all"
21
22 # If we are on WINDOWS:
23 case "$0" in
24         all|*/all)
25                 case "`uname`" in
26                         MINGW*|Win*)
27                                 # Windows hates users. So this script has to copy itself elsewhere first...
28                                 cp "$SELF" ../all.xonotic.sh
29                                 export WE_HATE_OUR_USERS=1
30                                 exec ../all.xonotic.sh "$@"
31                                 ;;
32                 esac
33                 ;;
34 esac
35
36 msg()
37 {
38         echo >&2 "\e[1m$*\e[m"
39 }
40
41 self=`git hash-object "$SELF"`
42 checkself()
43 {
44         self_new=`git hash-object "$SELF"`
45         if [ x"$self" != x"$self_new" ]; then
46                 msg "./all has changed."
47                 if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
48                         msg "Rerunning the requested operation to make sure."
49                         export XONOTIC_FORBID_RERUN_ALL=1
50                         exec "$SELF" "$@"
51                 else
52                         msg "Please try $SELF update, and then retry your requested operation."
53                         exit 1
54                 fi
55         fi
56         return 0
57 }
58
59 verbose()
60 {
61         msg "+ $*"
62         "$@"
63 }
64
65 visible_repo_name()
66 {
67         case "$1" in
68                 .)
69                         echo "the root directory"
70                         ;;
71                 *)
72                         echo "\"$1\""
73                         ;;
74         esac
75 }
76
77 check_mergeconflict()
78 {
79         if git ls-files -u | grep ' 1   '; then
80                 echo
81                 echo "MERGE CONFLICT."
82                 echo "change into the \"$1\" project directory, and then:"
83                 echo "- edit the files mentioned above with your favorite editor,"
84                 echo "  and fix the conflicts (marked with <<<<<<< blocks)"
85                 echo "- for binary files, you can select the files using"
86                 echo "  git checkout --ours or git checkout --theirs"
87                 echo "- when done with a file, 'git add' the file"
88                 echo "- when done, 'git commit'"
89                 echo
90                 exit 1
91         fi
92 }
93
94 yesno()
95 {
96         yesno=
97         while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
98                 eval "$2"
99                 echo "$1"
100                 IFS= read -r yesno
101         done
102         [ x"$yesno" = x"y" ]
103 }
104
105 enter()
106 {
107         $2 cd "$1" || exit 1
108         check_mergeconflict "$1"
109 }
110
111 repos_urls="
112 .                             |                                                   | master      |
113 data/xonotic-data.pk3dir      |                                                   | master      |
114 data/xonotic-maps.pk3dir      |                                                   | master      |
115 data/xonotic-music.pk3dir     |                                                   | master      |
116 data/xonotic-nexcompat.pk3dir |                                                   | master      | no
117 mediasource                   |                                                   | master      | no
118 darkplaces                    |                                                   | div0-stable | svn
119 fteqcc                        | git://github.com/Blub/qclib.git                   | master      |
120 div0-gittools                 |                                                   | master      | no
121 netradiant                    |                                                   | master      |
122 "
123 # todo: in darkplaces, change repobranch to div0-stable
124
125 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
126
127 base=`git config remote.origin.url`
128 case "$base" in
129         */xonotic.git)
130                 base=${base%xonotic.git}
131                 ;;
132         *)
133                 echo "The main repo is not xonotic.git, what have you done?"
134                 exit 1
135                 ;;
136 esac
137
138 repourl()
139 {
140         repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
141         if [ -n "$repo_t" ]; then
142                 case "$repo_t" in
143                         *://*)
144                                 echo "$repo_t"
145                                 ;;
146                         *)
147                                 echo "$base$repo_t"
148                                 ;;
149                 esac
150         else
151                 if [ x"$1" = x"." ]; then
152                         echo "$base""xonotic.git"
153                 else
154                         echo "$base${1##*/}.git"
155                 fi
156         fi
157 }
158
159 repobranch()
160 {
161         repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
162         if [ -n "$repo_t" ]; then
163                 echo "$repo_t"
164         else
165                 echo "master"
166         fi
167 }
168
169 repoflags()
170 {
171         echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
172 }
173
174 listrepos()
175 {
176         for d in $repos; do
177                 p="${d%dir}"
178                 f="`repoflags "$d"`"
179                 # if we have the dir, always keep it
180                 if [ -d "$d" ]; then
181                         msg "Repository $d enabled because it already exists"
182                         echo "$d"
183                         continue
184                 fi
185                 # if .yes file exists, always keep it
186                 if [ -f "$d.yes" ]; then
187                         msg "Repository $d enabled by a .yes file"
188                         echo "$d"
189                         continue
190                 fi
191                 # if we have .no file, skip
192                 if [ -f "$d.no" ]; then
193                         msg "Repository $d disabled by a .no file, delete $p.no to enable"
194                         continue
195                 fi
196                 # if we have matching pk3, skip
197                 if [ x"$p" != x"$d" ] && [ -f "$p" ]; then
198                         msg "Repository $d disabled by matching .pk3 file, delete $p or create $d.yes to enable"
199                         continue
200                 fi
201                 # if "no" flag is set, skip
202                 case ",$f," in
203                         *,no,*)
204                                 msg "Repository $d disabled by default, create $d.yes to enable"
205                                 continue
206                                 ;;
207                 esac
208         done
209 }
210
211 repos=`listrepos`
212
213 if [ "$#" = 0 ]; then
214         set -- help
215 fi
216 cmd=$1
217 shift
218
219 fix_upstream_rebase()
220 {
221         if [ -z "$r_me" ] || [ -z "$r_other" ]; then
222                 return
223         fi
224         r_base=`git merge-base "$r_me" "$r_other"`
225
226         # no merge-base? upstream did filter-branch
227         if [ -n "$r_base" ]; then
228                 # otherwise, check if the two histories are "similar"
229                 r_l_me=`git log --pretty="format:%s" "$r_other".."$r_me" | grep -v "^Merge" | sort -u`
230                 r_l_other=`git log --pretty="format:%s" "$r_me".."$r_other" | grep -v "^Merge" | sort -u`
231
232                 # heuristics: upstream rebase/filter-branch if more than 50% of the commits of one of the sides are in the other too
233                 r_lc_me=`echo "$r_l_me" | wc -l`
234                 r_lc_other=`echo "$r_l_other" | wc -l`
235                 r_lc_together=`{ echo "$r_l_me"; echo "$r_l_other"; } | sort -u | wc -l`
236                 r_lc_same=$(($r_lc_me + $r_lc_other - $r_lc_together))
237
238                 if [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_me )) ] || [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_other )) ]; then
239                         if yesno "Probable upstream rebase detected, automatically fix?" 'git log --oneline --graph --date-order --left-right "$r_other"..."$r_me"'; then
240                                 git reset --hard "$r_me"
241                                 git pull --rebase
242                                 return 1
243                         fi
244                 fi
245         fi
246
247         return 0
248 }
249
250 fix_upstream_rebase_mergeok()
251 {
252         r_me=`git rev-parse --revs-only HEAD^1 2>/dev/null || true`
253         r_other=`git rev-parse --revs-only HEAD^2 2>/dev/null || true`
254         fix_upstream_rebase
255 }
256
257 fix_upstream_rebase_mergefail()
258 {
259         r_me=`git rev-parse --revs-only HEAD 2>/dev/null || true`
260         r_other=`git rev-parse --revs-only MERGE_HEAD 2>/dev/null || true`
261         fix_upstream_rebase
262 }
263
264 case "$cmd" in
265         fix_upstream_rebase)
266                 for d in $repos; do
267                         enter "$d0/$d" verbose
268                         verbose fix_upstream_rebase_mergefail && verbose fix_upstream_rebase_mergeok
269                 done
270                 ;;
271         update|pull)
272                 allow_pull=true
273                 if [ x"$1" = x"-N" ]; then
274                         allow_pull=false
275                 fi
276                 for d in $repos; do
277                         url=`repourl "$d"`
278                         branch=`repobranch "$d"`
279                         if [ -d "$d0/$d" ]; then
280                                 if $allow_pull; then
281                                         enter "$d0/$d" verbose
282                                         verbose git config remote.origin.url "$url"
283                                         verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
284
285                                         verbose git config core.autocrlf input
286
287                                         r=`git symbolic-ref HEAD`
288                                         r=${r#refs/heads/}
289                                         if git config branch.$r.remote >/dev/null 2>&1; then
290                                                 if ! verbose git pull; then
291                                                         fix_upstream_rebase_mergefail || true
292                                                         check_mergeconflict "$d"
293                                                         echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
294                                                         read -r DUMMY
295                                                 else
296                                                         fix_upstream_rebase_mergeok || true
297                                                 fi
298                                         fi
299
300                                         cd "$d00"
301                                         checkself "$cmd" "$@"
302                                         cd "$d0/$d"
303                                         verbose git remote prune origin
304                                         cd "$d0"
305                                 fi
306                         else
307                                 verbose git clone "$url" "$d0/$d"
308                                 enter "$d0/$d" verbose
309                                 if [ "$branch" != "master" ]; then
310                                         verbose git checkout --track -b "$branch" origin/"$branch"
311                                 fi
312                                 cd "$d0"
313                         fi
314                 done
315                 ;;
316         update-maps)
317                 misc/tools/xonotic-map-compiler-autobuild download
318                 ;;
319         checkout|switch)
320                 checkoutflags=
321                 if [ x"$1" = x"-f" ]; then
322                         checkoutflags=-f
323                         shift
324                 fi
325                 remote=$1
326                 branch=$2
327                 if [ -z "$branch" ]; then
328                         case "$remote" in
329                                 origin/*)
330                                         branch=${remote#origin/}
331                                         remote=origin
332                                         ;;
333                                 *)
334                                         branch=$remote
335                                         remote=origin
336                                         ;;
337                         esac
338                 fi
339                 exists=false
340                 for d in $repos; do
341                         enter "$d0/$d" verbose
342                         b=$branch
343                         if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
344                                 exists=true
345                                 verbose git checkout $checkoutflags "$b"
346                         elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
347                                 exists=true
348                                 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
349                         else
350                                 b=`repobranch "$d"`
351                                 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
352                                         exists=true
353                                         verbose git checkout $checkoutflags "$b"
354                                 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
355                                         exists=true
356                                         verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
357                                 else
358                                         echo "WTF? Not even branch $b doesn't exist in $d"
359                                         exit 1
360                                 fi
361                         fi
362                         cd "$d00"
363                         checkself "$cmd" "$@"
364                         cd "$d0"
365                 done
366                 if ! $exists; then
367                         echo "The requested branch was not found in any repository."
368                 fi
369                 exec "$SELF" branch
370                 ;;
371         branch)
372                 remote=$1
373                 branch=$2
374                 srcbranch=$3
375                 if [ -z "$branch" ]; then
376                         branch=$remote
377                         remote=origin
378                 fi
379                 if [ -z "$branch" ]; then
380                         for d in $repos; do
381                                 enter "$d0/$d"
382                                 r=`git symbolic-ref HEAD`
383                                 r=${r#refs/heads/}
384                                 echo "$d is at $r"
385                                 cd "$d0"
386                         done
387                 else
388                         for d in $repos; do
389                                 dv=`visible_repo_name "$d"`
390                                 enter "$d0/$d" verbose
391                                 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
392                                         echo "Already having this branch in $dv."
393                                 else
394                                         if yesno "Branch in $dv?"; then
395                                                 if [ -n "$srcbranch" ]; then
396                                                         b=$srcbranch
397                                                 else
398                                                         b=origin/"`repobranch "$d"`"
399                                                         verbose git fetch origin || true
400                                                 fi
401                                                 # TODO do this without pushing
402                                                 verbose git checkout -b "$branch" "$b"
403                                                 verbose git config "branch.$branch.remote" "$remote"
404                                                 verbose git config "branch.$branch.merge" "refs/heads/$branch"
405                                         fi
406                                 fi
407                                 cd "$d0"
408                         done
409                         "$SELF" branch
410                 fi
411                 ;;
412         branches)
413                 for d in $repos; do
414                         cd "$d0/$d" # am in a pipe, shouldn't use enter
415                         git branch -a -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
416                         cd "$d0"
417                 done | {
418                         branches_list=
419                         # branches_repos_*=
420                         while read -r d BRANCH REV UPSTREAM TEXT; do
421                                 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
422                                         continue
423                                 fi
424                                 case "$UPSTREAM" in
425                                         \[*)
426                                                 UPSTREAM=${UPSTREAM#\[}
427                                                 UPSTREAM=${UPSTREAM%\]}
428                                                 UPSTREAM=${UPSTREAM%:*}
429                                                 ;;
430                                         *)
431                                                 TEXT="$UPSTREAM $TEXT"
432                                                 UPSTREAM=
433                                                 ;;
434                                 esac
435                                 if [ x"$REV" = x"->" ]; then
436                                         continue
437                                 fi
438                                 BRANCH=${BRANCH#remotes/}
439                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
440                                 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
441                                 eval "r=\$branches_repos_$ID"
442                                 case "$UPSTREAM" in
443                                         '')
444                                                 r="$r $d"
445                                                 ;;
446                                         *)
447                                                 r="$r $d:$UPSTREAM"
448                                                 ;;
449                                 esac
450                                 eval "branches_repos_$ID=\$r"
451                         done
452                         echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
453                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
454                                 eval "r=\$branches_repos_$ID"
455                                 printf "%-60s %s\n" "$BRANCH" "$r"
456                                 #echo "$BRANCH: $r"
457                         done
458                 }
459                 ;;
460         merge)
461                 for d in $repos; do
462                         dv=`visible_repo_name "$d"`
463                         enter "$d0/$d" verbose
464                         r=`git symbolic-ref HEAD`
465                         r=${r#refs/heads/}
466                         if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
467                                 # we have uncommitted changes
468                                 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
469                                         if ! verbose git merge origin/"`repobranch "$d"`"; then
470                                                 check_mergeconflict "$d"
471                                                 exit 1 # this should ALWAYS be fatal
472                                         fi
473                                 fi
474                         fi
475                         cd "$d0"
476                 done
477                 ;;
478         push|commit)
479                 submit=$1
480                 for d in $repos; do
481                         dv=`visible_repo_name "$d"`
482                         enter "$d0/$d" verbose
483                         r=`git symbolic-ref HEAD`
484                         r=${r#refs/heads/}
485                         diffdata=`git diff --color HEAD`
486                         if [ -n "$diffdata" ]; then
487                                 # we have uncommitted changes
488                                 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?" 'echo "$diffdata" | less -r'; then
489                                         verbose git commit -a
490                                 fi
491                         fi
492                         rem=`git config "branch.$r.remote" || echo origin`
493                         bra=`git config "branch.$r.merge" || echo "$r"`
494                         upstream="$rem/${bra#refs/heads/}"
495                         if ! git rev-parse "$upstream" >/dev/null 2>&1; then
496                                 upstream="origin/`repobranch "$d"`"
497                         fi
498                         logdata=`git log --color "$upstream".."$r"`
499                         if [ -n "$logdata" ]; then
500                                 if yesno "Push \"$r\" in $dv?" 'echo "$logdata" | less -r'; then
501                                         verbose git push "$rem" HEAD
502                                 fi
503                         fi
504                         if [ x"$submit" = x"-s" ]; then
505                                 case "$r" in
506                                         */*)
507                                                 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
508                                                 ;;
509                                 esac
510                         fi
511                         cd "$d0"
512                 done
513                 ;;
514         compile)
515                 if [ -n "$WE_HATE_OUR_USERS" ]; then
516                         TARGETS="sv-debug cl-debug"
517                         if [ -z "$CC" ]; then
518                                 export CC=gcc
519                         fi
520                 elif [ x"`uname`" = x"Darwin" ]; then
521                         case "`uname -r`" in
522                                 ?.*)
523                                         TARGETS="sv-debug cl-debug sdl-debug"
524                                         ;;
525                                 *)
526                                         # AGL cannot be compiled on systems with a kernel > 10.x (Snow Leopard)
527                                         TARGETS="sv-debug sdl-debug"
528                                         ;;
529                         esac
530                         export CC="gcc -I$PWD/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks/SDL.framework/Headers -F$PWD/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
531                 else
532                         TARGETS="sv-debug cl-debug sdl-debug"
533                 fi
534                 case "$1" in
535                         -c)
536                                 cleandp=true
537                                 cleanqcc=true
538                                 cleanqc=true
539                                 shift
540                                 ;;
541                         -n)
542                                 cleandp=false
543                                 cleanqcc=false
544                                 cleanqc=false
545                                 shift
546                                 ;;
547                         *)
548                                 cleandp=false
549                                 cleanqcc=false
550                                 cleanqc=true # version info
551                                 ;;
552                 esac
553                 if [ $# -gt 0 ] && [ x"$1" = x"" ]; then
554                         # if we give the command make the arg "", it will surely fail (invalid filename),
555                         # so better handle it as an empty client option
556                         BAD_TARGETS=" "
557                         shift
558                 elif [ -n "$1" ]; then
559                         BAD_TARGETS=
560                         TARGETS_SAVE=$TARGETS
561                         TARGETS=
562                         for X in $1; do
563                                 case "$X" in
564                                         sdl)
565                                                 TARGETS="$TARGETS sdl-debug"
566                                                 ;;
567                                         glx|agl|wgl)
568                                                 TARGETS="$TARGETS cl-debug"
569                                                 ;;
570                                         dedicated)
571                                                 TARGETS="$TARGETS sv-debug"
572                                                 ;;
573                                         *)
574                                                 BAD_TARGETS="$BAD_TARGETS $X"
575                                                 ;;
576                                 esac
577                         done
578                         if [ -n "$TARGETS" ]; then # at least a valid client
579                                 shift
580                         else # no valid client, let's assume this option is not meant to be a client then
581                                 TARGETS=$TARGETS_SAVE
582                                 BAD_TARGETS=
583                         fi
584                 fi
585                 if [ -z "$MAKEFLAGS" ]; then
586                         if [ -f /proc/cpuinfo ]; then
587                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
588                                 if [ $ncpus -gt 1 ]; then
589                                         MAKEFLAGS=-j$ncpus
590                                 fi
591                         fi
592                         if [ -n "$WE_HATE_OUR_USERS" ]; then
593                                 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw LIB_JPEG= CFLAGS_LIBJPEG="
594                         fi
595                 fi
596
597                 enter "$d0/fteqcc" verbose
598                 if $cleanqcc; then
599                         verbose make $MAKEFLAGS clean
600                 fi
601                 verbose make $MAKEFLAGS
602
603                 enter "$d0/data/xonotic-data.pk3dir" verbose
604                 if $cleanqc; then
605                         verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
606                 fi
607                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
608
609                 enter "$d0/darkplaces" verbose
610                 if [ x"$BAD_TARGETS" = x" " ]; then
611                         echo "Warning: invalid empty client, default clients will be used."
612                 fi
613                 if $cleandp; then
614                         verbose make $MAKEFLAGS clean
615                 fi
616                 for T in $TARGETS; do
617                         verbose make $MAKEFLAGS "$@" "$T"
618                 done
619                 for T in $BAD_TARGETS; do
620                         echo "Warning: discarded invalid client $T."
621                 done
622
623                 verbose "$SELF" update-maps
624                 ;;
625         run)
626                 if [ -n "$WE_HATE_OUR_USERS" ]; then
627                         client=
628                         export PATH="$d0/misc/buildfiles/win32:$PATH"
629                 elif [ x"`uname`" = x"Darwin" ]; then
630                         export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
631                         export DYLD_FRAMEWORK_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
632                         client=-sdl
633                 else
634                         client=-sdl
635                 fi
636                 case "$1" in
637                         sdl|glx|agl|dedicated)
638                                 client=-$1
639                                 shift
640                                 ;;
641                         wgl)
642                                 client=
643                                 shift
644                                 ;;
645                 esac
646                 if ! [ -x "darkplaces/darkplaces$client" ]; then
647                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
648                                 client=$client.exe
649                         else
650                                 echo "Client darkplaces/darkplaces$client not found, aborting"
651                                 exit 1
652                         fi
653                 fi
654                 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic -mygames "$@"
655
656                 # if pulseaudio is running: USE IT
657                 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
658                         if ps -C pulseaudio >/dev/null; then
659                                 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
660                                         export SDL_AUDIODRIVER=pulse
661                                 fi
662                         fi
663                 fi
664
665                 if [ -n "$USE_GDB" ]; then
666                         set -- gdb --args "$@"
667                 fi
668                 "$@"
669                 ;;
670         each|foreach)
671                 keep_going=false
672                 if [ x"$1" = x"-k" ]; then
673                         keep_going=true
674                         shift
675                 fi
676                 for d in $repos; do
677                         if verbose cd "$d0/$d"; then
678                                 if $keep_going; then
679                                         verbose "$@" || true
680                                 else
681                                         verbose "$@"
682                                 fi
683                                 cd "$d0"
684                         fi
685                 done
686                 ;;
687         save-patches)
688                 outfile=$1
689                 patchdir=`mktemp -d -t save-patches.XXXXXX`
690                 for d in $repos; do
691                         enter "$d0/$d" verbose
692                         git branch -v -v | cut -c 3- | {
693                                 i=0
694                                 while read -r BRANCH REV UPSTREAM TEXT; do
695                                         case "$UPSTREAM" in
696                                                 \[*)
697                                                         UPSTREAM=${UPSTREAM#\[}
698                                                         UPSTREAM=${UPSTREAM%\]}
699                                                         UPSTREAM=${UPSTREAM%:*}
700                                                         TRACK=true
701                                                         ;;
702                                                 *)
703                                                         UPSTREAM=origin/"`repobranch "$d"`"
704                                                         TRACK=false
705                                                         ;;
706                                         esac
707                                         if [ x"$REV" = x"->" ]; then
708                                                 continue
709                                         fi
710                                         if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
711                                                 echo "$d" > "$patchdir/$i/info.txt"
712                                                 echo "$BRANCH" >> "$patchdir/$i/info.txt"
713                                                 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
714                                                 echo "$TRACK" >> "$patchdir/$i/info.txt"
715                                                 i=$(($i+1))
716                                         else
717                                                 rm -rf "$patchdir/$i"
718                                         fi
719                                 done
720                         }
721                 done
722                 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
723                 rm -rf "$patchdir"
724                 ;;
725         restore-patches)
726                 infile=$1
727                 patchdir=`mktemp -d -t restore-patches.XXXXXX`
728                 ( cd "$patchdir" && tar xvzf - ) < "$infile"
729                 # detach the head
730                 for P in "$patchdir"/*/info.txt; do
731                         D=${P%/info.txt}
732                         exec 3<"$P"
733                         read -r d <&3
734                         read -r BRANCH <&3
735                         read -r UPSTREAM <&3
736                         read -r TRACK <&3
737                         verbose git checkout HEAD^0
738                         verbose git branch -D "$BRANCH"
739                         if [ x"$TRACK" = x"true" ]; then
740                                 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
741                         else
742                                 verbose git branch -b "$BRANCH" "$UPSTREAM"
743                         fi
744                         verbose git am "$D"
745                 done
746                 rm -rf "$patchdir"
747                 ;;
748         admin-merge)
749                 branch=$1
750                 t=`mktemp`
751                 report=""
752                 reportecho()
753                 {
754                         report=$report"$*$LF"
755                         echo "$*"
756                 }
757                 reportecho4()
758                 {
759                         report=$report"    $*$LF"
760                         echo "    $*"
761                 }
762                 reportdo4()
763                 {
764                         o=`"$@" | sed 's/^/    /' || true`
765                         reportecho "$o"
766                 }
767                 for d in $repos; do
768                         enter "$d0/$d" verbose
769                         base="`repobranch "$d"`"
770                         reportecho "In $d:"
771                         for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
772                                 case "${ref#refs/remotes/origin/}" in
773                                         "$base")
774                                                 continue
775                                                 ;;
776                                         HEAD|master)
777                                                 continue
778                                                 ;;
779                                         */*)
780                                                 ;;
781                                         *)
782                                                 continue
783                                                 ;;
784                                 esac
785                                 if [ -n "$branch" ]; then
786                                         if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
787                                                 continue
788                                         fi
789                                 fi
790                                 case "$base" in
791                                         master)
792                                                 realbase=$base
793                                                 ;;
794                                         *)
795                                                 l0=`git rev-list "$base".."$ref" | wc -l`
796                                                 l1=`git rev-list master.."$ref" | wc -l`
797                                                 if [ $l0 -gt $l1 ]; then
798                                                         realbase=master
799                                                 else
800                                                         realbase=$base
801                                                 fi
802                                                 ;;
803                                 esac
804                                 reportecho "  Branch $ref:"
805                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
806                                 logdata=`git log --color "$realbase".."$ref"`
807                                 if [ -z "$logdata" ]; then
808                                         reportecho4 "--> not merging, no changes vs master"
809                                         if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
810                                                 git push origin :"${ref#refs/remotes/origin/}"
811                                                 reportecho4 "--> branch deleted"
812                                         fi
813                                 else
814                                         diffdata=`git diff --color --find-copies-harder --ignore-space-change "$realbase"..."$ref"`
815                                         if [ -z "$diffdata" ]; then
816                                                 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
817                                                 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
818                                                         git push origin :"${ref#refs/remotes/origin/}"
819                                                         reportecho4 "--> branch deleted"
820                                                 fi
821                                         elif [ -z "$branch" ] && [ -n "$note" ]; then
822                                                 reportdo4 echo "$note"
823                                                 reportecho4 "--> not merging, already had this one rejected before"
824                                         elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
825                                                 git checkout "$realbase"
826                                                 org=`git rev-parse HEAD`
827                                                 if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
828                                                         git reset --hard "$org"
829                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
830                                                         reportdo4 cat "$t"
831                                                         reportecho4 "--> merge failed"
832                                                 elif ! "$SELF" compile -n 2>&1 | tee "$t"; then
833                                                         git reset --hard "$org"
834                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
835                                                         reportdo4 cat "$t"
836                                                         reportecho4 "--> compile failed"
837                                                 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
838                                                         git reset --hard "$org"
839                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
840                                                         note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
841                                                         if [ x"$note" = x"del" ]; then
842                                                                 git push origin :"${ref#refs/remotes/origin/}"
843                                                                 reportecho4 "--> test failed, branch deleted"
844                                                         elif [ -n "$note" ]; then
845                                                                 reportdo4 echo "$note"
846                                                                 reportecho4 "--> test failed"
847                                                         else
848                                                                 reportecho4 "--> test failed, postponed"
849                                                         fi
850                                                 else
851                                                         echo "MERGING"
852                                                         case ",`repoflags "$d"`," in
853                                                                 *,svn,*)
854                                                                         # we do quite a mess here... luckily we know $org
855                                                                         git fetch # svn needs to be current
856                                                                         git rebase -i --onto origin/master "$org"
857                                                                         git svn dcommit --add-author-from
858                                                                         git reset --hard "$org"
859                                                                         ;;
860                                                                 *)
861                                                                         git push origin HEAD
862                                                                         ;;
863                                                         esac
864                                                         reportecho4 "--> MERGED"
865                                                         if yesno "Delete original branch \"$ref\"?"; then
866                                                                 git push origin :"${ref#refs/remotes/origin/}"
867                                                                 reportecho4 "--> branch deleted"
868                                                         fi
869                                                 fi
870                                         else
871                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
872                                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
873                                                 if [ x"$note" = x"del" ]; then
874                                                         git push origin :"${ref#refs/remotes/origin/}"
875                                                         reportecho4 "--> branch deleted"
876                                                 elif [ -n "$note" ]; then
877                                                         reportdo4 echo "$note"
878                                                         reportecho4 "--> rejected"
879                                                 else
880                                                         reportecho4 "--> postponed"
881                                                 fi
882                                         fi
883                                 fi
884                                 reportecho ""
885                         done
886                         reportecho ""
887                 done
888                 rm -f "$t"
889                 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
890                 ;;
891         clean)
892                 force=false
893                 if [ x"$1" = x"-f" ]; then
894                         force=true
895                 fi
896                 for d in $repos; do
897                         enter "$d0/$d" verbose
898                         if $force; then
899                                 verbose git checkout-index -fa
900                         fi
901                         case "$d" in
902                                 .)
903                                         verbose git clean -df
904                                         ;;
905                                 *)
906                                         verbose git clean -xdf
907                                         ;;
908                         esac
909                 done
910                 ;;
911
912         # release building goes here
913         release-prepare)
914                 #"$SELF" each git clean -fxd
915                 case "$RELEASETYPE" in
916                         beta)
917                                 msg "Building a BETA"
918                                 ;;
919                         release)
920                                 msg "Building a RELEASE"
921                                 ;;
922                         *)
923                                 msg "Must either set RELEASETYPE=beta or RELEASETYPE=release"
924                                 exit 1
925                                 ;;
926                 esac
927                 verbose rm -rf Xonotic Xonotic*.zip
928                 verbose mkdir -p Xonotic
929                 verbose date +%Y%m%d > Xonotic/stamp.txt
930                 verbose git archive --format=tar HEAD -- Docs misc server xonotic-linux-glx.sh xonotic-linux-sdl.sh misc/buildfiles | {
931                         verbose cd Xonotic
932                         verbose mkdir data fteqcc source source/darkplaces source/fteqcc
933                         verbose tar xvf -
934                         verbose rm -rf misc/builddeps
935                         verbose mv misc/buildfiles/win32/* . || true
936                         verbose mv misc/buildfiles/win64 bin64 || true
937                         verbose mv misc/buildfiles/osx/* . || true
938                         verbose rm -rf misc/buildfiles
939                 }
940                 {
941                         verbose cd darkplaces
942                         verbose git archive --format=tar HEAD
943                 } | {
944                         verbose cd Xonotic/source/darkplaces
945                         verbose tar xvf -
946                 }
947                 {
948                         verbose cd fteqcc
949                         verbose git archive --format=tar HEAD
950                 } | {
951                         verbose cd Xonotic/source/fteqcc
952                         verbose tar xvf -
953                 }
954                 {
955                         verbose cd data/xonotic-data.pk3dir
956                         verbose git archive --format=tar HEAD -- qcsrc Makefile
957                 } | {
958                         verbose cd Xonotic/source
959                         verbose tar xvf -
960                 }
961                 ;;
962         release-compile-run)
963                 host=$1
964                 buildpath=$2
965                 maketargets=$3
966                 makeflags=$4
967                 srcdir=$5
968                 targetfiles=$6
969                 if [ -n "$targetfiles" ]; then
970                         case " $HOSTS_THAT_ARE_MYSELF " in
971                                 *\ $host\ *)
972                                         verbose rsync --delete -zvaSHP "$srcdir"/ "$buildpath/"
973                                         verbose eval make -C "$buildpath" clean $maketargets $makeflags
974                                         for f in $targetfiles; do
975                                                 verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
976                                         done
977                                         ;;
978                                 *)
979                                         verbose rsync --delete -zvaSHP "$srcdir"/ "$host:$buildpath/"
980                                         verbose ssh "$host" ". ~/.profile && cd $buildpath && make clean $maketargets $makeflags"
981                                         for f in $targetfiles; do
982                                                 verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
983                                         done
984                                         ;;
985                         esac
986                         # now rebrand the binaries...
987                         for f in $targetfiles; do
988                                 verbose "$d0/misc/tools/rebrand-darkplaces-engine.sh" "${XONOTIC_BRAND:-$d0/misc/tools/xonotic.brand}" "${f##*:}" || true
989                         done
990                 fi
991                 ;;
992         release-compile)
993                 suffix=$1
994                 makeflags=$2
995                 fteqcc_maketargets=$3
996                 fteqcc_files=$4
997                 darkplaces_maketargets=$5
998                 darkplaces_files=$6
999                 verbose "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "Xonotic/source/fteqcc" "$fteqcc_files"
1000                 verbose "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$darkplaces_files"
1001                 ;;
1002         release-engine-win32)
1003                 verbose "$SELF" release-compile win32 \
1004                         'STRIP=: DP_MAKE_TARGET=mingw CC="i586-mingw32msvc-gcc -g -Wl,--dynamicbase -Wl,--nxcompat -I$HOME/dp.win32/include -L$HOME/dp.win32/lib" WINDRES="i586-mingw32msvc-windres" SDL_CONFIG="$HOME/dp.win32/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN32RELEASE=1 D3D=0' \
1005                         win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
1006                         release 'darkplaces.exe:Xonotic/xonotic.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
1007                 ;;
1008         release-engine-win64)
1009                 verbose "$SELF" release-compile win64 \
1010                         'STRIP=: DP_MAKE_TARGET=mingw CC="amd64-mingw32msvc-gcc -g -Wl,--dynamicbase -Wl,--nxcompat -I$HOME/dp.win64/include -L$HOME/dp.win64/lib" WINDRES="amd64-mingw32msvc-windres" SDL_CONFIG="$HOME/dp.win64/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN64RELEASE=1 D3D=0' \
1011                         win 'fteqcc.exe:Xonotic/fteqcc/fteqcc-x64.exe' \
1012                         'sv-release cl-release' 'darkplaces.exe:Xonotic/xonotic-x64.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated-x64.exe'
1013                         # release 'darkplaces.exe:Xonotic/xonotic-x64.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl-x64.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated-x64.exe'
1014                 ;;
1015         release-engine-osx-sv-sdl)
1016                 # gcc on OSX is buggy, needs -fno-reorder-blocks for a release build to succeed
1017                 verbose "$SELF" release-compile osx \
1018                         'STRIP=: CC="gcc -g -arch i386 -arch ppc -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -I$HOME/dp.osx/include -L$HOME/dp.osx/lib -fno-reorder-blocks"' \
1019                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
1020                         'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
1021                 ;;
1022         release-engine-osx-agl)
1023                 # gcc on OSX is buggy, needs -fno-reorder-blocks for a release build to succeed
1024                 verbose "$SELF" release-compile osx \
1025                         'STRIP=: CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -I$HOME/dp.osx/include -L$HOME/dp.osx/lib -fno-reorder-blocks"' \
1026                         '' '' \
1027                         'cl-release' 'darkplaces-glx:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-agl-bin'
1028                 ;;
1029         release-engine-osx)
1030                 verbose "$SELF" release-engine-osx-sv-sdl
1031                 verbose "$SELF" release-engine-osx-agl
1032                 ;;
1033         release-engine-linux32)
1034                 verbose "$SELF" release-compile linux32 \
1035                         'STRIP=: CC="gcc -m32 -g -Wl,--hash-style=sysv -I$HOME/dp.linux32/include -L$HOME/dp.linux32/lib" DP_MODPLUG_STATIC_LIBDIR=$HOME/dp.linux32/lib LIB_JPEG=$HOME/dp.linux32/lib/libjpeg.a' \
1036                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
1037                         release 'darkplaces-glx:Xonotic/xonotic-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux32-dedicated'
1038                 ;;
1039         release-engine-linux64)
1040                 verbose "$SELF" release-compile linux64 \
1041                         'STRIP=: CC="gcc -m64 -g -Wl,--hash-style=sysv -I$HOME/dp.linux64/include -L$HOME/dp.linux64/lib" DP_MODPLUG_STATIC_LIBDIR=$HOME/dp.linux64/lib LIB_JPEG=$HOME/dp.linux64/lib/libjpeg.a' \
1042                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
1043                         release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
1044                 ;;
1045         release-engine)
1046                 verbose "$SELF" release-engine-win64
1047                 verbose "$SELF" release-engine-osx
1048                 verbose "$SELF" release-engine-win32
1049                 verbose "$SELF" release-engine-linux32
1050                 verbose "$SELF" release-engine-linux64
1051                 ;;
1052         release-maps)
1053                 verbose "$SELF" update-maps
1054                 ;;
1055         release-qc)
1056                 case "$RELEASETYPE" in
1057                         beta)
1058                                 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 clean all
1059                                 ;;
1060                         release)
1061                                 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 FTEQCCFLAGS_WATERMARK= clean all
1062                                 ;;
1063                 esac
1064                 verbose rm -f Xonotic/source/*/fteqcc.log
1065                 ;;
1066         release-buildpk3-transform-raw)
1067                 dir=$1
1068                 ;;
1069         release-buildpk3-transform-normal)
1070                 dir=$1
1071                 verbose cd "$dir"
1072                 # texture: convert to jpeg and dds
1073                 verbose export do_jpeg=true
1074                 verbose export jpeg_qual_rgb=95
1075                 verbose export jpeg_qual_a=99
1076                 verbose export do_dds=true
1077                 verbose export dds_flags=
1078                 verbose export do_ogg=false
1079                 verbose export del_src=true
1080                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1081                 ;;
1082         release-buildpk3-transform-low)
1083                 dir=$1
1084                 verbose cd "$dir"
1085                 # texture: convert to jpeg and dds
1086                 # music: reduce bitrate
1087                 verbose export do_jpeg=true
1088                 verbose export jpeg_qual_rgb=80
1089                 verbose export jpeg_qual_a=95
1090                 verbose export do_dds=false
1091                 verbose export do_ogg=true
1092                 verbose export ogg_qual=1
1093                 verbose export del_src=true
1094                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1095                 ;;
1096         release-buildpk3-transform-lowdds)
1097                 dir=$1
1098                 verbose cd "$dir"
1099                 # texture: convert to jpeg and dds
1100                 # music: reduce bitrate
1101                 verbose export do_jpeg=false
1102                 verbose export do_jpeg_if_not_dds=true
1103                 verbose export jpeg_qual_rgb=80
1104                 verbose export jpeg_qual_a=95
1105                 verbose export do_dds=true
1106                 verbose export dds_flags=
1107                 verbose export do_ogg=true
1108                 verbose export ogg_qual=1
1109                 verbose export del_src=true
1110                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1111                 ;;
1112         release-buildpk3)
1113                 src=$1
1114                 dst=$2
1115                 transform=$3
1116                 case "$dst" in
1117                         /*)
1118                                 ;;
1119                         */)
1120                                 dst="$PWD/$dst"
1121                                 ;;
1122                 esac
1123                 verbose rm -rf Xonotic/temp
1124                 verbose mkdir -p Xonotic/temp
1125                 {
1126                         verbose cd "$src"
1127                         verbose git archive --format=tar HEAD
1128                 } | {
1129                         verbose cd Xonotic/temp
1130                         verbose tar xvf -
1131                 }
1132                 verbose cd Xonotic/temp
1133                 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
1134                         verbose cp ../source/progs.dat .
1135                         verbose cp ../source/csprogs.dat .
1136                         verbose cp ../source/menu.dat .
1137                         verbose rm -rf qcsrc
1138                         gv=`grep "^gameversion " "defaultXonotic.cfg" | awk '{ print $2 }'`
1139                         major=$(($gv / 10000))
1140                         minor=$(($gv / 100 - $major * 100))
1141                         patch=$(($gv - $major * 10000 - $minor * 100))
1142                         verbose sed -i "
1143                                 s/^set g_xonoticversion [^ ]* /set g_xonoticversion $major.$minor.$patch /;
1144                                 s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
1145                                 s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
1146                         " defaultXonotic.cfg
1147                 fi
1148                 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
1149                         for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
1150                                 if [ -f "$X" ]; then
1151                                         verbose unzip "$X"
1152                                 fi
1153                         done
1154                 fi
1155                 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
1156                 verbose zip -9yr "../../$dst" .
1157                 verbose cd ../..
1158                 verbose rm -rf Xonotic/temp
1159                 ;;
1160         release-buildpk3s)
1161                 stamp=`cat Xonotic/stamp.txt`
1162                 src=$1
1163                 shift
1164                 dst=${src%.pk3dir}
1165                 case "$dst" in
1166                         data/xonotic-*)
1167                                 dst="data/xonotic-$stamp-${dst#data/xonotic-}"
1168                                 ;;
1169                         *)
1170                                 dst="$dst-$stamp"
1171                                 ;;
1172                 esac
1173                 while [ "$#" -gt 1 ]; do
1174                         verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
1175                         shift
1176                         shift
1177                 done
1178                 ;;
1179         release-pack)
1180                 verbose "$SELF" release-buildpk3s data/font-nimbussansl.pk3dir             raw ''
1181                 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
1182                 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
1183                 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir                raw ''     low '-low'
1184                 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir                       low ''
1185                 ;;
1186         release-pack-needsx11)
1187                 case "$DISPLAY" in
1188                         '')
1189                                 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
1190                                 ;;
1191                         *)
1192                                 verbose "$SELF" release-pack
1193                                 ;;
1194                 esac
1195                 ;;
1196         release-zip)
1197                 stamp=`cat Xonotic/stamp.txt`
1198                 verbose zip -9yr Xonotic-$stamp-common.zip \
1199                         Xonotic/*.dll \
1200                         Xonotic/source/*/ \
1201                         Xonotic/Docs \
1202                         Xonotic/misc \
1203                         Xonotic/fteqcc \
1204                         Xonotic/server \
1205                         Xonotic/*.app \
1206                         Xonotic/xonotic-* \
1207                         Xonotic/xonotic.exe \
1208                         Xonotic/data/font-nimbussansl-$stamp.pk3
1209                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
1210                 verbose zip -0yr Xonotic-$stamp.zip \
1211                         Xonotic/data/xonotic-$stamp-data.pk3 \
1212                         Xonotic/data/xonotic-$stamp-maps.pk3 \
1213                         Xonotic/data/xonotic-$stamp-music.pk3 \
1214                         Xonotic/data/xonotic-$stamp-nexcompat.pk3
1215                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-low.zip
1216                 verbose zip -0yr Xonotic-$stamp-low.zip \
1217                         Xonotic/data/xonotic-$stamp-data-low.pk3 \
1218                         Xonotic/data/xonotic-$stamp-maps-low.pk3 \
1219                         Xonotic/data/xonotic-$stamp-music-low.pk3
1220                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-lowdds.zip
1221                 verbose zip -0yr Xonotic-$stamp-lowdds.zip \
1222                         Xonotic/data/xonotic-$stamp-data-lowdds.pk3 \
1223                         Xonotic/data/xonotic-$stamp-maps-lowdds.pk3 \
1224                         Xonotic/data/xonotic-$stamp-music-low.pk3
1225                 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
1226                 verbose zip -0yr Xonotic-$stamp-high.zip \
1227                         Xonotic/data/xonotic-$stamp-data-raw.pk3 \
1228                         Xonotic/data/xonotic-$stamp-maps-raw.pk3 \
1229                         Xonotic/data/xonotic-$stamp-music.pk3 \
1230                         Xonotic/data/xonotic-$stamp-nexcompat.pk3
1231                 ;;
1232         release)
1233                 verbose "$SELF" release-prepare
1234                 verbose "$SELF" release-maps
1235                 verbose "$SELF" release-engine
1236                 verbose "$SELF" release-qc
1237                 verbose "$SELF" release-pack-needsx11
1238                 verbose "$SELF" release-zip
1239                 ;;
1240
1241         *)
1242                 echo "Usage:"
1243                 echo "  $SELF pull"
1244                 echo "  $SELF merge"
1245                 echo "  $SELF push [-s]"
1246                 echo "  $SELF branches"
1247                 echo "  $SELF branch [<remote>] <branchname>"
1248                 echo "  $SELF branch <remote> <branchname> <srcbranchname>"
1249                 echo "  $SELF checkout [<remote>] <branchname>"
1250                 echo "  $SELF compile [-c|-n] [<client>] <options>"
1251                 echo "  $SELF run [<client>] <options>"
1252                 echo "  $SELF each <command>"
1253                 ;;
1254 esac