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