]> git.xonotic.org Git - xonotic/xonotic.git/blob - all
050516b519b871edd3364f5d4f9356bab770f435
[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 fix_git_config()
265 {
266         verbose git config core.autocrlf input
267         if [ -z "`git config push.default`" ]; then
268                 verbose git config push.default current # or is tracking better?
269         fi
270 }
271
272 case "$cmd" in
273         fix_upstream_rebase)
274                 for d in $repos; do
275                         enter "$d0/$d" verbose
276                         verbose fix_upstream_rebase_mergefail && verbose fix_upstream_rebase_mergeok
277                 done
278                 ;;
279         update|pull)
280                 allow_pull=true
281                 if [ x"$1" = x"-N" ]; then
282                         allow_pull=false
283                 fi
284                 for d in $repos; do
285                         url=`repourl "$d"`
286                         branch=`repobranch "$d"`
287                         if [ -d "$d0/$d" ]; then
288                                 if $allow_pull; then
289                                         enter "$d0/$d" verbose
290                                         fix_git_config
291                                         verbose git config remote.origin.url "$url"
292                                         verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
293                                         r=`git symbolic-ref HEAD`
294                                         r=${r#refs/heads/}
295                                         if git config branch.$r.remote >/dev/null 2>&1; then
296                                                 if ! verbose git pull; then
297                                                         fix_upstream_rebase_mergefail || true
298                                                         check_mergeconflict "$d"
299                                                         echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
300                                                         read -r DUMMY
301                                                 else
302                                                         fix_upstream_rebase_mergeok || true
303                                                 fi
304                                         fi
305
306                                         cd "$d00"
307                                         checkself "$cmd" "$@"
308                                         cd "$d0/$d"
309                                         verbose git remote prune origin
310                                         cd "$d0"
311                                 fi
312                         else
313                                 verbose git clone "$url" "$d0/$d"
314                                 enter "$d0/$d" verbose
315                                 fix_git_config
316                                 if [ "$branch" != "master" ]; then
317                                         verbose git checkout --track -b "$branch" origin/"$branch"
318                                 fi
319                                 cd "$d0"
320                         fi
321                 done
322                 ;;
323         update-maps)
324                 misc/tools/xonotic-map-compiler-autobuild download
325                 ;;
326         checkout|switch)
327                 checkoutflags=
328                 if [ x"$1" = x"-f" ]; then
329                         checkoutflags=-f
330                         shift
331                 fi
332                 remote=$1
333                 branch=$2
334                 if [ -z "$branch" ]; then
335                         case "$remote" in
336                                 origin/*)
337                                         branch=${remote#origin/}
338                                         remote=origin
339                                         ;;
340                                 *)
341                                         branch=$remote
342                                         remote=origin
343                                         ;;
344                         esac
345                 fi
346                 exists=false
347                 for d in $repos; do
348                         enter "$d0/$d" verbose
349                         b=$branch
350                         if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
351                                 exists=true
352                                 verbose git checkout $checkoutflags "$b"
353                         elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
354                                 exists=true
355                                 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
356                         else
357                                 b=`repobranch "$d"`
358                                 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
359                                         exists=true
360                                         verbose git checkout $checkoutflags "$b"
361                                 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
362                                         exists=true
363                                         verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
364                                 else
365                                         echo "WTF? Not even branch $b doesn't exist in $d"
366                                         exit 1
367                                 fi
368                         fi
369                         cd "$d00"
370                         checkself "$cmd" "$@"
371                         cd "$d0"
372                 done
373                 if ! $exists; then
374                         echo "The requested branch was not found in any repository."
375                 fi
376                 exec "$SELF" branch
377                 ;;
378         branch)
379                 remote=$1
380                 branch=$2
381                 srcbranch=$3
382                 if [ -z "$branch" ]; then
383                         branch=$remote
384                         remote=origin
385                 fi
386                 if [ -z "$branch" ]; then
387                         for d in $repos; do
388                                 enter "$d0/$d"
389                                 r=`git symbolic-ref HEAD`
390                                 r=${r#refs/heads/}
391                                 echo "$d is at $r"
392                                 cd "$d0"
393                         done
394                 else
395                         for d in $repos; do
396                                 dv=`visible_repo_name "$d"`
397                                 enter "$d0/$d" verbose
398                                 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
399                                         echo "Already having this branch in $dv."
400                                 else
401                                         if yesno "Branch in $dv?"; then
402                                                 if [ -n "$srcbranch" ]; then
403                                                         b=$srcbranch
404                                                 else
405                                                         b=origin/"`repobranch "$d"`"
406                                                         verbose git fetch origin || true
407                                                 fi
408                                                 # TODO do this without pushing
409                                                 verbose git checkout -b "$branch" "$b"
410                                                 verbose git config "branch.$branch.remote" "$remote"
411                                                 verbose git config "branch.$branch.merge" "refs/heads/$branch"
412                                         fi
413                                 fi
414                                 cd "$d0"
415                         done
416                         "$SELF" branch
417                 fi
418                 ;;
419         branches)
420                 for d in $repos; do
421                         cd "$d0/$d" # am in a pipe, shouldn't use enter
422                         git branch -a -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
423                         cd "$d0"
424                 done | {
425                         branches_list=
426                         # branches_repos_*=
427                         while read -r d BRANCH REV UPSTREAM TEXT; do
428                                 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
429                                         continue
430                                 fi
431                                 case "$UPSTREAM" in
432                                         \[*)
433                                                 UPSTREAM=${UPSTREAM#\[}
434                                                 UPSTREAM=${UPSTREAM%\]}
435                                                 UPSTREAM=${UPSTREAM%:*}
436                                                 ;;
437                                         *)
438                                                 TEXT="$UPSTREAM $TEXT"
439                                                 UPSTREAM=
440                                                 ;;
441                                 esac
442                                 if [ x"$REV" = x"->" ]; then
443                                         continue
444                                 fi
445                                 BRANCH=${BRANCH#remotes/}
446                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
447                                 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
448                                 eval "r=\$branches_repos_$ID"
449                                 case "$UPSTREAM" in
450                                         '')
451                                                 r="$r $d"
452                                                 ;;
453                                         *)
454                                                 r="$r $d:$UPSTREAM"
455                                                 ;;
456                                 esac
457                                 eval "branches_repos_$ID=\$r"
458                         done
459                         echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
460                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
461                                 eval "r=\$branches_repos_$ID"
462                                 printf "%-60s %s\n" "$BRANCH" "$r"
463                                 #echo "$BRANCH: $r"
464                         done
465                 }
466                 ;;
467         merge)
468                 for d in $repos; do
469                         dv=`visible_repo_name "$d"`
470                         enter "$d0/$d" verbose
471                         r=`git symbolic-ref HEAD`
472                         r=${r#refs/heads/}
473                         if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
474                                 # we have uncommitted changes
475                                 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
476                                         if ! verbose git merge origin/"`repobranch "$d"`"; then
477                                                 check_mergeconflict "$d"
478                                                 exit 1 # this should ALWAYS be fatal
479                                         fi
480                                 fi
481                         fi
482                         cd "$d0"
483                 done
484                 ;;
485         push|commit)
486                 submit=$1
487                 for d in $repos; do
488                         dv=`visible_repo_name "$d"`
489                         enter "$d0/$d" verbose
490                         r=`git symbolic-ref HEAD`
491                         r=${r#refs/heads/}
492                         diffdata=`git diff --color HEAD`
493                         if [ -n "$diffdata" ]; then
494                                 # we have uncommitted changes
495                                 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?" 'echo "$diffdata" | less -r'; then
496                                         verbose git commit -a
497                                 fi
498                         fi
499                         rem=`git config "branch.$r.remote" || echo origin`
500                         bra=`git config "branch.$r.merge" || echo "$r"`
501                         upstream="$rem/${bra#refs/heads/}"
502                         if ! git rev-parse "$upstream" >/dev/null 2>&1; then
503                                 upstream="origin/`repobranch "$d"`"
504                         fi
505                         logdata=`git log --color "$upstream".."$r"`
506                         if [ -n "$logdata" ]; then
507                                 if yesno "Push \"$r\" in $dv?" 'echo "$logdata" | less -r'; then
508                                         verbose git push "$rem" HEAD
509                                 fi
510                         fi
511                         if [ x"$submit" = x"-s" ]; then
512                                 case "$r" in
513                                         */*)
514                                                 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
515                                                 ;;
516                                 esac
517                         fi
518                         cd "$d0"
519                 done
520                 ;;
521         compile)
522                 if [ -n "$WE_HATE_OUR_USERS" ]; then
523                         TARGETS="sv-debug cl-debug"
524                         if [ -z "$CC" ]; then
525                                 export CC=gcc
526                         fi
527                 elif [ x"`uname`" = x"Darwin" ]; then
528                         case "`uname -r`" in
529                                 ?.*)
530                                         TARGETS="sv-debug cl-debug sdl-debug"
531                                         ;;
532                                 *)
533                                         # AGL cannot be compiled on systems with a kernel > 10.x (Snow Leopard)
534                                         TARGETS="sv-debug sdl-debug"
535                                         ;;
536                         esac
537                         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"
538                 else
539                         TARGETS="sv-debug cl-debug sdl-debug"
540                 fi
541                 case "$1" in
542                         -c)
543                                 cleandp=true
544                                 cleanqcc=true
545                                 cleanqc=true
546                                 shift
547                                 ;;
548                         -n)
549                                 cleandp=false
550                                 cleanqcc=false
551                                 cleanqc=false
552                                 shift
553                                 ;;
554                         *)
555                                 cleandp=false
556                                 cleanqcc=false
557                                 cleanqc=true # version info
558                                 ;;
559                 esac
560                 if [ $# -gt 0 ] && [ x"$1" = x"" ]; then
561                         # if we give the command make the arg "", it will surely fail (invalid filename),
562                         # so better handle it as an empty client option
563                         BAD_TARGETS=" "
564                         shift
565                 elif [ -n "$1" ]; then
566                         BAD_TARGETS=
567                         TARGETS_SAVE=$TARGETS
568                         TARGETS=
569                         for X in $1; do
570                                 case "$X" in
571                                         sdl)
572                                                 TARGETS="$TARGETS sdl-debug"
573                                                 ;;
574                                         glx|agl|wgl)
575                                                 TARGETS="$TARGETS cl-debug"
576                                                 ;;
577                                         dedicated)
578                                                 TARGETS="$TARGETS sv-debug"
579                                                 ;;
580                                         *)
581                                                 BAD_TARGETS="$BAD_TARGETS $X"
582                                                 ;;
583                                 esac
584                         done
585                         if [ -n "$TARGETS" ]; then # at least a valid client
586                                 shift
587                         else # no valid client, let's assume this option is not meant to be a client then
588                                 TARGETS=$TARGETS_SAVE
589                                 BAD_TARGETS=
590                         fi
591                 fi
592                 if [ -z "$MAKEFLAGS" ]; then
593                         if [ -f /proc/cpuinfo ]; then
594                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
595                                 if [ $ncpus -gt 1 ]; then
596                                         MAKEFLAGS=-j$ncpus
597                                 fi
598                         fi
599                         if [ -n "$WE_HATE_OUR_USERS" ]; then
600                                 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw LIB_JPEG= CFLAGS_LIBJPEG="
601                         fi
602                 fi
603
604                 enter "$d0/fteqcc" verbose
605                 if $cleanqcc; then
606                         verbose make $MAKEFLAGS clean
607                 fi
608                 verbose make $MAKEFLAGS
609
610                 enter "$d0/data/xonotic-data.pk3dir" verbose
611                 if $cleanqc; then
612                         verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
613                 fi
614                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
615
616                 enter "$d0/darkplaces" verbose
617                 if [ x"$BAD_TARGETS" = x" " ]; then
618                         echo "Warning: invalid empty client, default clients will be used."
619                 fi
620                 if $cleandp; then
621                         verbose make $MAKEFLAGS clean
622                 fi
623                 for T in $TARGETS; do
624                         verbose make $MAKEFLAGS "$@" "$T"
625                 done
626                 for T in $BAD_TARGETS; do
627                         echo "Warning: discarded invalid client $T."
628                 done
629
630                 verbose "$SELF" update-maps
631                 ;;
632         run)
633                 if [ -n "$WE_HATE_OUR_USERS" ]; then
634                         client=
635                         export PATH="$d0/misc/buildfiles/win32:$PATH"
636                 elif [ x"`uname`" = x"Darwin" ]; then
637                         export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
638                         export DYLD_FRAMEWORK_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
639                         client=-sdl
640                 else
641                         client=-sdl
642                 fi
643                 case "$1" in
644                         sdl|glx|agl|dedicated)
645                                 client=-$1
646                                 shift
647                                 ;;
648                         wgl)
649                                 client=
650                                 shift
651                                 ;;
652                 esac
653                 if ! [ -x "darkplaces/darkplaces$client" ]; then
654                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
655                                 client=$client.exe
656                         else
657                                 echo "Client darkplaces/darkplaces$client not found, aborting"
658                                 exit 1
659                         fi
660                 fi
661                 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic -mygames "$@"
662
663                 # if pulseaudio is running: USE IT
664                 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
665                         if ps -C pulseaudio >/dev/null; then
666                                 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
667                                         export SDL_AUDIODRIVER=pulse
668                                 fi
669                         fi
670                 fi
671
672                 if [ -n "$USE_GDB" ]; then
673                         set -- gdb --args "$@"
674                 fi
675                 "$@"
676                 ;;
677         each|foreach)
678                 keep_going=false
679                 if [ x"$1" = x"-k" ]; then
680                         keep_going=true
681                         shift
682                 fi
683                 for d in $repos; do
684                         if verbose cd "$d0/$d"; then
685                                 if $keep_going; then
686                                         verbose "$@" || true
687                                 else
688                                         verbose "$@"
689                                 fi
690                                 cd "$d0"
691                         fi
692                 done
693                 ;;
694         save-patches)
695                 outfile=$1
696                 patchdir=`mktemp -d -t save-patches.XXXXXX`
697                 for d in $repos; do
698                         enter "$d0/$d" verbose
699                         git branch -v -v | cut -c 3- | {
700                                 i=0
701                                 while read -r BRANCH REV UPSTREAM TEXT; do
702                                         case "$UPSTREAM" in
703                                                 \[*)
704                                                         UPSTREAM=${UPSTREAM#\[}
705                                                         UPSTREAM=${UPSTREAM%\]}
706                                                         UPSTREAM=${UPSTREAM%:*}
707                                                         TRACK=true
708                                                         ;;
709                                                 *)
710                                                         UPSTREAM=origin/"`repobranch "$d"`"
711                                                         TRACK=false
712                                                         ;;
713                                         esac
714                                         if [ x"$REV" = x"->" ]; then
715                                                 continue
716                                         fi
717                                         if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
718                                                 echo "$d" > "$patchdir/$i/info.txt"
719                                                 echo "$BRANCH" >> "$patchdir/$i/info.txt"
720                                                 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
721                                                 echo "$TRACK" >> "$patchdir/$i/info.txt"
722                                                 i=$(($i+1))
723                                         else
724                                                 rm -rf "$patchdir/$i"
725                                         fi
726                                 done
727                         }
728                 done
729                 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
730                 rm -rf "$patchdir"
731                 ;;
732         restore-patches)
733                 infile=$1
734                 patchdir=`mktemp -d -t restore-patches.XXXXXX`
735                 ( cd "$patchdir" && tar xvzf - ) < "$infile"
736                 # detach the head
737                 for P in "$patchdir"/*/info.txt; do
738                         D=${P%/info.txt}
739                         exec 3<"$P"
740                         read -r d <&3
741                         read -r BRANCH <&3
742                         read -r UPSTREAM <&3
743                         read -r TRACK <&3
744                         verbose git checkout HEAD^0
745                         verbose git branch -D "$BRANCH"
746                         if [ x"$TRACK" = x"true" ]; then
747                                 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
748                         else
749                                 verbose git branch -b "$BRANCH" "$UPSTREAM"
750                         fi
751                         verbose git am "$D"
752                 done
753                 rm -rf "$patchdir"
754                 ;;
755         admin-merge)
756                 branch=$1
757                 t=`mktemp`
758                 report=""
759                 reportecho()
760                 {
761                         report=$report"$*$LF"
762                         echo "$*"
763                 }
764                 reportecho4()
765                 {
766                         report=$report"    $*$LF"
767                         echo "    $*"
768                 }
769                 reportdo4()
770                 {
771                         o=`"$@" | sed 's/^/    /' || true`
772                         reportecho "$o"
773                 }
774                 for d in $repos; do
775                         enter "$d0/$d" verbose
776                         base="`repobranch "$d"`"
777                         reportecho "In $d:"
778                         for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
779                                 case "${ref#refs/remotes/origin/}" in
780                                         "$base")
781                                                 continue
782                                                 ;;
783                                         HEAD|master)
784                                                 continue
785                                                 ;;
786                                         */*)
787                                                 ;;
788                                         *)
789                                                 continue
790                                                 ;;
791                                 esac
792                                 if [ -n "$branch" ]; then
793                                         if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
794                                                 continue
795                                         fi
796                                 fi
797                                 case "$base" in
798                                         master)
799                                                 realbase=$base
800                                                 ;;
801                                         *)
802                                                 l0=`git rev-list "$base".."$ref" | wc -l`
803                                                 l1=`git rev-list master.."$ref" | wc -l`
804                                                 if [ $l0 -gt $l1 ]; then
805                                                         realbase=master
806                                                 else
807                                                         realbase=$base
808                                                 fi
809                                                 ;;
810                                 esac
811                                 reportecho "  Branch $ref:"
812                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
813                                 logdata=`git log --color "$realbase".."$ref"`
814                                 if [ -z "$logdata" ]; then
815                                         reportecho4 "--> not merging, no changes vs master"
816                                         if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
817                                                 git push origin :"${ref#refs/remotes/origin/}"
818                                                 reportecho4 "--> branch deleted"
819                                         fi
820                                 else
821                                         diffdata=`git diff --color --find-copies-harder --ignore-space-change "$realbase"..."$ref"`
822                                         if [ -z "$diffdata" ]; then
823                                                 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
824                                                 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
825                                                         git push origin :"${ref#refs/remotes/origin/}"
826                                                         reportecho4 "--> branch deleted"
827                                                 fi
828                                         elif [ -z "$branch" ] && [ -n "$note" ]; then
829                                                 reportdo4 echo "$note"
830                                                 reportecho4 "--> not merging, already had this one rejected before"
831                                         elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
832                                                 git checkout "$realbase"
833                                                 org=`git rev-parse HEAD`
834                                                 if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
835                                                         git reset --hard "$org"
836                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
837                                                         reportdo4 cat "$t"
838                                                         reportecho4 "--> merge failed"
839                                                 elif ! "$SELF" compile -n 2>&1 | tee "$t"; then
840                                                         git reset --hard "$org"
841                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
842                                                         reportdo4 cat "$t"
843                                                         reportecho4 "--> compile failed"
844                                                 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
845                                                         git reset --hard "$org"
846                                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
847                                                         note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
848                                                         if [ x"$note" = x"del" ]; then
849                                                                 git push origin :"${ref#refs/remotes/origin/}"
850                                                                 reportecho4 "--> test failed, branch deleted"
851                                                         elif [ -n "$note" ]; then
852                                                                 reportdo4 echo "$note"
853                                                                 reportecho4 "--> test failed"
854                                                         else
855                                                                 reportecho4 "--> test failed, postponed"
856                                                         fi
857                                                 else
858                                                         echo "MERGING"
859                                                         case ",`repoflags "$d"`," in
860                                                                 *,svn,*)
861                                                                         # we do quite a mess here... luckily we know $org
862                                                                         git fetch # svn needs to be current
863                                                                         git rebase -i --onto origin/master "$org"
864                                                                         git svn dcommit --add-author-from
865                                                                         git reset --hard "$org"
866                                                                         ;;
867                                                                 *)
868                                                                         git push origin HEAD
869                                                                         ;;
870                                                         esac
871                                                         reportecho4 "--> MERGED"
872                                                         if yesno "Delete original branch \"$ref\"?"; then
873                                                                 git push origin :"${ref#refs/remotes/origin/}"
874                                                                 reportecho4 "--> branch deleted"
875                                                         fi
876                                                 fi
877                                         else
878                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
879                                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
880                                                 if [ x"$note" = x"del" ]; then
881                                                         git push origin :"${ref#refs/remotes/origin/}"
882                                                         reportecho4 "--> branch deleted"
883                                                 elif [ -n "$note" ]; then
884                                                         reportdo4 echo "$note"
885                                                         reportecho4 "--> rejected"
886                                                 else
887                                                         reportecho4 "--> postponed"
888                                                 fi
889                                         fi
890                                 fi
891                                 reportecho ""
892                         done
893                         reportecho ""
894                 done
895                 rm -f "$t"
896                 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
897                 ;;
898         clean)
899                 force=false
900                 if [ x"$1" = x"-f" ]; then
901                         force=true
902                 fi
903                 for d in $repos; do
904                         enter "$d0/$d" verbose
905                         if $force; then
906                                 verbose git checkout-index -fa
907                         fi
908                         case "$d" in
909                                 .)
910                                         verbose git clean -df
911                                         ;;
912                                 *)
913                                         verbose git clean -xdf
914                                         ;;
915                         esac
916                 done
917                 ;;
918
919         # release building goes here
920         release-prepare)
921                 #"$SELF" each git clean -fxd
922                 case "$RELEASETYPE" in
923                         beta)
924                                 msg "Building a BETA"
925                                 ;;
926                         release)
927                                 msg "Building a RELEASE"
928                                 ;;
929                         *)
930                                 msg "Must either set RELEASETYPE=beta or RELEASETYPE=release"
931                                 exit 1
932                                 ;;
933                 esac
934                 verbose rm -rf Xonotic Xonotic*.zip
935                 verbose mkdir -p Xonotic
936                 verbose date +%Y%m%d > Xonotic/stamp.txt
937                 verbose git archive --format=tar HEAD -- Docs misc server xonotic-linux-glx.sh xonotic-linux-sdl.sh misc/buildfiles | {
938                         verbose cd Xonotic
939                         verbose mkdir data fteqcc source source/darkplaces source/fteqcc
940                         verbose tar xvf -
941                         verbose rm -rf misc/builddeps
942                         verbose mv misc/buildfiles/win32/* . || true
943                         verbose mv misc/buildfiles/win64 bin64 || true
944                         verbose mv misc/buildfiles/osx/* . || true
945                         verbose rm -rf misc/buildfiles
946                 }
947                 {
948                         verbose cd darkplaces
949                         verbose git archive --format=tar HEAD
950                 } | {
951                         verbose cd Xonotic/source/darkplaces
952                         verbose tar xvf -
953                 }
954                 {
955                         verbose cd fteqcc
956                         verbose git archive --format=tar HEAD
957                 } | {
958                         verbose cd Xonotic/source/fteqcc
959                         verbose tar xvf -
960                 }
961                 {
962                         verbose cd data/xonotic-data.pk3dir
963                         verbose git archive --format=tar HEAD -- qcsrc Makefile
964                 } | {
965                         verbose cd Xonotic/source
966                         verbose tar xvf -
967                 }
968                 ;;
969         release-compile-run)
970                 host=$1
971                 buildpath=$2
972                 maketargets=$3
973                 makeflags=$4
974                 srcdir=$5
975                 targetfiles=$6
976                 if [ -n "$targetfiles" ]; then
977                         case " $HOSTS_THAT_ARE_MYSELF " in
978                                 *\ $host\ *)
979                                         verbose rsync --delete -zvaSHP "$srcdir"/ "$buildpath/"
980                                         verbose eval make -C "$buildpath" clean $maketargets $makeflags
981                                         for f in $targetfiles; do
982                                                 verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
983                                         done
984                                         ;;
985                                 *)
986                                         verbose rsync --delete -zvaSHP "$srcdir"/ "$host:$buildpath/"
987                                         verbose ssh "$host" ". ~/.profile && cd $buildpath && make clean $maketargets $makeflags"
988                                         for f in $targetfiles; do
989                                                 verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
990                                         done
991                                         ;;
992                         esac
993                         # now rebrand the binaries...
994                         for f in $targetfiles; do
995                                 verbose "$d0/misc/tools/rebrand-darkplaces-engine.sh" "${XONOTIC_BRAND:-$d0/misc/tools/xonotic.brand}" "${f##*:}" || true
996                         done
997                 fi
998                 ;;
999         release-compile)
1000                 suffix=$1
1001                 makeflags=$2
1002                 fteqcc_maketargets=$3
1003                 fteqcc_files=$4
1004                 darkplaces_maketargets=$5
1005                 darkplaces_files=$6
1006                 verbose "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "Xonotic/source/fteqcc" "$fteqcc_files"
1007                 verbose "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$darkplaces_files"
1008                 ;;
1009         release-engine-win32)
1010                 verbose "$SELF" release-compile win32 \
1011                         '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' \
1012                         win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
1013                         release 'darkplaces.exe:Xonotic/xonotic.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
1014                 ;;
1015         release-engine-win64)
1016                 verbose "$SELF" release-compile win64 \
1017                         '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' \
1018                         win 'fteqcc.exe:Xonotic/fteqcc/fteqcc-x64.exe' \
1019                         'sv-release cl-release' 'darkplaces.exe:Xonotic/xonotic-x64.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated-x64.exe'
1020                         # release 'darkplaces.exe:Xonotic/xonotic-x64.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl-x64.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated-x64.exe'
1021                 ;;
1022         release-engine-osx-sv-sdl)
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 -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"' \
1026                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
1027                         'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
1028                 ;;
1029         release-engine-osx-agl)
1030                 # gcc on OSX is buggy, needs -fno-reorder-blocks for a release build to succeed
1031                 verbose "$SELF" release-compile osx \
1032                         '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"' \
1033                         '' '' \
1034                         'cl-release' 'darkplaces-glx:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-agl-bin'
1035                 ;;
1036         release-engine-osx)
1037                 verbose "$SELF" release-engine-osx-sv-sdl
1038                 verbose "$SELF" release-engine-osx-agl
1039                 ;;
1040         release-engine-linux32)
1041                 verbose "$SELF" release-compile linux32 \
1042                         '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' \
1043                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
1044                         release 'darkplaces-glx:Xonotic/xonotic-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux32-dedicated'
1045                 ;;
1046         release-engine-linux64)
1047                 verbose "$SELF" release-compile linux64 \
1048                         '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' \
1049                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
1050                         release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
1051                 ;;
1052         release-engine)
1053                 verbose "$SELF" release-engine-win64
1054                 verbose "$SELF" release-engine-osx
1055                 verbose "$SELF" release-engine-win32
1056                 verbose "$SELF" release-engine-linux32
1057                 verbose "$SELF" release-engine-linux64
1058                 ;;
1059         release-maps)
1060                 verbose "$SELF" update-maps
1061                 ;;
1062         release-qc)
1063                 case "$RELEASETYPE" in
1064                         beta)
1065                                 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 clean all
1066                                 ;;
1067                         release)
1068                                 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 FTEQCCFLAGS_WATERMARK= clean all
1069                                 ;;
1070                 esac
1071                 verbose rm -f Xonotic/source/*/fteqcc.log
1072                 ;;
1073         release-buildpk3-transform-raw)
1074                 dir=$1
1075                 ;;
1076         release-buildpk3-transform-normal)
1077                 dir=$1
1078                 verbose cd "$dir"
1079                 # texture: convert to jpeg and dds
1080                 verbose export do_jpeg=true
1081                 verbose export jpeg_qual_rgb=95
1082                 verbose export jpeg_qual_a=99
1083                 verbose export do_dds=true
1084                 verbose export dds_flags=
1085                 verbose export do_ogg=false
1086                 verbose export del_src=true
1087                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1088                 ;;
1089         release-buildpk3-transform-low)
1090                 dir=$1
1091                 verbose cd "$dir"
1092                 # texture: convert to jpeg and dds
1093                 # music: reduce bitrate
1094                 verbose export do_jpeg=true
1095                 verbose export jpeg_qual_rgb=80
1096                 verbose export jpeg_qual_a=95
1097                 verbose export do_dds=false
1098                 verbose export do_ogg=true
1099                 verbose export ogg_qual=1
1100                 verbose export del_src=true
1101                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1102                 ;;
1103         release-buildpk3-transform-lowdds)
1104                 dir=$1
1105                 verbose cd "$dir"
1106                 # texture: convert to jpeg and dds
1107                 # music: reduce bitrate
1108                 verbose export do_jpeg=false
1109                 verbose export do_jpeg_if_not_dds=true
1110                 verbose export jpeg_qual_rgb=80
1111                 verbose export jpeg_qual_a=95
1112                 verbose export do_dds=true
1113                 verbose export dds_flags=
1114                 verbose export do_ogg=true
1115                 verbose export ogg_qual=1
1116                 verbose export del_src=true
1117                 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1118                 ;;
1119         release-buildpk3)
1120                 src=$1
1121                 dst=$2
1122                 transform=$3
1123                 case "$dst" in
1124                         /*)
1125                                 ;;
1126                         */)
1127                                 dst="$PWD/$dst"
1128                                 ;;
1129                 esac
1130                 verbose rm -rf Xonotic/temp
1131                 verbose mkdir -p Xonotic/temp
1132                 {
1133                         verbose cd "$src"
1134                         verbose git archive --format=tar HEAD
1135                 } | {
1136                         verbose cd Xonotic/temp
1137                         verbose tar xvf -
1138                 }
1139                 verbose cd Xonotic/temp
1140                 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
1141                         verbose cp ../source/progs.dat .
1142                         verbose cp ../source/csprogs.dat .
1143                         verbose cp ../source/menu.dat .
1144                         verbose rm -rf qcsrc
1145                         gv=`grep "^gameversion " "defaultXonotic.cfg" | awk '{ print $2 }'`
1146                         major=$(($gv / 10000))
1147                         minor=$(($gv / 100 - $major * 100))
1148                         patch=$(($gv - $major * 10000 - $minor * 100))
1149                         verbose sed -i "
1150                                 s/^set g_xonoticversion [^ ]* /set g_xonoticversion $major.$minor.$patch /;
1151                                 s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
1152                                 s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
1153                         " defaultXonotic.cfg
1154                 fi
1155                 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
1156                         for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
1157                                 if [ -f "$X" ]; then
1158                                         verbose unzip "$X"
1159                                 fi
1160                         done
1161                 fi
1162                 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
1163                 verbose zip -9yr "../../$dst" .
1164                 verbose cd ../..
1165                 verbose rm -rf Xonotic/temp
1166                 ;;
1167         release-buildpk3s)
1168                 stamp=`cat Xonotic/stamp.txt`
1169                 src=$1
1170                 shift
1171                 dst=${src%.pk3dir}
1172                 case "$dst" in
1173                         data/xonotic-*)
1174                                 dst="data/xonotic-$stamp-${dst#data/xonotic-}"
1175                                 ;;
1176                         *)
1177                                 dst="$dst-$stamp"
1178                                 ;;
1179                 esac
1180                 while [ "$#" -gt 1 ]; do
1181                         verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
1182                         shift
1183                         shift
1184                 done
1185                 ;;
1186         release-pack)
1187                 verbose "$SELF" release-buildpk3s data/font-nimbussansl.pk3dir             raw ''
1188                 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
1189                 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
1190                 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir                raw ''     low '-low'
1191                 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir                       low ''
1192                 ;;
1193         release-pack-needsx11)
1194                 case "$DISPLAY" in
1195                         '')
1196                                 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
1197                                 ;;
1198                         *)
1199                                 verbose "$SELF" release-pack
1200                                 ;;
1201                 esac
1202                 ;;
1203         release-zip)
1204                 stamp=`cat Xonotic/stamp.txt`
1205                 verbose zip -9yr Xonotic-$stamp-common.zip \
1206                         Xonotic/*.dll \
1207                         Xonotic/source/*/ \
1208                         Xonotic/Docs \
1209                         Xonotic/misc \
1210                         Xonotic/fteqcc \
1211                         Xonotic/server \
1212                         Xonotic/*.app \
1213                         Xonotic/xonotic-* \
1214                         Xonotic/xonotic.exe \
1215                         Xonotic/data/font-nimbussansl-$stamp.pk3
1216                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
1217                 verbose zip -0yr Xonotic-$stamp.zip \
1218                         Xonotic/data/xonotic-$stamp-data.pk3 \
1219                         Xonotic/data/xonotic-$stamp-maps.pk3 \
1220                         Xonotic/data/xonotic-$stamp-music.pk3 \
1221                         Xonotic/data/xonotic-$stamp-nexcompat.pk3
1222                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-low.zip
1223                 verbose zip -0yr Xonotic-$stamp-low.zip \
1224                         Xonotic/data/xonotic-$stamp-data-low.pk3 \
1225                         Xonotic/data/xonotic-$stamp-maps-low.pk3 \
1226                         Xonotic/data/xonotic-$stamp-music-low.pk3
1227                 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-lowdds.zip
1228                 verbose zip -0yr Xonotic-$stamp-lowdds.zip \
1229                         Xonotic/data/xonotic-$stamp-data-lowdds.pk3 \
1230                         Xonotic/data/xonotic-$stamp-maps-lowdds.pk3 \
1231                         Xonotic/data/xonotic-$stamp-music-low.pk3
1232                 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
1233                 verbose zip -0yr Xonotic-$stamp-high.zip \
1234                         Xonotic/data/xonotic-$stamp-data-raw.pk3 \
1235                         Xonotic/data/xonotic-$stamp-maps-raw.pk3 \
1236                         Xonotic/data/xonotic-$stamp-music.pk3 \
1237                         Xonotic/data/xonotic-$stamp-nexcompat.pk3
1238                 ;;
1239         release)
1240                 verbose "$SELF" release-prepare
1241                 verbose "$SELF" release-maps
1242                 verbose "$SELF" release-engine
1243                 verbose "$SELF" release-qc
1244                 verbose "$SELF" release-pack-needsx11
1245                 verbose "$SELF" release-zip
1246                 ;;
1247
1248         *)
1249                 echo "Usage:"
1250                 echo "  $SELF pull"
1251                 echo "  $SELF merge"
1252                 echo "  $SELF push [-s]"
1253                 echo "  $SELF branches"
1254                 echo "  $SELF branch [<remote>] <branchname>"
1255                 echo "  $SELF branch <remote> <branchname> <srcbranchname>"
1256                 echo "  $SELF checkout [<remote>] <branchname>"
1257                 echo "  $SELF compile [-c|-n] [<client>] <options>"
1258                 echo "  $SELF run [<client>] <options>"
1259                 echo "  $SELF each <command>"
1260                 ;;
1261 esac