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 check_mergeconflict "$1"
112 data/xonotic-data.pk3dir | | master
113 data/xonotic-maps.pk3dir | | master
114 data/xonotic-music.pk3dir | | master
115 data/xonotic-nexcompat.pk3dir | | master
116 mediasource | | master
117 darkplaces | | div0-stable
118 fteqcc | git://github.com/Blub/qclib.git | master
119 div0-gittools | git://git.icculus.org/divverent/div0-gittools.git | master
120 netradiant | | master
122 # todo: in darkplaces, change repobranch to div0-stable
124 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
126 base=`git config remote.origin.url`
127 base=${base%xonotic.git}
131 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
142 if [ x"$1" = x"." ]; then
143 echo "$base""xonotic.git"
145 echo "$base${1##*/}.git"
152 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
160 repos=`for d in $repos; do
162 if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
167 if [ "$#" = 0 ]; then
176 if [ x"$1" = x"-N" ]; then
181 branch=`repobranch "$d"`
182 if [ -d "$d0/$d" ]; then
184 enter "$d0/$d" verbose
185 verbose git config remote.origin.url "$url"
186 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
187 # TODO remove this line later
189 verbose git config core.autocrlf false
190 verbose git config core.safecrlf false # we don't NEED that...
192 r=`git symbolic-ref HEAD`
194 if git config branch.$r.remote >/dev/null 2>&1; then
195 if ! verbose git pull; then
196 check_mergeconflict "$d"
197 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
203 checkself "$cmd" "$@"
205 verbose git remote prune origin
209 verbose git clone "$url" "$d0/$d"
210 enter "$d0/$d" verbose
211 verbose git checkout "$branch"
219 if [ -z "$branch" ]; then
225 enter "$d0/$d" verbose
226 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
228 verbose git checkout "$branch"
229 elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
231 verbose git checkout --track -b "$branch" "$remote/$branch"
233 verbose git checkout "`repobranch "$d"`"
236 checkself "$cmd" "$@"
240 echo "The requested branch was not found in any repository."
248 if [ -z "$branch" ]; then
252 if [ -z "$branch" ]; then
255 r=`git symbolic-ref HEAD`
262 dv=`visible_repo_name "$d"`
263 enter "$d0/$d" verbose
265 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
266 echo "Already having this branch in $dv."
268 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
269 echo "Branch in $dv?"
272 if [ x"$a" = x"y" ]; then
273 if [ -n "$srcbranch" ]; then
276 b="`repobranch "$d"`"
278 # TODO do this without pushing
279 verbose git push "$remote" "$b":"$branch"
280 verbose git checkout --track -b "$branch" "$remote/$branch"
292 git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
295 UPSTREAM=${UPSTREAM#\[}
296 UPSTREAM=${UPSTREAM%\]}
297 UPSTREAM=${UPSTREAM%:*}
300 TEXT="$UPSTREAM $TEXT"
304 if [ x"$REV" = x"->" ]; then
307 BRANCH=${BRANCH#remotes/}
309 if [ -n "$UPSTREAM" ]; then
310 echo -n " (tracking $UPSTREAM)"
319 cd "$d0/$d" # am in a pipe, shouldn't use enter
320 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
325 while read -r d BRANCH REV UPSTREAM TEXT; do
328 UPSTREAM=${UPSTREAM#\[}
329 UPSTREAM=${UPSTREAM%\]}
330 UPSTREAM=${UPSTREAM%:*}
333 TEXT="$UPSTREAM $TEXT"
337 if [ x"$REV" = x"->" ]; then
340 BRANCH=${BRANCH#remotes/}
341 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
342 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
343 eval "r=\$branches_repos_$ID"
345 eval "branches_repos_$ID=\$r"
347 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
348 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
349 eval "r=\$branches_repos_$ID"
356 dv=`visible_repo_name "$d"`
357 enter "$d0/$d" verbose
358 r=`git symbolic-ref HEAD`
360 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
361 # we have uncommitted changes
363 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
364 echo "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"
367 if [ x"$a" = x"y" ]; then
368 if ! verbose git merge origin/"`repobranch "$d"`"; then
369 check_mergeconflict "$d"
370 exit 1 # this should ALWAYS be fatal
380 dv=`visible_repo_name "$d"`
381 enter "$d0/$d" verbose
382 r=`git symbolic-ref HEAD`
384 if git diff HEAD | grep .; then
385 # we have uncommitted changes
387 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
388 echo "Uncommitted changes in \"$r\" in $dv. Commit?"
391 if [ x"$a" = x"y" ]; then
392 verbose git commit -a
395 rem=`git config "branch.$r.remote" || echo origin`
396 if { git log "$rem/$r".."$r" || git log origin/"`repobranch "$d"`".."$r"; } | grep .; then
398 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
399 echo "Push \"$r\" in $dv?"
402 if [ x"$a" = x"y" ]; then
403 verbose git push "$rem" HEAD
406 if [ x"$submit" = x"-s" ]; then
409 verbose git push "$rem" HEAD:"${r%%/*}/finished/${r#*/}"
417 if [ -n "$WE_HATE_OUR_USERS" ]; then
418 TARGETS="sv-debug cl-debug"
420 TARGETS="sv-debug cl-debug sdl-debug"
445 if [ -z "$MAKEFLAGS" ]; then
446 if [ -f /proc/cpuinfo ]; then
447 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
448 if [ $ncpus -gt 1 ]; then
454 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
457 if [ -n "$WE_HATE_OUR_USERS" ]; then
458 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
461 enter "$d0/fteqcc" verbose
463 verbose make $MAKEFLAGS clean
465 verbose make $MAKEFLAGS
466 enter "$d0/data/xonotic-data.pk3dir" verbose
468 verbose make $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 "$@"
508 if [ -n "$USE_GDB" ]; then
509 set -- gdb --args "$@"
515 if verbose cd "$d0/$d"; then
523 patchdir=`mktemp -d -t save-patches.XXXXXX`
525 enter "$d0/$d" verbose
526 git branch -v -v | cut -c 3- | {
528 while read -r BRANCH REV UPSTREAM TEXT; do
531 UPSTREAM=${UPSTREAM#\[}
532 UPSTREAM=${UPSTREAM%\]}
533 UPSTREAM=${UPSTREAM%:*}
537 UPSTREAM=origin/"`repobranch "$d"`"
541 if [ x"$REV" = x"->" ]; then
544 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
545 echo "$d" > "$patchdir/$i/info.txt"
546 echo "$BRANCH" >> "$patchdir/$i/info.txt"
547 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
548 echo "$TRACK" >> "$patchdir/$i/info.txt"
551 rm -rf "$patchdir/$i"
556 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
561 patchdir=`mktemp -d -t restore-patches.XXXXXX`
562 ( cd "$patchdir" && tar xvzf - ) < "$infile"
564 for P in "$patchdir"/*/info.txt; do
571 verbose git checkout HEAD^0
572 verbose git branch -D "$BRANCH"
573 if [ x"$TRACK" = x"true" ]; then
574 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
576 verbose git branch -b "$BRANCH" "$UPSTREAM"
583 if [ "$#" = 1 ]; then
584 set -- "${1%%/*}" "${1#*/}"
587 enter "$d0/$d" verbose
588 git rev-parse "$1/$2" || continue
591 git log HEAD.."$1/$2"
592 git diff HEAD..."$1/$2"
595 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
596 echo "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"
599 if [ x"$a" = x"y" ]; then
603 if ! "$SELF" compile; then
607 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
608 echo "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."
611 if [ x"$a" = x"y" ]; then
615 git reset --hard HEAD@{1}
624 echo " $SELF push [-s]"
625 echo " $SELF branches"
626 echo " $SELF branch [<remote>] <branchname>"
627 echo " $SELF branch <remote> <branchname> <srcbranchname>"
628 echo " $SELF checkout [<remote>] <branchname>"
629 echo " $SELF compile [-c] [<client>] <options>"
630 echo " $SELF run [<client>] <options>"
631 echo " $SELF each <command>"