6 # I use this in EVERY shell script ;)
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."
22 # If we are on WINDOWS:
27 # Windows hates users. So this script has to copy itself elsewhere first...
29 cp "$SELF" ../all.xonotic.sh
30 export WE_HATE_OUR_USERS=1
31 exec ../all.xonotic.sh "$@"
44 if [ -x /usr/bin/md5sum ]; then
46 elif [ -x /bin/md5sum ]; then
48 elif [ -x /usr/bin/cksum ]; then
55 self=`checksum "$SELF"`
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
66 msg "Please try $SELF update, and then retry your requested operation."
83 echo "the root directory"
93 if git ls-files -u | grep ' 1 '; then
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'"
111 while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
122 check_mergeconflict "$1"
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 |
137 # todo: in darkplaces, change repobranch to div0-stable
139 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
141 base=`git config remote.origin.url`
144 base=${base%xonotic.git}
147 echo "The main repo is not xonotic.git, what have you done?"
154 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
165 if [ x"$1" = x"." ]; then
166 echo "$base""xonotic.git"
168 echo "$base${1##*/}.git"
175 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
185 echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
189 repos=`for d in $repos; do
191 if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
196 if [ "$#" = 0 ]; then
205 if [ x"$1" = x"-N" ]; then
210 branch=`repobranch "$d"`
211 if [ -d "$d0/$d" ]; 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/*"
217 r=`git symbolic-ref HEAD`
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."
228 checkself "$cmd" "$@"
230 verbose git remote prune origin
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"
244 misc/tools/xonotic-map-compiler-autobuild download
249 if [ -z "$branch" ]; then
255 enter "$d0/$d" verbose
257 if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
259 verbose git checkout "$b"
260 elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
262 verbose git checkout --track -b "$b" "$remote/$b"
265 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
267 verbose git checkout "$b"
268 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
270 verbose git checkout --track -b "$b" "$remote/$b"
272 echo "WTF? Not even branch $b doesn't exist in $d"
277 checkself "$cmd" "$@"
281 echo "The requested branch was not found in any repository."
289 if [ -z "$branch" ]; then
293 if [ -z "$branch" ]; then
296 r=`git symbolic-ref HEAD`
303 dv=`visible_repo_name "$d"`
304 enter "$d0/$d" verbose
305 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
306 echo "Already having this branch in $dv."
308 if yesno "Branch in $dv?"; then
309 if [ -n "$srcbranch" ]; then
312 b=origin/"`repobranch "$d"`"
313 verbose git fetch origin || true
315 # TODO do this without pushing
316 verbose git checkout -b "$branch" "$b"
317 verbose git config "branch.$branch.remote" "$remote"
318 verbose git config "branch.$branch.merge" "refs/heads/$branch"
330 git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
333 UPSTREAM=${UPSTREAM#\[}
334 UPSTREAM=${UPSTREAM%\]}
335 UPSTREAM=${UPSTREAM%:*}
338 TEXT="$UPSTREAM $TEXT"
342 if [ x"$REV" = x"->" ]; then
345 BRANCH=${BRANCH#remotes/}
347 if [ -n "$UPSTREAM" ]; then
348 echo -n " (tracking $UPSTREAM)"
357 cd "$d0/$d" # am in a pipe, shouldn't use enter
358 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
363 while read -r d BRANCH REV UPSTREAM TEXT; do
366 UPSTREAM=${UPSTREAM#\[}
367 UPSTREAM=${UPSTREAM%\]}
368 UPSTREAM=${UPSTREAM%:*}
371 TEXT="$UPSTREAM $TEXT"
375 if [ x"$REV" = x"->" ]; then
378 BRANCH=${BRANCH#remotes/}
379 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
380 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
381 eval "r=\$branches_repos_$ID"
383 eval "branches_repos_$ID=\$r"
385 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
386 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
387 eval "r=\$branches_repos_$ID"
394 dv=`visible_repo_name "$d"`
395 enter "$d0/$d" verbose
396 r=`git symbolic-ref HEAD`
398 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
399 # we have uncommitted changes
400 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
401 if ! verbose git merge origin/"`repobranch "$d"`"; then
402 check_mergeconflict "$d"
403 exit 1 # this should ALWAYS be fatal
413 dv=`visible_repo_name "$d"`
414 enter "$d0/$d" verbose
415 r=`git symbolic-ref HEAD`
417 if git diff HEAD | grep .; then
418 # we have uncommitted changes
419 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
420 verbose git commit -a
423 rem=`git config "branch.$r.remote" || echo origin`
424 bra=`git config "branch.$r.merge" || echo "$r"`
426 if ! [ git rev-parse "$upstream" ]; then
427 upstream="`repobranch "$d"`"
429 if git log "$upstream".."$r" | grep .; then
430 if yesno "Push \"$r\" in $dv?"; then
431 verbose git push "$rem" HEAD
434 if [ x"$submit" = x"-s" ]; then
437 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
445 if [ -n "$WE_HATE_OUR_USERS" ]; then
446 TARGETS="sv-debug cl-debug"
447 if [ -z "$CC" ]; then
450 elif [ x"`uname`" = x"Darwin" ] && ( [ -d /Library/Frameworks/SDL.framework ] || [ -d $(HOME)/Library/Frameworks/SDL.framework ] ); then
451 # AGL is broken in Snow Leopard, so let's default to SDL if it is available.
452 TARGETS="sv-debug sdl-debug"
454 TARGETS="sv-debug cl-debug sdl-debug"
479 if [ -z "$MAKEFLAGS" ]; then
480 if [ -f /proc/cpuinfo ]; then
481 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
482 if [ $ncpus -gt 1 ]; then
488 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
491 if [ -n "$WE_HATE_OUR_USERS" ]; then
492 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
495 enter "$d0/fteqcc" verbose
497 verbose make $MAKEFLAGS clean
499 verbose make $MAKEFLAGS
500 enter "$d0/data/xonotic-data.pk3dir" verbose
502 verbose make $MAKEFLAGS clean
504 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
505 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
506 enter "$d0/darkplaces" verbose
508 verbose make $MAKEFLAGS clean
510 for T in $TARGETS; do
511 verbose make $MAKEFLAGS "$@" "$T"
513 verbose "$SELF" update-maps
516 if [ -n "$WE_HATE_OUR_USERS" ]; then
518 export PATH="$d0/misc/buildfiles/w32:$PATH"
519 elif [ x"`uname`" = x"Darwin" ]; then
520 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
526 sdl|glx|agl|dedicated)
535 if ! [ -x "darkplaces/darkplaces$client" ]; then
536 if [ -x "darkplaces/darkplaces$client.exe" ]; then
539 echo "Client darkplaces/darkplaces$client not found, aborting"
543 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
545 # if pulseaudio is running: USE IT
546 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
547 if ps -C pulseaudio >/dev/null; then
548 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
549 export SDL_AUDIODRIVER=pulse
554 if [ -n "$USE_GDB" ]; then
555 set -- gdb --args "$@"
561 if verbose cd "$d0/$d"; then
569 patchdir=`mktemp -d -t save-patches.XXXXXX`
571 enter "$d0/$d" verbose
572 git branch -v -v | cut -c 3- | {
574 while read -r BRANCH REV UPSTREAM TEXT; do
577 UPSTREAM=${UPSTREAM#\[}
578 UPSTREAM=${UPSTREAM%\]}
579 UPSTREAM=${UPSTREAM%:*}
583 UPSTREAM=origin/"`repobranch "$d"`"
587 if [ x"$REV" = x"->" ]; then
590 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
591 echo "$d" > "$patchdir/$i/info.txt"
592 echo "$BRANCH" >> "$patchdir/$i/info.txt"
593 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
594 echo "$TRACK" >> "$patchdir/$i/info.txt"
597 rm -rf "$patchdir/$i"
602 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
607 patchdir=`mktemp -d -t restore-patches.XXXXXX`
608 ( cd "$patchdir" && tar xvzf - ) < "$infile"
610 for P in "$patchdir"/*/info.txt; do
617 verbose git checkout HEAD^0
618 verbose git branch -D "$BRANCH"
619 if [ x"$TRACK" = x"true" ]; then
620 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
622 verbose git branch -b "$BRANCH" "$UPSTREAM"
629 if [ "$#" = 1 ]; then
630 set -- "${1%%/*}" "${1#*/}"
633 enter "$d0/$d" verbose
634 git rev-parse "$1/$2" || continue
637 git log HEAD.."$1/$2"
638 git diff HEAD..."$1/$2"
640 if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
642 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
646 git reset --hard HEAD@{1}
656 report=$report"$*$LF"
661 report=$report" $*$LF"
666 o=`"$@" | sed 's/^/ /' || true`
670 enter "$d0/$d" verbose
671 base="`repobranch "$d"`"
673 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
674 case "${ref#refs/remotes/origin/}" in
682 reportecho " Branch $ref:"
683 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
684 logdata=`git log --color "$base".."$ref"`
685 diffdata=`git diff --color --find-copies-harder --ignore-space-change "$base"..."$ref"`
686 if [ -z "$logdata" ]; then
687 reportecho4 "--> not merging, no changes vs master"
688 elif [ -z "$diffdata" ]; then
689 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
690 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
691 git push origin :"${ref#refs/remotes/origin/}"
692 reportecho4 "--> branch deleted"
694 elif [ -n "$note" ]; then
695 reportdo4 echo "$note"
696 reportecho4 "--> not merging, already had this one rejected before"
697 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
699 org=`git rev-parse HEAD`
700 if ! git merge "$ref" 2>&1 | tee "$t"; then
701 git reset --hard "$org"
702 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
704 reportecho4 "--> merge failed"
705 elif ! "$SELF" compile 2>&1 | tee "$t"; then
706 git reset --hard "$org"
707 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
709 reportecho4 "--> compile failed"
710 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
711 git reset --hard "$org"
712 git notes edit "$ref"
713 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
714 reportdo4 echo "$note"
715 reportecho4 "--> test failed"
717 case ",`repoflags "$d"`," in
719 # we do quite a mess here... luckily we know $org
720 git pull # svn needs to be current
721 git rebase -i --onto master "$org"
722 git svn dcommit --add-author-from
723 git reset --hard "$org"
729 reportecho4 "--> MERGED"
730 if yesno "Delete original branch \"$ref\"?"; then
731 git push origin :"${ref#refs/remotes/origin/}"
732 reportecho4 "--> branch deleted"
736 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
737 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
738 if [ -n "$note" ]; then
739 reportdo4 echo "$note"
740 reportecho4 "--> rejected"
742 reportecho4 "--> postponed"
750 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
756 echo " $SELF push [-s]"
757 echo " $SELF branches"
758 echo " $SELF branch [<remote>] <branchname>"
759 echo " $SELF branch <remote> <branchname> <srcbranchname>"
760 echo " $SELF checkout [<remote>] <branchname>"
761 echo " $SELF compile [-c] [<client>] <options>"
762 echo " $SELF run [<client>] <options>"
763 echo " $SELF each <command>"