]> de.git.xonotic.org Git - xonotic/xonotic.git/blob - all
1ad861d0f38a6bc3ac32f590a346a6cdcd804393
[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 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                                 tname=
29                                 cp "$SELF" ../all.xonotic.sh
30                                 export WE_HATE_OUR_USERS=1
31                                 exec ../all.xonotic.sh "$@"
32                                 ;;
33                 esac
34                 ;;
35 esac
36
37 msg()
38 {
39         echo "\e[1m$*\e[m"
40 }
41
42 checksum()
43 {
44         if [ -x /usr/bin/md5sum ]; then
45                 /usr/bin/md5sum "$@"
46         elif [ -x /bin/md5sum ]; then
47                 /bin/md5sum "$@"
48         elif [ -x /usr/bin/cksum ]; then
49                 /usr/bin/cksum "$@"
50         else
51                 echo "NOCHECKSUM"
52         fi
53 }
54
55 self=`checksum "$SELF"`
56 checkself()
57 {
58         self_new=`checksum "$SELF"`
59         if [ x"$self" != x"$self_new" ]; then
60                 msg "./all has changed."
61                 if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
62                         msg "Rerunning the requested operation to make sure."
63                         export XONOTIC_FORBID_RERUN_ALL=1
64                         exec "$SELF" "$@"
65                 else
66                         msg "Please try $SELF update, and then retry your requested operation."
67                         exit 1
68                 fi
69         fi
70         return 0
71 }
72
73 verbose()
74 {
75         msg "+ $*"
76         "$@"
77 }
78
79 visible_repo_name()
80 {
81         case "$1" in
82                 .)
83                         echo "the root directory"
84                         ;;
85                 *)
86                         echo "\"$1\""
87                         ;;
88         esac
89 }
90
91 check_mergeconflict()
92 {
93         if git ls-files -u | grep ' 1   '; then
94                 echo
95                 echo "MERGE CONFLICT."
96                 echo "change into the \"$1\" project directory, and then:"
97                 echo "- edit the files mentioned above with your favorite editor,"
98                 echo "  and fix the conflicts (marked with <<<<<<< blocks)"
99                 echo "- for binary files, you can select the files using"
100                 echo "  git checkout --ours or git checkout --theirs"
101                 echo "- when done with a file, 'git add' the file"
102                 echo "- when done, 'git commit'"
103                 echo
104                 exit 1
105         fi
106 }
107
108 yesno()
109 {
110         yesno=
111         while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
112                 eval "$2"
113                 echo "$1"
114                 IFS= read -r yesno
115         done
116         [ x"$yesno" = x"y" ]
117 }
118
119 enter()
120 {
121         $2 cd "$1"
122         check_mergeconflict "$1"
123 }
124
125 repos_urls="
126 .                             |                                                   | master      |
127 data/xonotic-data.pk3dir      |                                                   | master      |
128 data/xonotic-maps.pk3dir      |                                                   | master      |
129 data/xonotic-music.pk3dir     |                                                   | master      |
130 data/xonotic-nexcompat.pk3dir |                                                   | master      |
131 mediasource                   |                                                   | master      |
132 darkplaces                    |                                                   | div0-stable | svn
133 fteqcc                        | git://github.com/Blub/qclib.git                   | master      |
134 div0-gittools                 | git://git.icculus.org/divverent/div0-gittools.git | master      |
135 netradiant                    |                                                   | master      |
136 "
137 # todo: in darkplaces, change repobranch to div0-stable
138
139 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
140
141 base=`git config remote.origin.url`
142 case "$base" in
143         */xonotic.git)
144                 base=${base%xonotic.git}
145                 ;;
146         *)
147                 echo "The main repo is not xonotic.git, what have you done?"
148                 exit 1
149                 ;;
150 esac
151
152 repourl()
153 {
154         t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
155         if [ -n "$t" ]; then
156                 case "$t" in
157                         *://*)
158                                 echo "$t"
159                                 ;;
160                         *)
161                                 echo "$base$t"
162                                 ;;
163                 esac
164         else
165                 if [ x"$1" = x"." ]; then
166                         echo "$base""xonotic.git"
167                 else
168                         echo "$base${1##*/}.git"
169                 fi
170         fi
171 }
172
173 repobranch()
174 {
175         t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
176         if [ -n "$t" ]; then
177                 echo "$t"
178         else
179                 echo "master"
180         fi
181 }
182
183 repoflags()
184 {
185         echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
186         echo "$t"
187 }
188
189 repos=`for d in $repos; do
190         p="${d%dir}"
191         if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! { [ -f "$d.no" ] || [ -f "$p" ]; }; then
192                 echo "$d"
193         fi
194 done`
195
196 if [ "$#" = 0 ]; then
197         set -- help
198 fi
199 cmd=$1
200 shift
201
202 case "$cmd" in
203         update|pull)
204                 allow_pull=true
205                 if [ x"$1" = x"-N" ]; then
206                         allow_pull=false
207                 fi
208                 for d in $repos; do
209                         url=`repourl "$d"`
210                         branch=`repobranch "$d"`
211                         if [ -d "$d0/$d" ]; then
212                                 if $allow_pull; then
213                                         enter "$d0/$d" verbose
214                                         verbose git config remote.origin.url "$url"
215                                         verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
216
217                                         r=`git symbolic-ref HEAD`
218                                         r=${r#refs/heads/}
219                                         if git config branch.$r.remote >/dev/null 2>&1; then
220                                                 if ! verbose git pull; then
221                                                         check_mergeconflict "$d"
222                                                         echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
223                                                         read -r DUMMY
224                                                 fi
225                                         fi
226
227                                         cd "$d00"
228                                         checkself "$cmd" "$@"
229                                         cd "$d0/$d"
230                                         verbose git remote prune origin
231                                         cd "$d0"
232                                 fi
233                         else
234                                 verbose git clone "$url" "$d0/$d"
235                                 enter "$d0/$d" verbose
236                                 if [ "$branch" != "master" ]; then
237                                         verbose git checkout --track -b "$branch" origin/"$branch"
238                                 fi
239                                 cd "$d0"
240                         fi
241                 done
242                 ;;
243         update-maps)
244                 misc/tools/xonotic-map-compiler-autobuild download
245                 ;;
246         checkout|switch)
247                 remote=$1
248                 branch=$2
249                 if [ -z "$branch" ]; then
250                         case "$remote" in
251                                 origin/*)
252                                         branch=${remote#origin/}
253                                         remote=origin
254                                         ;;
255                                 *)
256                                         branch=$remote
257                                         remote=origin
258                                         ;;
259                         esac
260                 fi
261                 exists=false
262                 for d in $repos; do
263                         enter "$d0/$d" verbose
264                         b=$branch
265                         if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
266                                 exists=true
267                                 verbose git checkout "$b"
268                         elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
269                                 exists=true
270                                 verbose git checkout --track -b "$b" "$remote/$b"
271                         else
272                                 b=`repobranch "$d"`
273                                 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
274                                         exists=true
275                                         verbose git checkout "$b"
276                                 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
277                                         exists=true
278                                         verbose git checkout --track -b "$b" "$remote/$b"
279                                 else
280                                         echo "WTF? Not even branch $b doesn't exist in $d"
281                                         exit 1
282                                 fi
283                         fi
284                         cd "$d00"
285                         checkself "$cmd" "$@"
286                         cd "$d0"
287                 done
288                 if ! $exists; then
289                         echo "The requested branch was not found in any repository."
290                 fi
291                 exec "$SELF" branch
292                 ;;
293         branch)
294                 remote=$1
295                 branch=$2
296                 srcbranch=$3
297                 if [ -z "$branch" ]; then
298                         branch=$remote
299                         remote=origin
300                 fi
301                 if [ -z "$branch" ]; then
302                         for d in $repos; do
303                                 enter "$d0/$d"
304                                 r=`git symbolic-ref HEAD`
305                                 r=${r#refs/heads/}
306                                 echo "$d is at $r"
307                                 cd "$d0"
308                         done
309                 else
310                         for d in $repos; do
311                                 dv=`visible_repo_name "$d"`
312                                 enter "$d0/$d" verbose
313                                 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
314                                         echo "Already having this branch in $dv."
315                                 else
316                                         if yesno "Branch in $dv?"; then
317                                                 if [ -n "$srcbranch" ]; then
318                                                         b=$srcbranch
319                                                 else
320                                                         b=origin/"`repobranch "$d"`"
321                                                         verbose git fetch origin || true
322                                                 fi
323                                                 # TODO do this without pushing
324                                                 verbose git checkout -b "$branch" "$b"
325                                                 verbose git config "branch.$branch.remote" "$remote"
326                                                 verbose git config "branch.$branch.merge" "refs/heads/$branch"
327                                         fi
328                                 fi
329                                 cd "$d0"
330                         done
331                         "$SELF" branch
332                 fi
333                 ;;
334         branches)
335                 for d in $repos; do
336                         cd "$d0/$d" # am in a pipe, shouldn't use enter
337                         git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
338                         cd "$d0"
339                 done | {
340                         branches_list=
341                         # branches_repos_*=
342                         while read -r d BRANCH REV UPSTREAM TEXT; do
343                                 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
344                                         continue
345                                 fi
346                                 case "$UPSTREAM" in
347                                         \[*)
348                                                 UPSTREAM=${UPSTREAM#\[}
349                                                 UPSTREAM=${UPSTREAM%\]}
350                                                 UPSTREAM=${UPSTREAM%:*}
351                                                 ;;
352                                         *)
353                                                 TEXT="$UPSTREAM $TEXT"
354                                                 UPSTREAM=
355                                                 ;;
356                                 esac
357                                 if [ x"$REV" = x"->" ]; then
358                                         continue
359                                 fi
360                                 BRANCH=${BRANCH#remotes/}
361                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
362                                 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
363                                 eval "r=\$branches_repos_$ID"
364                                 case "$UPSTREAM" in
365                                         '')
366                                                 r="$r $d"
367                                                 ;;
368                                         *)
369                                                 r="$r $d:$UPSTREAM"
370                                                 ;;
371                                 esac
372                                 eval "branches_repos_$ID=\$r"
373                         done
374                         echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
375                                 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
376                                 eval "r=\$branches_repos_$ID"
377                                 printf "%-60s %s\n" "$BRANCH" "$r"
378                                 #echo "$BRANCH: $r"
379                         done
380                 }
381                 ;;
382         merge)
383                 for d in $repos; do
384                         dv=`visible_repo_name "$d"`
385                         enter "$d0/$d" verbose
386                         r=`git symbolic-ref HEAD`
387                         r=${r#refs/heads/}
388                         if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
389                                 # we have uncommitted changes
390                                 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
391                                         if ! verbose git merge origin/"`repobranch "$d"`"; then
392                                                 check_mergeconflict "$d"
393                                                 exit 1 # this should ALWAYS be fatal
394                                         fi
395                                 fi
396                         fi
397                         cd "$d0"
398                 done
399                 ;;
400         push|commit)
401                 submit=$1
402                 for d in $repos; do
403                         dv=`visible_repo_name "$d"`
404                         enter "$d0/$d" verbose
405                         r=`git symbolic-ref HEAD`
406                         r=${r#refs/heads/}
407                         if git diff HEAD | grep .; then
408                                 # we have uncommitted changes
409                                 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
410                                         verbose git commit -a
411                                 fi
412                         fi
413                         rem=`git config "branch.$r.remote" || echo origin`
414                         bra=`git config "branch.$r.merge" || echo "$r"`
415                         upstream="$rem/$bra"
416                         if ! [ git rev-parse "$upstream" ]; then
417                                 upstream="`repobranch "$d"`"
418                         fi
419                         if git log "$upstream".."$r" | grep .; then
420                                 if yesno "Push \"$r\" in $dv?"; then
421                                         verbose git push "$rem" HEAD
422                                 fi
423                         fi
424                         if [ x"$submit" = x"-s" ]; then
425                                 case "$r" in
426                                         */*)
427                                                 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
428                                                 ;;
429                                 esac
430                         fi
431                         cd "$d0"
432                 done
433                 ;;
434         compile)
435                 if [ -n "$WE_HATE_OUR_USERS" ]; then
436                         TARGETS="sv-debug cl-debug"
437                         if [ -z "$CC" ]; then
438                                 export CC=gcc
439                         fi
440                 elif [ x"`uname`" = x"Darwin" ] && ( [ -d /Library/Frameworks/SDL.framework ] || [ -d $(HOME)/Library/Frameworks/SDL.framework ] ); then
441                         # AGL is broken in Snow Leopard, so let's default to SDL if it is available.
442                         TARGETS="sv-debug sdl-debug"
443                 else
444                         TARGETS="sv-debug cl-debug sdl-debug"
445                 fi
446                 case "$1" in
447                         -c)
448                                 clean=true
449                                 shift
450                                 ;;
451                         *)
452                                 clean=false
453                                 ;;
454                 esac
455                 case "$1" in
456                         sdl)
457                                 TARGETS="sdl-debug"
458                                 shift
459                                 ;;
460                         glx|agl|wgl)
461                                 TARGETS="cl-debug"
462                                 shift
463                                 ;;
464                         dedicated)
465                                 TARGETS="sv-debug"
466                                 shift
467                                 ;;
468                 esac
469                 if [ -z "$MAKEFLAGS" ]; then
470                         if [ -f /proc/cpuinfo ]; then
471                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
472                                 if [ $ncpus -gt 1 ]; then
473                                         MAKEFLAGS=-j$ncpus
474                                 fi
475                         fi
476                         case "`uname`" in
477                                 Linux|*BSD)
478                                         MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
479                                         ;;
480                         esac
481                         if [ -n "$WE_HATE_OUR_USERS" ]; then
482                                 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
483                         fi
484                 fi
485                 enter "$d0/fteqcc" verbose
486                 if $clean; then
487                         verbose make $MAKEFLAGS clean
488                 fi
489                 verbose make $MAKEFLAGS
490                 enter "$d0/data/xonotic-data.pk3dir" verbose
491                 if $clean; then
492                         verbose make $MAKEFLAGS clean
493                 fi
494                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
495                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
496                 enter "$d0/darkplaces" verbose
497                 if $clean; then
498                         verbose make $MAKEFLAGS clean
499                 fi
500                 for T in $TARGETS; do
501                         verbose make $MAKEFLAGS "$@" "$T"
502                 done
503                 verbose "$SELF" update-maps
504                 ;;
505         makebuild)
506                 
507                 ;;
508         run)
509                 if [ -n "$WE_HATE_OUR_USERS" ]; then
510                         client=
511                         export PATH="$d0/misc/buildfiles/w32:$PATH"
512                 elif [ x"`uname`" = x"Darwin" ]; then
513                         export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
514                         client=-sdl
515                 else
516                         client=-sdl
517                 fi
518                 case "$1" in
519                         sdl|glx|agl|dedicated)
520                                 client=-$1
521                                 shift
522                                 ;;
523                         wgl)
524                                 client=
525                                 shift
526                                 ;;
527                 esac
528                 if ! [ -x "darkplaces/darkplaces$client" ]; then
529                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
530                                 client=$client.exe
531                         else
532                                 echo "Client darkplaces/darkplaces$client not found, aborting"
533                                 exit 1
534                         fi
535                 fi
536                 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
537
538                 # if pulseaudio is running: USE IT
539                 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
540                         if ps -C pulseaudio >/dev/null; then
541                                 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
542                                         export SDL_AUDIODRIVER=pulse
543                                 fi
544                         fi
545                 fi
546
547                 if [ -n "$USE_GDB" ]; then
548                         set -- gdb --args "$@"
549                 fi
550                 "$@"
551                 ;;
552         each|foreach)
553                 keep_going=false
554                 if [ x"$1" = x"-k" ]; then
555                         keep_going=true
556                         shift
557                 fi
558                 for d in $repos; do
559                         if verbose cd "$d0/$d"; then
560                                 if $keep_going; then
561                                         verbose "$@" || true
562                                 else
563                                         verbose "$@"
564                                 fi
565                                 cd "$d0"
566                         fi
567                 done
568                 ;;
569         save-patches)
570                 outfile=$1
571                 patchdir=`mktemp -d -t save-patches.XXXXXX`
572                 for d in $repos; do
573                         enter "$d0/$d" verbose
574                         git branch -v -v | cut -c 3- | {
575                                 i=0
576                                 while read -r BRANCH REV UPSTREAM TEXT; do
577                                         case "$UPSTREAM" in
578                                                 \[*)
579                                                         UPSTREAM=${UPSTREAM#\[}
580                                                         UPSTREAM=${UPSTREAM%\]}
581                                                         UPSTREAM=${UPSTREAM%:*}
582                                                         TRACK=true
583                                                         ;;
584                                                 *)
585                                                         UPSTREAM=origin/"`repobranch "$d"`"
586                                                         TRACK=false
587                                                         ;;
588                                         esac
589                                         if [ x"$REV" = x"->" ]; then
590                                                 continue
591                                         fi
592                                         if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
593                                                 echo "$d" > "$patchdir/$i/info.txt"
594                                                 echo "$BRANCH" >> "$patchdir/$i/info.txt"
595                                                 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
596                                                 echo "$TRACK" >> "$patchdir/$i/info.txt"
597                                                 i=$(($i+1))
598                                         else
599                                                 rm -rf "$patchdir/$i"
600                                         fi
601                                 done
602                         }
603                 done
604                 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
605                 rm -rf "$patchdir"
606                 ;;
607         restore-patches)
608                 infile=$1
609                 patchdir=`mktemp -d -t restore-patches.XXXXXX`
610                 ( cd "$patchdir" && tar xvzf - ) < "$infile"
611                 # detach the head
612                 for P in "$patchdir"/*/info.txt; do
613                         D=${P%/info.txt}
614                         exec 3<"$P"
615                         read -r d <&3
616                         read -r BRANCH <&3
617                         read -r UPSTREAM <&3
618                         read -r TRACK <&3
619                         verbose git checkout HEAD^0
620                         verbose git branch -D "$BRANCH"
621                         if [ x"$TRACK" = x"true" ]; then
622                                 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
623                         else
624                                 verbose git branch -b "$BRANCH" "$UPSTREAM"
625                         fi
626                         verbose git am "$D"
627                 done
628                 rm -rf "$patchdir"
629                 ;;
630         admin-merge)
631                 if [ "$#" = 1 ]; then
632                         set -- "${1%%/*}" "${1#*/}"
633                 fi
634                 for d in $repos; do
635                         enter "$d0/$d" verbose
636                         git rev-parse "$1/$2" || continue
637                         # 1. review
638                         {
639                                 git log HEAD.."$1/$2"
640                                 git diff HEAD..."$1/$2"
641                         } | less
642                         if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
643                                 git merge "$1/$2"
644                                 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
645                                         git push origin HEAD
646                                         git push "$1" :"$2"
647                                 else
648                                         git reset --hard HEAD@{1}
649                                 fi
650                         fi
651                 done
652                 ;;
653         admin-merge-2)
654                 t=`mktemp`
655                 report=""
656                 reportecho()
657                 {
658                         report=$report"$*$LF"
659                         echo "$*"
660                 }
661                 reportecho4()
662                 {
663                         report=$report"    $*$LF"
664                         echo "    $*"
665                 }
666                 reportdo4()
667                 {
668                         o=`"$@" | sed 's/^/    /' || true`
669                         reportecho "$o"
670                 }
671                 for d in $repos; do
672                         enter "$d0/$d" verbose
673                         base="`repobranch "$d"`"
674                         reportecho "In $d:"
675                         for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
676                                 case "${ref#refs/remotes/origin/}" in
677                                         "$base")
678                                                 continue
679                                                 ;;
680                                         HEAD|master)
681                                                 continue
682                                                 ;;
683                                 esac
684                                 reportecho "  Branch $ref:"
685                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
686                                 logdata=`git log --color "$base".."$ref"`
687                                 diffdata=`git diff --color --find-copies-harder --ignore-space-change "$base"..."$ref"`
688                                 if [ -z "$logdata" ]; then
689                                         reportecho4 "--> not merging, no changes vs master"
690                                 elif [ -z "$diffdata" ]; then
691                                         reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
692                                         if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
693                                                 git push origin :"${ref#refs/remotes/origin/}"
694                                                 reportecho4 "--> branch deleted"
695                                         fi
696                                 elif [ -n "$note" ]; then
697                                         reportdo4 echo "$note"
698                                         reportecho4 "--> not merging, already had this one rejected before"
699                                 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
700                                         git checkout "$base"
701                                         org=`git rev-parse HEAD`
702                                         if ! git merge "$ref" 2>&1 | tee "$t"; then
703                                                 git reset --hard "$org"
704                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
705                                                 reportdo4 cat "$t"
706                                                 reportecho4 "--> merge failed"
707                                         elif ! "$SELF" compile 2>&1 | tee "$t"; then
708                                                 git reset --hard "$org"
709                                                 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
710                                                 reportdo4 cat "$t"
711                                                 reportecho4 "--> compile failed"
712                                         elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
713                                                 git reset --hard "$org"
714                                                 git notes edit "$ref"
715                                                 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
716                                                 reportdo4 echo "$note"
717                                                 reportecho4 "--> test failed"
718                                         else
719                                                 case ",`repoflags "$d"`," in
720                                                         *,svn,*)
721                                                                 # we do quite a mess here... luckily we know $org
722                                                                 git pull # svn needs to be current
723                                                                 git rebase -i --onto master "$org"
724                                                                 git svn dcommit --add-author-from
725                                                                 git reset --hard "$org"
726                                                                 ;;
727                                                         *)
728                                                                 git push origin HEAD
729                                                                 ;;
730                                                 esac
731                                                 reportecho4 "--> MERGED"
732                                                 if yesno "Delete original branch \"$ref\"?"; then
733                                                         git push origin :"${ref#refs/remotes/origin/}"
734                                                         reportecho4 "--> branch deleted"
735                                                 fi
736                                         fi
737                                 else
738                                         GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
739                                         note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
740                                         if [ -n "$note" ]; then
741                                                 reportdo4 echo "$note"
742                                                 reportecho4 "--> rejected"
743                                         else
744                                                 reportecho4 "--> postponed"
745                                         fi
746                                 fi
747                                 reportecho ""
748                         done
749                         reportecho ""
750                 done
751                 rm -f "$t"
752                 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
753                 ;;
754
755         # release building goes here
756         release-mkdir)
757                 mkdir -p Xonotic/"$1"
758                 ;;
759         release-prepare)
760 #"$SELF" each git clean -fxd
761                 mkdir -p Xonotic
762                 "$SELF" release-copy Docs/
763                 "$SELF" release-copy misc/
764                 "$SELF" release-copy server/
765                 "$SELF" release-copy xonotic-linux-glx.sh
766                 "$SELF" release-copy xonotic-linux-sdl.sh
767                 "$SELF" release-mkdir data
768                 "$SELF" release-mkdir fteqcc
769                 ;;
770         release-copy)
771                 rsync --exclude=.git -vaSHPAX "$1" Xonotic/"$1"
772                 ;;
773         release-compile-run)
774                 host=$1
775                 buildpath=$2
776                 maketargets=$3
777                 makeflags=$4
778                 srcdir=$5
779                 targetfiles=$6
780                 rsync --delete -zvaSHPAX "$srcdir"/ "$host:$buildpath/"
781                 ssh "$host" ". ~/.profile && cd $buildpath && make clean $maketargets $makeflags"
782         for f in $targetfiles; do
783                         rsync -zvaSHPAX "$host:$buildpath/${f%:*}" "${f##*:}"
784                 done
785                 ;;
786         release-compile)
787                 suffix=$1
788                 makeflags=$2
789                 fteqcc_maketargets=$3
790                 fteqcc_files=$4
791                 darkplaces_maketargets=$5
792                 darkplaces_files=$6
793                 "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "fteqcc" "$fteqcc_files"
794                 "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "fteqcc" "$darkplaces_files"
795                 ;;
796         release-engine-win32)
797                 rsync --exclude=.git -vaSHPAX Xonotic/misc/buildfiles/w32/* Xonotic/
798                 "$SELF" release-compile win32 \
799                         '"DP_MAKE_TARGET=mingw CC="$HOME/mingw32/bin/i386-mingw32-gcc -g -DSUPPORTDIRECTX -DUSE_WSPIAPI_H -I$HOME/dxheaders" WINDRES="$HOME/mingw32/bin/i386-mingw32-windres" SDL_CONFIG="$HOME/sdl-win32/SDL-1.2.13/bin/sdl-config"' \
800                         win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
801                         debug 'darkplaces.exe:xonotic.exe darkplaces-sdl.exe:xonotic-sdl.exe darkplaces-dedicated.exe:xonotic-dedicated.exe'
802                 ;;
803         release-engine-osx)
804                 rsync --exclude=.git -vaSHPAX Xonotic/misc/buildfiles/osx/* Xonotic/
805                 "$SELF" release-compile osx \
806                         'CC="gcc -g -arch i386 -arch ppc -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"' \
807                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
808                         sdl-debug 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin'
809                 ;;
810         release-engine-linux32)
811                 "$SELF" release-compile linux32 \
812                         'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=$HOME/modplug-i386/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/jpeg7/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/jpeg7/include"' \
813                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
814                         debug 'darkplaces-glx:Xonotic/xonotic-linux-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux-linux32-dedicated'
815                 ;;
816         release-engine-linux64)
817                 "$SELF" release-compile linux64 \
818                         'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=$HOME/modplug-x86_64/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/jpeg7/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/jpeg7/include"' \
819                         all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
820                         debug 'darkplaces-glx:Xonotic/xonotic-linux-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux-linux64-dedicated'
821                 ;;
822         release-engine)
823                 "$SELF" release-engine-win32
824                 "$SELF" release-engine-osx
825                 "$SELF" release-engine-linux32
826                 "$SELF" release-engine-linux64
827                 ;;
828         release-maps)
829                 "$SELF" update-maps
830                 for X in data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
831                         if [ -f "$X" ]; then
832                                 cd Xonotic/data/xonotic-maps.pk3dir
833                                 unzip ../../../"$X"
834                                 cd ../../..
835                         fi
836                 done
837                 ;;
838         release-finish)
839                 # version numnber and stuff like that
840                 ;;
841         release-buildpk3-transform-raw)
842                 ;;
843         release-buildpk3-transform-normal)
844                 # texture: convert to jpeg
845                 ;;
846         release-buildpk3-transform-low)
847                 # texture: convert to jpeg and downscale
848                 # music: reduce bitrate
849                 ;;
850         release-buildpk3)
851                 src=$1
852                 dst=$2
853                 transform=$3
854                 case "$dst" in
855                         /*)
856                                 ;;
857                         */)
858                                 dst="$PWD/$dst"
859                                 ;;
860                 esac
861                 rm -rf Xonotic/temp
862                 rsync --exclude=.git -vaSHPAX "$src"/ "Xonotic/temp"
863                 "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
864                 7za a -tzip -mx=9 "$dst" .
865                 rm -rf Xonotic/temp
866                 ;;
867         release-buildpk3s)
868                 src=$1
869                 shift
870                 while [ "$#" -gt 1 ]; do
871                         "$SELF" release-buildpk3 "$src" "Xonotic/${src%.pk3dir}$2.pk3" "$1"
872                 done
873                 rm -rf "$src"
874                 ;;
875         release-pack)
876 #"$SELF" release-buildpk3s data/font-dejavu.pk3dir                  raw ''
877 #"$SELF" release-buildpk3s data/xonotic-data.pk3dir       normal '' raw '-raw' low '-low'
878 #"$SELF" release-buildpk3s data/xonotic-maps.pk3dir       normal '' raw '-raw' low '-low'
879 #"$SELF" release-buildpk3s data/xonotic-music.pk3dir      normal '' raw '-raw' low '-low'
880 #"$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir                       low ''
881                 "$SELF" release-buildpk3s data/font-dejavu.pk3dir        raw ''
882                 "$SELF" release-buildpk3s data/xonotic-data.pk3dir       raw ''
883                 "$SELF" release-buildpk3s data/xonotic-maps.pk3dir       raw ''
884                 "$SELF" release-buildpk3s data/xonotic-music.pk3dir      raw ''
885                 "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir  raw ''
886                 ;;
887         release)
888                 "$SELF" release-prepare
889                 "$SELF" release-engine
890                 "$SELF" release-gamedata
891                 "$SELF" release-maps
892                 "$SELF" release-finish
893                 "$SELF" release-pack
894                 ;;
895         *)
896                 echo "Usage:"
897                 echo "  $SELF pull"
898                 echo "  $SELF merge"
899                 echo "  $SELF push [-s]"
900                 echo "  $SELF branches"
901                 echo "  $SELF branch [<remote>] <branchname>"
902                 echo "  $SELF branch <remote> <branchname> <srcbranchname>"
903                 echo "  $SELF checkout [<remote>] <branchname>"
904                 echo "  $SELF compile [-c] [<client>] <options>"
905                 echo "  $SELF run [<client>] <options>"
906                 echo "  $SELF each <command>"
907                 ;;
908 esac