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
117 check_mergeconflict "$1"
122 data/xonotic-data.pk3dir | | master
123 data/xonotic-maps.pk3dir | | master
124 data/xonotic-music.pk3dir | | master
125 data/xonotic-nexcompat.pk3dir | | master
126 mediasource | | master
127 darkplaces | | div0-stable
128 fteqcc | git://github.com/Blub/qclib.git | master
129 div0-gittools | git://git.icculus.org/divverent/div0-gittools.git | master
130 netradiant | | master
132 # todo: in darkplaces, change repobranch to div0-stable
134 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
136 base=`git config remote.origin.url`
137 base=${base%xonotic.git}
141 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
152 if [ x"$1" = x"." ]; then
153 echo "$base""xonotic.git"
155 echo "$base${1##*/}.git"
162 t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
170 repos=`for d in $repos; do
172 if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
177 if [ "$#" = 0 ]; then
186 if [ x"$1" = x"-N" ]; then
191 branch=`repobranch "$d"`
192 if [ -d "$d0/$d" ]; then
194 enter "$d0/$d" verbose
195 verbose git config remote.origin.url "$url"
196 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
197 # TODO remove this line later
199 verbose git config core.autocrlf false
200 verbose git config core.safecrlf false # we don't NEED that...
202 r=`git symbolic-ref HEAD`
204 if git config branch.$r.remote >/dev/null 2>&1; then
205 if ! verbose git pull; then
206 check_mergeconflict "$d"
207 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
213 checkself "$cmd" "$@"
215 verbose git remote prune origin
219 verbose git clone "$url" "$d0/$d"
220 enter "$d0/$d" verbose
221 verbose git checkout "$branch"
229 if [ -z "$branch" ]; then
235 enter "$d0/$d" verbose
236 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
238 verbose git checkout "$branch"
239 elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
241 verbose git checkout --track -b "$branch" "$remote/$branch"
243 verbose git checkout "`repobranch "$d"`"
246 checkself "$cmd" "$@"
250 echo "The requested branch was not found in any repository."
258 if [ -z "$branch" ]; then
262 if [ -z "$branch" ]; then
265 r=`git symbolic-ref HEAD`
272 dv=`visible_repo_name "$d"`
273 enter "$d0/$d" verbose
274 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
275 echo "Already having this branch in $dv."
277 if yesno "Branch in $dv?"; then
278 if [ -n "$srcbranch" ]; then
281 b="`repobranch "$d"`"
283 # TODO do this without pushing
284 verbose git push "$remote" "$b":"$branch"
285 verbose git checkout --track -b "$branch" "$remote/$branch"
297 git branch -a -v -v | cut -c 3- | while read -r BRANCH REV UPSTREAM TEXT; do
300 UPSTREAM=${UPSTREAM#\[}
301 UPSTREAM=${UPSTREAM%\]}
302 UPSTREAM=${UPSTREAM%:*}
305 TEXT="$UPSTREAM $TEXT"
309 if [ x"$REV" = x"->" ]; then
312 BRANCH=${BRANCH#remotes/}
314 if [ -n "$UPSTREAM" ]; then
315 echo -n " (tracking $UPSTREAM)"
324 cd "$d0/$d" # am in a pipe, shouldn't use enter
325 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
330 while read -r d 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/}
346 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
347 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
348 eval "r=\$branches_repos_$ID"
350 eval "branches_repos_$ID=\$r"
352 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
353 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
354 eval "r=\$branches_repos_$ID"
361 dv=`visible_repo_name "$d"`
362 enter "$d0/$d" verbose
363 r=`git symbolic-ref HEAD`
365 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
366 # we have uncommitted changes
367 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; 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
386 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?"; then
387 verbose git commit -a
390 rem=`git config "branch.$r.remote" || echo origin`
391 if { git log "$rem/$r".."$r" || git log origin/"`repobranch "$d"`".."$r"; } | grep .; then
392 if yesno "Push \"$r\" in $dv?"; then
393 verbose git push "$rem" HEAD
396 if [ x"$submit" = x"-s" ]; then
399 verbose git push "$rem" HEAD:"${r%%/*}/finished/${r#*/}"
407 if [ -n "$WE_HATE_OUR_USERS" ]; then
408 TARGETS="sv-debug cl-debug"
410 TARGETS="sv-debug cl-debug sdl-debug"
435 if [ -z "$MAKEFLAGS" ]; then
436 if [ -f /proc/cpuinfo ]; then
437 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
438 if [ $ncpus -gt 1 ]; then
444 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
447 if [ -n "$WE_HATE_OUR_USERS" ]; then
448 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
451 enter "$d0/fteqcc" verbose
453 verbose make $MAKEFLAGS clean
455 verbose make $MAKEFLAGS
456 enter "$d0/data/xonotic-data.pk3dir" verbose
458 verbose make $MAKEFLAGS clean
460 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
461 enter "$d0/darkplaces" verbose
463 verbose make $MAKEFLAGS clean
465 for T in $TARGETS; do
466 verbose make $MAKEFLAGS "$@" "$T"
470 if [ -n "$WE_HATE_OUR_USERS" ]; then
472 export PATH="$d0/misc/buildfiles/w32:$PATH"
473 elif [ x"`uname`" = x"Darwin" ]; then
474 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Nexuiz.app/Contents/MacOS"
480 sdl|glx|agl|dedicated)
489 if ! [ -x "darkplaces/darkplaces$client" ]; then
490 if [ -x "darkplaces/darkplaces$client.exe" ]; then
493 echo "Client darkplaces/darkplaces$client not found, aborting"
497 set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
498 if [ -n "$USE_GDB" ]; then
499 set -- gdb --args "$@"
505 if verbose cd "$d0/$d"; then
513 patchdir=`mktemp -d -t save-patches.XXXXXX`
515 enter "$d0/$d" verbose
516 git branch -v -v | cut -c 3- | {
518 while read -r BRANCH REV UPSTREAM TEXT; do
521 UPSTREAM=${UPSTREAM#\[}
522 UPSTREAM=${UPSTREAM%\]}
523 UPSTREAM=${UPSTREAM%:*}
527 UPSTREAM=origin/"`repobranch "$d"`"
531 if [ x"$REV" = x"->" ]; then
534 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
535 echo "$d" > "$patchdir/$i/info.txt"
536 echo "$BRANCH" >> "$patchdir/$i/info.txt"
537 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
538 echo "$TRACK" >> "$patchdir/$i/info.txt"
541 rm -rf "$patchdir/$i"
546 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
551 patchdir=`mktemp -d -t restore-patches.XXXXXX`
552 ( cd "$patchdir" && tar xvzf - ) < "$infile"
554 for P in "$patchdir"/*/info.txt; do
561 verbose git checkout HEAD^0
562 verbose git branch -D "$BRANCH"
563 if [ x"$TRACK" = x"true" ]; then
564 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
566 verbose git branch -b "$BRANCH" "$UPSTREAM"
573 if [ "$#" = 1 ]; then
574 set -- "${1%%/*}" "${1#*/}"
577 enter "$d0/$d" verbose
578 git rev-parse "$1/$2" || continue
581 git log HEAD.."$1/$2"
582 git diff HEAD..."$1/$2"
584 if yesno "Merge \"$1/$2\" into `git symbolic-ref HEAD` of $d?"; then
586 if "$SELF" compile && yesno "Still merge \"$1/$2\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
590 git reset --hard HEAD@{1}
598 enter "$d0/$d" verbose
599 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
600 case "${ref#refs/remotes/origin/}" in
609 if git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null; then
610 echo "Not merging, already had this one"
611 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ git log HEAD.."$ref"; git diff HEAD.."$ref"; } | less'; then
612 org=`git rev-parse HEAD`
613 if ! git merge "$ref" 2>&1 | tee "$t"; then
614 git reset --hard "$org"
615 git notes --ref "refs/notes/admin-merge" add -m "Merge failed:
617 elif ! "$SELF" compile 2>&1 | tee "$t"; then
618 git reset --hard "$org"
619 git notes --ref "refs/notes/admin-merge" add -m "Compile failed:
621 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
622 git reset --hard HEAD@{1}
623 git notes --ref "refs/notes/admin-merge" add "$ref"
626 git push origin :"${ref#refs/remotes/origin/}"
629 git reset --hard HEAD@{1}
630 git notes --ref "refs/notes/admin-merge" add "$ref"
640 echo " $SELF push [-s]"
641 echo " $SELF branches"
642 echo " $SELF branch [<remote>] <branchname>"
643 echo " $SELF branch <remote> <branchname> <srcbranchname>"
644 echo " $SELF checkout [<remote>] <branchname>"
645 echo " $SELF compile [-c] [<client>] <options>"
646 echo " $SELF run [<client>] <options>"
647 echo " $SELF each <command>"