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 "$@"
42 self=`git hash-object "$SELF"`
45 self_new=`git hash-object "$SELF"`
46 if [ x"$self" != x"$self_new" ]; then
47 msg "./all has changed."
48 if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
49 msg "Rerunning the requested operation to make sure."
50 export XONOTIC_FORBID_RERUN_ALL=1
53 msg "Please try $SELF update, and then retry your requested operation."
70 echo "the root directory"
80 if git ls-files -u | grep ' 1 '; then
82 echo "MERGE CONFLICT."
83 echo "change into the \"$1\" project directory, and then:"
84 echo "- edit the files mentioned above with your favorite editor,"
85 echo " and fix the conflicts (marked with <<<<<<< blocks)"
86 echo "- for binary files, you can select the files using"
87 echo " git checkout --ours or git checkout --theirs"
88 echo "- when done with a file, 'git add' the file"
89 echo "- when done, 'git commit'"
98 while [ x"$yesno" != x"y" -a x"$yesno" != x"n" ]; do
109 check_mergeconflict "$1"
114 data/xonotic-data.pk3dir | | master |
115 data/xonotic-maps.pk3dir | | master |
116 data/xonotic-music.pk3dir | | master |
117 data/xonotic-nexcompat.pk3dir | | master |
118 mediasource | | master |
119 darkplaces | | div0-stable | svn
120 fteqcc | git://github.com/Blub/qclib.git | master |
121 div0-gittools | git://git.icculus.org/divverent/div0-gittools.git | master |
122 netradiant | | master |
124 # todo: in darkplaces, change repobranch to div0-stable
126 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
128 base=`git config remote.origin.url`
131 base=${base%xonotic.git}
134 echo "The main repo is not xonotic.git, what have you done?"
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 ' '`
172 echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
176 repos=`for d in $repos; do
178 if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! { [ -f "$d.no" ] || [ -f "$p" ]; }; then
183 if [ "$#" = 0 ]; then
192 if [ x"$1" = x"-N" ]; then
197 branch=`repobranch "$d"`
198 if [ -d "$d0/$d" ]; then
200 enter "$d0/$d" verbose
201 verbose git config remote.origin.url "$url"
202 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
204 r=`git symbolic-ref HEAD`
206 if git config branch.$r.remote >/dev/null 2>&1; then
207 if ! verbose git pull; then
208 check_mergeconflict "$d"
209 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
215 checkself "$cmd" "$@"
217 verbose git remote prune origin
221 verbose git clone "$url" "$d0/$d"
222 enter "$d0/$d" verbose
223 if [ "$branch" != "master" ]; then
224 verbose git checkout --track -b "$branch" origin/"$branch"
231 misc/tools/xonotic-map-compiler-autobuild download
236 if [ -z "$branch" ]; then
239 branch=${remote#origin/}
250 enter "$d0/$d" verbose
252 if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
254 verbose git checkout "$b"
255 elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
257 verbose git checkout --track -b "$b" "$remote/$b"
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 echo "WTF? Not even branch $b doesn't exist in $d"
272 checkself "$cmd" "$@"
276 echo "The requested branch was not found in any repository."
284 if [ -z "$branch" ]; then
288 if [ -z "$branch" ]; then
291 r=`git symbolic-ref HEAD`
298 dv=`visible_repo_name "$d"`
299 enter "$d0/$d" verbose
300 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
301 echo "Already having this branch in $dv."
303 if yesno "Branch in $dv?"; then
304 if [ -n "$srcbranch" ]; then
307 b=origin/"`repobranch "$d"`"
308 verbose git fetch origin || true
310 # TODO do this without pushing
311 verbose git checkout -b "$branch" "$b"
312 verbose git config "branch.$branch.remote" "$remote"
313 verbose git config "branch.$branch.merge" "refs/heads/$branch"
323 cd "$d0/$d" # am in a pipe, shouldn't use enter
324 git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
329 while read -r d BRANCH REV UPSTREAM TEXT; do
330 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
335 UPSTREAM=${UPSTREAM#\[}
336 UPSTREAM=${UPSTREAM%\]}
337 UPSTREAM=${UPSTREAM%:*}
340 TEXT="$UPSTREAM $TEXT"
344 if [ x"$REV" = x"->" ]; then
347 BRANCH=${BRANCH#remotes/}
348 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
349 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
350 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"
364 printf "%-60s %s\n" "$BRANCH" "$r"
371 dv=`visible_repo_name "$d"`
372 enter "$d0/$d" verbose
373 r=`git symbolic-ref HEAD`
375 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
376 # we have uncommitted changes
377 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
378 if ! verbose git merge origin/"`repobranch "$d"`"; then
379 check_mergeconflict "$d"
380 exit 1 # this should ALWAYS be fatal
390 dv=`visible_repo_name "$d"`
391 enter "$d0/$d" verbose
392 r=`git symbolic-ref HEAD`
394 diffdata=`git diff --color HEAD`
395 if [ -n "$diffdata" ]; then
396 # we have uncommitted changes
397 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?" 'echo "$diffdata" | less -r'; then
398 verbose git commit -a
401 rem=`git config "branch.$r.remote" || echo origin`
402 bra=`git config "branch.$r.merge" || echo "$r"`
404 if ! git rev-parse "$upstream" >/dev/null 2>&1; then
405 upstream="origin/`repobranch "$d"`"
407 logdata=`git log --color "$upstream".."$r"`
408 if [ -n "$logdata" ]; then
409 if yesno "Push \"$r\" in $dv?" 'echo "$logdata" | less -r'; then
410 verbose git push "$rem" HEAD
413 if [ x"$submit" = x"-s" ]; then
416 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
424 if [ -n "$WE_HATE_OUR_USERS" ]; then
425 TARGETS="sv-debug cl-debug"
426 if [ -z "$CC" ]; then
429 elif [ x"`uname`" = x"Darwin" ] && ( [ -d /Library/Frameworks/SDL.framework ] || [ -d $(HOME)/Library/Frameworks/SDL.framework ] ); then
430 # AGL is broken in Snow Leopard, so let's default to SDL if it is available.
431 TARGETS="sv-debug sdl-debug"
433 TARGETS="sv-debug cl-debug sdl-debug"
458 if [ -z "$MAKEFLAGS" ]; then
459 if [ -f /proc/cpuinfo ]; then
460 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
461 if [ $ncpus -gt 1 ]; then
467 MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
470 if [ -n "$WE_HATE_OUR_USERS" ]; then
471 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
474 enter "$d0/fteqcc" verbose
476 verbose make $MAKEFLAGS clean
478 verbose make $MAKEFLAGS
479 enter "$d0/data/xonotic-data.pk3dir" verbose
481 verbose make $MAKEFLAGS clean
483 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
484 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
485 enter "$d0/darkplaces" verbose
487 verbose make $MAKEFLAGS clean
489 for T in $TARGETS; do
490 verbose make $MAKEFLAGS "$@" "$T"
492 verbose "$SELF" update-maps
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/Xonotic-SDL.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" ] && ! [ x"`uname`" = x"Darwin" ]; 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 [ x"$1" = x"-k" ]; then
548 if verbose cd "$d0/$d"; then
560 patchdir=`mktemp -d -t save-patches.XXXXXX`
562 enter "$d0/$d" verbose
563 git branch -v -v | cut -c 3- | {
565 while read -r BRANCH REV UPSTREAM TEXT; do
568 UPSTREAM=${UPSTREAM#\[}
569 UPSTREAM=${UPSTREAM%\]}
570 UPSTREAM=${UPSTREAM%:*}
574 UPSTREAM=origin/"`repobranch "$d"`"
578 if [ x"$REV" = x"->" ]; then
581 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
582 echo "$d" > "$patchdir/$i/info.txt"
583 echo "$BRANCH" >> "$patchdir/$i/info.txt"
584 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
585 echo "$TRACK" >> "$patchdir/$i/info.txt"
588 rm -rf "$patchdir/$i"
593 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
598 patchdir=`mktemp -d -t restore-patches.XXXXXX`
599 ( cd "$patchdir" && tar xvzf - ) < "$infile"
601 for P in "$patchdir"/*/info.txt; do
608 verbose git checkout HEAD^0
609 verbose git branch -D "$BRANCH"
610 if [ x"$TRACK" = x"true" ]; then
611 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
613 verbose git branch -b "$BRANCH" "$UPSTREAM"
625 report=$report"$*$LF"
630 report=$report" $*$LF"
635 o=`"$@" | sed 's/^/ /' || true`
639 enter "$d0/$d" verbose
640 base="`repobranch "$d"`"
642 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
643 case "${ref#refs/remotes/origin/}" in
656 if [ -n "$branch" ]; then
657 if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
661 reportecho " Branch $ref:"
662 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
663 logdata=`git log --color "$base".."$ref"`
664 if [ -z "$logdata" ]; then
665 reportecho4 "--> not merging, no changes vs master"
666 if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
667 git push origin :"${ref#refs/remotes/origin/}"
668 reportecho4 "--> branch deleted"
671 diffdata=`git diff --color --find-copies-harder --ignore-space-change "$base"..."$ref"`
672 if [ -z "$diffdata" ]; then
673 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
674 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
675 git push origin :"${ref#refs/remotes/origin/}"
676 reportecho4 "--> branch deleted"
678 elif [ -n "$note" ]; then
679 reportdo4 echo "$note"
680 reportecho4 "--> not merging, already had this one rejected before"
681 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
683 org=`git rev-parse HEAD`
684 if ! git merge "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
685 git reset --hard "$org"
686 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
688 reportecho4 "--> merge failed"
689 elif ! "$SELF" compile 2>&1 | tee "$t"; then
690 git reset --hard "$org"
691 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
693 reportecho4 "--> compile failed"
694 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
695 git reset --hard "$org"
696 git notes edit "$ref"
697 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
698 if [ x"$note" = x"del" ]; then
699 git push origin :"${ref#refs/remotes/origin/}"
700 reportecho4 "--> test failed, branch deleted"
701 elif [ -n "$note" ]; then
702 reportdo4 echo "$note"
703 reportecho4 "--> test failed"
705 reportecho4 "--> test failed, postponed"
708 case ",`repoflags "$d"`," in
710 # we do quite a mess here... luckily we know $org
711 git fetch # svn needs to be current
712 git rebase -i --onto origin/master "$org"
713 git svn dcommit --add-author-from
714 git reset --hard "$org"
720 reportecho4 "--> MERGED"
721 if yesno "Delete original branch \"$ref\"?"; then
722 git push origin :"${ref#refs/remotes/origin/}"
723 reportecho4 "--> branch deleted"
727 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
728 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
729 if [ x"$note" = x"del" ]; then
730 git push origin :"${ref#refs/remotes/origin/}"
731 reportecho4 "--> branch deleted"
732 elif [ -n "$note" ]; then
733 reportdo4 echo "$note"
734 reportecho4 "--> rejected"
736 reportecho4 "--> postponed"
745 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
748 # release building goes here
750 mkdir -p Xonotic/"$1"
753 #"$SELF" each git clean -fxd
755 "$SELF" release-copy Docs/
756 "$SELF" release-copy misc/
757 "$SELF" release-copy server/
758 "$SELF" release-copy xonotic-linux-glx.sh
759 "$SELF" release-copy xonotic-linux-sdl.sh
760 "$SELF" release-mkdir data
761 "$SELF" release-mkdir fteqcc
764 rsync --exclude=.git -vaSHPAX "$1" Xonotic/"$1"
773 rsync --delete -zvaSHPAX "$srcdir"/ "$host:$buildpath/"
774 ssh "$host" ". ~/.profile && cd $buildpath && make clean $maketargets $makeflags"
775 for f in $targetfiles; do
776 rsync -zvaSHPAX "$host:$buildpath/${f%:*}" "${f##*:}"
782 fteqcc_maketargets=$3
784 darkplaces_maketargets=$5
786 "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "fteqcc" "$fteqcc_files"
787 "$SELF" release-compile-run "xonotic-build-$suffix" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "fteqcc" "$darkplaces_files"
789 release-engine-win32)
790 rsync --exclude=.git -vaSHPAX Xonotic/misc/buildfiles/w32/* Xonotic/
791 "$SELF" release-compile win32 \
792 '"DP_MAKE_TARGET=mingw CC="$HOME/mingw32/bin/i386-mingw32-gcc -g -DSUPPORTDIRECTX -DUSE_WSPIAPI_H -I$HOME/dxheaders" WINDRES="$HOME/mingw32/bin/i386-mingw32-windres" SDL_CONFIG="$HOME/sdl-win32/SDL-1.2.13/bin/sdl-config"' \
793 win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
794 debug 'darkplaces.exe:xonotic.exe darkplaces-sdl.exe:xonotic-sdl.exe darkplaces-dedicated.exe:xonotic-dedicated.exe'
797 rsync --exclude=.git -vaSHPAX Xonotic/misc/buildfiles/osx/* Xonotic/
798 "$SELF" release-compile osx \
799 'CC="gcc -g -arch i386 -arch ppc -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"' \
800 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
801 sdl-debug 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin'
803 release-engine-linux32)
804 "$SELF" release-compile linux32 \
805 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=$HOME/darkplaces-deps/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/darkplaces-deps/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/darkplaces-deps/include"' \
806 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
807 debug 'darkplaces-glx:Xonotic/xonotic-linux-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux-linux32-dedicated'
809 release-engine-linux64)
810 "$SELF" release-compile linux64 \
811 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=$HOME/darkplaces-deps/lib DP_LINK_TO_LIBJPEG=1 LDFLAGS_LIBJPEG="$HOME/darkplaces-deps/lib/libjpeg.a" CFLAGS_LIBJPEG="-I$HOME/darkplaces-deps/include"' \
812 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
813 debug 'darkplaces-glx:Xonotic/xonotic-linux-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux-linux64-dedicated'
816 "$SELF" release-engine-win32
817 "$SELF" release-engine-osx
818 "$SELF" release-engine-linux32
819 "$SELF" release-engine-linux64
823 for X in data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
825 cd Xonotic/data/xonotic-maps.pk3dir
832 # version numnber and stuff like that
835 verbose make -C Xonotic/data/xonotic-data.pk3dir FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" FTEQCCFLAGS_WATERMARK=
837 release-buildpk3-transform-raw)
840 release-buildpk3-transform-normal)
843 # texture: convert to jpeg and dds
845 export jpeg_qual_rgb=95
846 export jpeg_qual_a=99
850 find textures -type f -print0 | xargs -0 "$d0"/misc/tools/cached-converter.sh
852 release-buildpk3-transform-low)
855 # texture: convert to jpeg and dds
856 # music: reduce bitrate
858 export jpeg_qual_rgb=95
859 export jpeg_qual_a=99
863 find textures sound/cdtracks -type f -print0 | xargs -0 "$d0"/misc/tools/cached-converter.sh
877 rsync --exclude=.git -vaSHPAX "$src"/ "Xonotic/temp"
878 "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
880 zip -9r "../../$dst" . ########### 7za a -tzip -mx=9 "../../$dst" .
887 while [ "$#" -gt 1 ]; do
888 "$SELF" release-buildpk3 "$src" "Xonotic/${src%.pk3dir}$2.pk3" "$1"
894 "$SELF" release-buildpk3s data/font-dejavu.pk3dir raw ''
895 "$SELF" release-buildpk3s data/xonotic-data.pk3dir normal '' raw '-raw' low '-low'
896 "$SELF" release-buildpk3s data/xonotic-maps.pk3dir normal '' raw '-raw' low '-low'
897 "$SELF" release-buildpk3s data/xonotic-music.pk3dir normal '' raw '-raw' low '-low'
898 "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir low ''
901 "$SELF" release-prepare
903 "$SELF" release-finish
906 "$SELF" release-engine
912 echo " $SELF push [-s]"
913 echo " $SELF branches"
914 echo " $SELF branch [<remote>] <branchname>"
915 echo " $SELF branch <remote> <branchname> <srcbranchname>"
916 echo " $SELF checkout [<remote>] <branchname>"
917 echo " $SELF compile [-c] [<client>] <options>"
918 echo " $SELF run [<client>] <options>"
919 echo " $SELF each <command>"