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