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/*"
216 # TODO remove this line later
218 verbose git config core.autocrlf false
219 verbose git config core.safecrlf false # we don't NEED that...
221 r=`git symbolic-ref HEAD`
223 if git config branch.$r.remote >/dev/null 2>&1; then
224 if ! verbose git pull; then
225 check_mergeconflict "$d"
226 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
232 checkself "$cmd" "$@"
234 verbose git remote prune origin
238 verbose git clone "$url" "$d0/$d"
239 enter "$d0/$d" verbose
240 verbose git checkout "$branch"
248 if [ -z "$branch" ]; then
254 enter "$d0/$d" verbose
255 if [ -z "$branch" ]; then
260 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
262 verbose git checkout "$b"
263 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
265 verbose git checkout --track -b "$b" "$remote/$b"
267 verbose git checkout "`repobranch "$d"`"
270 checkself "$cmd" "$@"
274 echo "The requested branch was not found in any repository."
282 if [ -z "$branch" ]; then
286 if [ -z "$branch" ]; then
289 r=`git symbolic-ref HEAD`
296 dv=`visible_repo_name "$d"`
297 enter "$d0/$d" verbose
298 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
299 echo "Already having this branch in $dv."
301 if yesno "Branch in $dv?"; then
302 if [ -n "$srcbranch" ]; then
305 b=origin/"`repobranch "$d"`"
306 verbose git fetch origin || true
308 # TODO do this without pushing
309 verbose git checkout -b "$branch" "$b"
310 verbose git config "branch.$branch.remote" "$remote"
311 verbose git config "branch.$branch.merge" "refs/heads/$b"
312 verbose git push origin "$branch"
324 git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
327 UPSTREAM=${UPSTREAM#\[}
328 UPSTREAM=${UPSTREAM%\]}
329 UPSTREAM=${UPSTREAM%:*}
332 TEXT="$UPSTREAM $TEXT"
336 if [ x"$REV" = x"->" ]; then
339 BRANCH=${BRANCH#remotes/}
341 if [ -n "$UPSTREAM" ]; then
342 echo -n " (tracking $UPSTREAM)"
351 cd "$d0/$d" # am in a pipe, shouldn't use enter
352 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
357 while read -r d BRANCH REV UPSTREAM TEXT; do
360 UPSTREAM=${UPSTREAM#\[}
361 UPSTREAM=${UPSTREAM%\]}
362 UPSTREAM=${UPSTREAM%:*}
365 TEXT="$UPSTREAM $TEXT"
369 if [ x"$REV" = x"->" ]; then
372 BRANCH=${BRANCH#remotes/}
373 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
374 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
375 eval "r=\$branches_repos_$ID"
377 eval "branches_repos_$ID=\$r"
379 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
380 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
381 eval "r=\$branches_repos_$ID"
388 dv=`visible_repo_name "$d"`
389 enter "$d0/$d" verbose
390 r=`git symbolic-ref HEAD`
392 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
393 # we have uncommitted changes
394 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
395 if ! verbose git merge origin/"`repobranch "$d"`"; then
396 check_mergeconflict "$d"
397 exit 1 # this should ALWAYS be fatal
407 dv=`visible_repo_name "$d"`
408 enter "$d0/$d" verbose
409 r=`git symbolic-ref HEAD`
411 if git diff HEAD | grep .; then
412 # we have uncommitted changes
413 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
414 verbose git commit -a
417 rem=`git config "branch.$r.remote" || echo origin`
418 if { git log "$rem/$r".."$r" || git log origin/"`repobranch "$d"`".."$r"; } | grep .; then
419 if yesno "Push \"$r\" in $dv?"; then
420 verbose git push "$rem" HEAD
423 if [ x"$submit" = x"-s" ]; then
426 verbose git push "$rem" HEAD:"${r%%/*}/finished/${r#*/}"
434 if [ -n "$WE_HATE_OUR_USERS" ]; then
435 TARGETS="sv-debug cl-debug"
437 TARGETS="sv-debug cl-debug sdl-debug"
462 if [ -z "$MAKEFLAGS" ]; then
463 if [ -f /proc/cpuinfo ]; then
464 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
465 if [ $ncpus -gt 1 ]; then
471 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
474 if [ -n "$WE_HATE_OUR_USERS" ]; then
475 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
478 enter "$d0/fteqcc" verbose
480 verbose make $MAKEFLAGS clean
482 verbose make $MAKEFLAGS
483 enter "$d0/data/xonotic-data.pk3dir" verbose
485 verbose make $MAKEFLAGS clean
487 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
488 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
489 enter "$d0/darkplaces" verbose
491 verbose make $MAKEFLAGS clean
493 for T in $TARGETS; do
494 verbose make $MAKEFLAGS "$@" "$T"
498 if [ -n "$WE_HATE_OUR_USERS" ]; then
500 export PATH="$d0/misc/buildfiles/w32:$PATH"
501 elif [ x"`uname`" = x"Darwin" ]; then
502 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Nexuiz.app/Contents/MacOS"
508 sdl|glx|agl|dedicated)
517 if ! [ -x "darkplaces/darkplaces$client" ]; then
518 if [ -x "darkplaces/darkplaces$client.exe" ]; then
521 echo "Client darkplaces/darkplaces$client not found, aborting"
525 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
527 # if pulseaudio is running: USE IT
528 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ]; then
529 if ps -C pulseaudio >/dev/null; then
530 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
531 export SDL_AUDIODRIVER=pulse
536 if [ -n "$USE_GDB" ]; then
537 set -- gdb --args "$@"
543 if verbose cd "$d0/$d"; then
551 patchdir=`mktemp -d -t save-patches.XXXXXX`
553 enter "$d0/$d" verbose
554 git branch -v -v | cut -c 3- | {
556 while read -r BRANCH REV UPSTREAM TEXT; do
559 UPSTREAM=${UPSTREAM#\[}
560 UPSTREAM=${UPSTREAM%\]}
561 UPSTREAM=${UPSTREAM%:*}
565 UPSTREAM=origin/"`repobranch "$d"`"
569 if [ x"$REV" = x"->" ]; then
572 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
573 echo "$d" > "$patchdir/$i/info.txt"
574 echo "$BRANCH" >> "$patchdir/$i/info.txt"
575 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
576 echo "$TRACK" >> "$patchdir/$i/info.txt"
579 rm -rf "$patchdir/$i"
584 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
589 patchdir=`mktemp -d -t restore-patches.XXXXXX`
590 ( cd "$patchdir" && tar xvzf - ) < "$infile"
592 for P in "$patchdir"/*/info.txt; do
599 verbose git checkout HEAD^0
600 verbose git branch -D "$BRANCH"
601 if [ x"$TRACK" = x"true" ]; then
602 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
604 verbose git branch -b "$BRANCH" "$UPSTREAM"
611 if [ "$#" = 1 ]; then
612 set -- "${1%%/*}" "${1#*/}"
615 enter "$d0/$d" verbose
616 git rev-parse "$1/$2" || continue
619 git log HEAD.."$1/$2"
620 git diff HEAD..."$1/$2"
622 if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
624 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
628 git reset --hard HEAD@{1}
638 report=$report"$*$LF"
643 report=$report" $*$LF"
648 o=`"$@" | sed 's/^/ /' || true`
652 enter "$d0/$d" verbose
654 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
655 case "${ref#refs/remotes/origin/}" in
663 reportecho " Branch $ref:"
664 note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
665 if [ -n "$note" ]; then
666 reportdo4 echo "$note"
667 reportecho4 "--> not merging, already had this one rejected before"
668 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ git log --color master.."$ref"; git diff --color --find-copies-harder --ignore-space-change master..."$ref"; } | less -r'; then
670 org=`git rev-parse HEAD`
671 if ! git merge "$ref" 2>&1 | tee "$t"; then
672 git reset --hard "$org"
673 git notes --ref "refs/notes/admin-merge" add -m "Merge failed:$LF`cat "$t"`" "$ref"
675 reportecho4 "--> merge failed"
676 elif ! "$SELF" compile 2>&1 | tee "$t"; then
677 git reset --hard "$org"
678 git notes --ref "refs/notes/admin-merge" add -m "Compile failed:$LF`cat "$t"`" "$ref"
680 reportecho4 "--> compile failed"
681 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
682 git reset --hard "$org"
683 git notes --ref "refs/notes/admin-merge" add "$ref"
684 note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
685 reportdo4 echo "$note"
686 reportecho4 "--> test failed"
688 case ",`repoflags "$d"`," in
692 git svn dcommit --add-author-from
698 reportecho4 "--> MERGED"
699 if yesno "Delete original branch \"$ref\"?"; then
700 git push origin :"${ref#refs/remotes/origin/}"
701 reportecho4 "--> branch deleted"
705 git notes --ref "refs/notes/admin-merge" add "$ref"
706 note=`git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null || true`
707 if [ -n "$note" ]; then
708 reportdo4 echo "$note"
709 reportecho4 "--> rejected"
711 reportecho4 "--> postponed"
719 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
725 echo " $SELF push [-s]"
726 echo " $SELF branches"
727 echo " $SELF branch [<remote>] <branchname>"
728 echo " $SELF branch <remote> <branchname> <srcbranchname>"
729 echo " $SELF checkout [<remote>] <branchname>"
730 echo " $SELF compile [-c] [<client>] <options>"
731 echo " $SELF run [<client>] <options>"
732 echo " $SELF each <command>"