7 while ! [ -f ./all ]; do
8 if [ x"`pwd`" = x"/" ]; then
9 echo "Cannot find myself."
10 echo "Please run this script with the working directory inside a Xonotic checkout."
18 # If we are on WINDOWS:
23 # Windows hates users. So this script has to copy itself elsewhere first...
25 cp "$SELF" ../all.xonotic.sh
26 export WE_HATE_OUR_USERS=1
27 exec ../all.xonotic.sh "$@"
40 if [ -x /usr/bin/md5sum ]; then
42 elif [ -x /bin/md5sum ]; then
44 elif [ -x /usr/bin/cksum ]; then
51 self=`checksum "$SELF"`
54 self_new=`checksum "$SELF"`
55 if [ x"$self" != x"$self_new" ]; then
56 msg "./all has changed."
57 if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
58 msg "Rerunning the requested operation to make sure."
59 export XONOTIC_FORBID_RERUN_ALL=1
62 msg "Please try $SELF update, and then retry your requested operation."
79 echo "the root directory"
89 if git ls-files -u | grep ' 1 '; then
91 echo "MERGE CONFLICT."
92 echo "change into the \"$1\" project directory, and then:"
93 echo "- edit the files mentioned above with your favorite editor,"
94 echo " and fix the conflicts (marked with <<<<<<< blocks)"
95 echo "- for binary files, you can select the files using"
96 echo " git checkout --ours or git checkout --theirs"
97 echo "- when done with a file, 'git add' the file"
98 echo "- when done, 'git commit'"
107 while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
118 check_mergeconflict "$1"
123 data/xonotic-data.pk3dir | | master
124 data/xonotic-maps.pk3dir | | master
125 data/xonotic-music.pk3dir | | master
126 data/xonotic-nexcompat.pk3dir | | master
127 mediasource | | master
128 darkplaces | | div0-stable
129 fteqcc | git://github.com/Blub/qclib.git | master
130 div0-gittools | git://git.icculus.org/divverent/div0-gittools.git | master
131 netradiant | | master
133 # todo: in darkplaces, change repobranch to div0-stable
135 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
137 base=`git config remote.origin.url`
140 base=${base%xonotic.git}
143 echo "The main repo is not xonotic.git, what have you done?"
150 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
161 if [ x"$1" = x"." ]; then
162 echo "$base""xonotic.git"
164 echo "$base${1##*/}.git"
171 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
179 repos=`for d in $repos; do
181 if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
186 if [ "$#" = 0 ]; then
195 if [ x"$1" = x"-N" ]; then
200 branch=`repobranch "$d"`
201 if [ -d "$d0/$d" ]; then
203 enter "$d0/$d" verbose
204 verbose git config remote.origin.url "$url"
205 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
206 # TODO remove this line later
208 verbose git config core.autocrlf false
209 verbose git config core.safecrlf false # we don't NEED that...
211 r=`git symbolic-ref HEAD`
213 if git config branch.$r.remote >/dev/null 2>&1; then
214 if ! verbose git pull; then
215 check_mergeconflict "$d"
216 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
222 checkself "$cmd" "$@"
224 verbose git remote prune origin
228 verbose git clone "$url" "$d0/$d"
229 enter "$d0/$d" verbose
230 verbose git checkout "$branch"
238 if [ -z "$branch" ]; then
244 enter "$d0/$d" verbose
245 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
247 verbose git checkout "$branch"
248 elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
250 verbose git checkout --track -b "$branch" "$remote/$branch"
252 verbose git checkout "`repobranch "$d"`"
255 checkself "$cmd" "$@"
259 echo "The requested branch was not found in any repository."
267 if [ -z "$branch" ]; then
271 if [ -z "$branch" ]; then
274 r=`git symbolic-ref HEAD`
281 dv=`visible_repo_name "$d"`
282 enter "$d0/$d" verbose
283 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
284 echo "Already having this branch in $dv."
286 if yesno "Branch in $dv?"; then
287 if [ -n "$srcbranch" ]; then
290 b="`repobranch "$d"`"
292 # TODO do this without pushing
293 verbose git push "$remote" "$b":"$branch"
294 verbose git checkout --track -b "$branch" "$remote/$branch"
306 git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
309 UPSTREAM=${UPSTREAM#\[}
310 UPSTREAM=${UPSTREAM%\]}
311 UPSTREAM=${UPSTREAM%:*}
314 TEXT="$UPSTREAM $TEXT"
318 if [ x"$REV" = x"->" ]; then
321 BRANCH=${BRANCH#remotes/}
323 if [ -n "$UPSTREAM" ]; then
324 echo -n " (tracking $UPSTREAM)"
333 cd "$d0/$d" # am in a pipe, shouldn't use enter
334 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
339 while read -r d BRANCH REV UPSTREAM TEXT; do
342 UPSTREAM=${UPSTREAM#\[}
343 UPSTREAM=${UPSTREAM%\]}
344 UPSTREAM=${UPSTREAM%:*}
347 TEXT="$UPSTREAM $TEXT"
351 if [ x"$REV" = x"->" ]; then
354 BRANCH=${BRANCH#remotes/}
355 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
356 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
357 eval "r=\$branches_repos_$ID"
359 eval "branches_repos_$ID=\$r"
361 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
362 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
363 eval "r=\$branches_repos_$ID"
370 dv=`visible_repo_name "$d"`
371 enter "$d0/$d" verbose
372 r=`git symbolic-ref HEAD`
374 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
375 # we have uncommitted changes
376 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
377 if ! verbose git merge origin/"`repobranch "$d"`"; then
378 check_mergeconflict "$d"
379 exit 1 # this should ALWAYS be fatal
389 dv=`visible_repo_name "$d"`
390 enter "$d0/$d" verbose
391 r=`git symbolic-ref HEAD`
393 if git diff HEAD | grep .; then
394 # we have uncommitted changes
395 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
396 verbose git commit -a
399 rem=`git config "branch.$r.remote" || echo origin`
400 if { git log "$rem/$r".."$r" || git log origin/"`repobranch "$d"`".."$r"; } | grep .; then
401 if yesno "Push \"$r\" in $dv?"; then
402 verbose git push "$rem" HEAD
405 if [ x"$submit" = x"-s" ]; then
408 verbose git push "$rem" HEAD:"${r%%/*}/finished/${r#*/}"
416 if [ -n "$WE_HATE_OUR_USERS" ]; then
417 TARGETS="sv-debug cl-debug"
419 TARGETS="sv-debug cl-debug sdl-debug"
444 if [ -z "$MAKEFLAGS" ]; then
445 if [ -f /proc/cpuinfo ]; then
446 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
447 if [ $ncpus -gt 1 ]; then
453 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
456 if [ -n "$WE_HATE_OUR_USERS" ]; then
457 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
460 enter "$d0/fteqcc" verbose
462 verbose make $MAKEFLAGS clean
464 verbose make $MAKEFLAGS
465 enter "$d0/data/xonotic-data.pk3dir" verbose
467 verbose make $MAKEFLAGS clean
469 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
470 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
471 enter "$d0/darkplaces" verbose
473 verbose make $MAKEFLAGS clean
475 for T in $TARGETS; do
476 verbose make $MAKEFLAGS "$@" "$T"
480 if [ -n "$WE_HATE_OUR_USERS" ]; then
482 export PATH="$d0/misc/buildfiles/w32:$PATH"
483 elif [ x"`uname`" = x"Darwin" ]; then
484 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Nexuiz.app/Contents/MacOS"
490 sdl|glx|agl|dedicated)
499 if ! [ -x "darkplaces/darkplaces$client" ]; then
500 if [ -x "darkplaces/darkplaces$client.exe" ]; then
503 echo "Client darkplaces/darkplaces$client not found, aborting"
507 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
509 # if pulseaudio is running: USE IT
510 if ps -C pulseaudio >/dev/null; then
511 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
512 export SDL_AUDIODRIVER=pulse
516 if [ -n "$USE_GDB" ]; then
517 set -- gdb --args "$@"
523 if verbose cd "$d0/$d"; then
531 patchdir=`mktemp -d -t save-patches.XXXXXX`
533 enter "$d0/$d" verbose
534 git branch -v -v | cut -c 3- | {
536 while read -r BRANCH REV UPSTREAM TEXT; do
539 UPSTREAM=${UPSTREAM#\[}
540 UPSTREAM=${UPSTREAM%\]}
541 UPSTREAM=${UPSTREAM%:*}
545 UPSTREAM=origin/"`repobranch "$d"`"
549 if [ x"$REV" = x"->" ]; then
552 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
553 echo "$d" > "$patchdir/$i/info.txt"
554 echo "$BRANCH" >> "$patchdir/$i/info.txt"
555 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
556 echo "$TRACK" >> "$patchdir/$i/info.txt"
559 rm -rf "$patchdir/$i"
564 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
569 patchdir=`mktemp -d -t restore-patches.XXXXXX`
570 ( cd "$patchdir" && tar xvzf - ) < "$infile"
572 for P in "$patchdir"/*/info.txt; do
579 verbose git checkout HEAD^0
580 verbose git branch -D "$BRANCH"
581 if [ x"$TRACK" = x"true" ]; then
582 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
584 verbose git branch -b "$BRANCH" "$UPSTREAM"
591 if [ "$#" = 1 ]; then
592 set -- "${1%%/*}" "${1#*/}"
595 enter "$d0/$d" verbose
596 git rev-parse "$1/$2" || continue
599 git log HEAD.."$1/$2"
600 git diff HEAD..."$1/$2"
602 if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
604 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
608 git reset --hard HEAD@{1}
616 enter "$d0/$d" verbose
617 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
618 case "${ref#refs/remotes/origin/}" in
627 if git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null; then
628 echo "Not merging, already had this one"
629 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ git log HEAD.."$ref"; git diff HEAD..."$ref"; } | less'; then
630 org=`git rev-parse HEAD`
631 if ! git merge "$ref" 2>&1 | tee "$t"; then
632 git reset --hard "$org"
633 git notes --ref "refs/notes/admin-merge" add -m "Merge failed:
635 elif ! "$SELF" compile 2>&1 | tee "$t"; then
636 git reset --hard "$org"
637 git notes --ref "refs/notes/admin-merge" add -m "Compile failed:
639 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
640 git reset --hard "$org"
641 git notes --ref "refs/notes/admin-merge" add "$ref"
644 if yesno "Delete original branch \"$ref\"?"; then
645 git push origin :"${ref#refs/remotes/origin/}"
649 git notes --ref "refs/notes/admin-merge" add "$ref"
659 echo " $SELF push [-s]"
660 echo " $SELF branches"
661 echo " $SELF branch [<remote>] <branchname>"
662 echo " $SELF branch <remote> <branchname> <srcbranchname>"
663 echo " $SELF checkout [<remote>] <branchname>"
664 echo " $SELF compile [-c] [<client>] <options>"
665 echo " $SELF run [<client>] <options>"
666 echo " $SELF each <command>"