6 # I use this in EVERY shell script ;)
12 while ! [ -f ./all ]; do
13 if [ x"`pwd`" = x"/" ]; then
14 echo "Cannot find myself."
15 echo "Please run this script with the working directory inside a Xonotic checkout."
23 # If we are on WINDOWS:
28 # 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 "$@"
39 echo >&2 "$ESC[1m$*$ESC[m"
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-music.pk3dir | | master |
116 data/xonotic-nexcompat.pk3dir | | master | no
117 darkplaces | | div0-stable | svn
118 netradiant | | master |
119 div0-gittools | | master | no
120 d0_blind_id | http://github.com/divVerent/d0_blind_id.git | master |
121 data/xonotic-maps.pk3dir | | master |
122 mediasource | | master | no
123 fteqcc | git://github.com/Blub/qclib.git | master |
125 # todo: in darkplaces, change repobranch to div0-stable
127 repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
129 base=`git config remote.origin.url`
132 base=${base%xonotic.git}
135 echo "The main repo is not xonotic.git, what have you done?"
139 pushbase=`git config remote.origin.pushurl || true`
142 pushbase=${pushbase%xonotic.git}
147 echo "The main repo is not xonotic.git, what have you done?"
154 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
155 if [ -n "$repo_t" ]; then
165 if [ x"$1" = x"." ]; then
166 echo "$base""xonotic.git"
168 echo "$base${1##*/}.git"
175 [ -n "$pushbase" ] || return 0
176 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
177 if [ -n "$repo_t" ]; then
182 echo "$pushbase$repo_t"
186 if [ x"$1" = x"." ]; then
187 echo "$pushbase""xonotic.git"
189 echo "$pushbase${1##*/}.git"
196 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
197 if [ -n "$repo_t" ]; then
206 echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
214 # if we have the dir, always keep it
216 msg "Repository $d enabled because it already exists"
220 # if .yes file exists, always keep it
221 if [ -f "$d.yes" ]; then
222 msg "Repository $d enabled by a .yes file"
226 # if we have .no file, skip
227 if [ -f "$d.no" ]; then
228 msg "Repository $d disabled by a .no file, delete $p.no to enable"
231 # if we have matching pk3, skip
232 if [ x"$p" != x"$d" ] && [ -f "$p" ]; then
233 msg "Repository $d disabled by matching .pk3 file, delete $p or create $d.yes to enable"
236 # if "no" flag is set, skip
239 msg "Repository $d disabled by default, create $d.yes to enable"
244 msg "Repository $d enabled by default"
251 if [ "$#" = 0 ]; then
257 fix_upstream_rebase()
259 if [ -z "$r_me" ] || [ -z "$r_other" ]; then
262 r_base=`git merge-base "$r_me" "$r_other"`
264 # no merge-base? upstream did filter-branch
265 if [ -n "$r_base" ]; then
266 # otherwise, check if the two histories are "similar"
267 r_l_me=`git log --pretty="format:%s" "$r_other".."$r_me" | grep -v "^Merge" | sort -u`
268 r_l_other=`git log --pretty="format:%s" "$r_me".."$r_other" | grep -v "^Merge" | sort -u`
270 # heuristics: upstream rebase/filter-branch if more than 50% of the commits of one of the sides are in the other too
271 r_lc_me=`echo "$r_l_me" | wc -l`
272 r_lc_other=`echo "$r_l_other" | wc -l`
273 r_lc_together=`{ echo "$r_l_me"; echo "$r_l_other"; } | sort -u | wc -l`
274 r_lc_same=$(($r_lc_me + $r_lc_other - $r_lc_together))
276 if [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_me )) ] || [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_other )) ]; then
277 if yesno "Probable upstream rebase detected, automatically fix?" 'git log --oneline --graph --date-order --left-right "$r_other"..."$r_me"'; then
278 git reset --hard "$r_me"
288 fix_upstream_rebase_mergeok()
290 r_me=`git rev-parse --revs-only HEAD^1 2>/dev/null || true`
291 r_other=`git rev-parse --revs-only HEAD^2 2>/dev/null || true`
295 fix_upstream_rebase_mergefail()
297 r_me=`git rev-parse --revs-only HEAD 2>/dev/null || true`
298 r_other=`git rev-parse --revs-only MERGE_HEAD 2>/dev/null || true`
304 verbose git config remote.origin.url "$1"
306 verbose git config remote.origin.pushurl "$2"
308 verbose git config --unset remote.origin.pushurl || true
310 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
311 verbose git config core.autocrlf input
312 if [ -z "`git config push.default`" ]; then
313 verbose git config push.default current # or is tracking better?
322 find "$@" -xtype f \( -executable -or -type l \) -print > "$ziplist"
323 7za a -tzip -mx=9 -x@"$ziplist" "$archive" "$@" || true
324 zip -9y -@<"$ziplist" "$archive" || true
336 enter "$d0/$d" verbose
337 verbose fix_upstream_rebase_mergefail && verbose fix_upstream_rebase_mergeok
343 pushurl=`repopushurl "$d"`
344 branch=`repobranch "$d"`
345 if [ -d "$d0/$d" ]; then
347 fix_git_config "$url" "$pushurl"
354 if [ x"$1" = x"-N" ]; then
362 pushurl=`repopushurl "$d"`
363 branch=`repobranch "$d"`
364 if [ -d "$d0/$d" ]; then
366 enter "$d0/$d" verbose
367 r=`git symbolic-ref HEAD`
369 if git config branch.$r.remote >/dev/null 2>&1; then
370 if ! verbose git pull; then
371 fix_upstream_rebase_mergefail || true
372 check_mergeconflict "$d"
373 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
376 fix_upstream_rebase_mergeok || true
381 checkself "$cmd" "$@"
383 verbose git remote prune origin
387 verbose git clone "$url" "$d0/$d"
388 enter "$d0/$d" verbose
389 fix_git_config "$url" "$pushurl"
390 if [ "$branch" != "master" ]; then
391 verbose git checkout --track -b "$branch" origin/"$branch"
398 misc/tools/xonotic-map-compiler-autobuild download
402 if [ x"$1" = x"-f" ]; then
408 if [ -z "$branch" ]; then
411 branch=${remote#origin/}
422 enter "$d0/$d" verbose
424 if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
426 verbose git checkout $checkoutflags "$b"
427 elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
429 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
432 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
434 verbose git checkout $checkoutflags "$b"
435 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
437 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
439 echo "WTF? Not even branch $b doesn't exist in $d"
444 checkself "$cmd" "$@"
448 echo "The requested branch was not found in any repository."
456 if [ -z "$branch" ]; then
460 if [ -z "$branch" ]; then
463 r=`git symbolic-ref HEAD`
470 dv=`visible_repo_name "$d"`
471 enter "$d0/$d" verbose
472 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
473 echo "Already having this branch in $dv."
475 if yesno "Branch in $dv?"; then
476 if [ -n "$srcbranch" ]; then
479 b=origin/"`repobranch "$d"`"
480 verbose git fetch origin || true
482 # TODO do this without pushing
483 verbose git checkout -b "$branch" "$b"
484 verbose git config "branch.$branch.remote" "$remote"
485 verbose git config "branch.$branch.merge" "refs/heads/$branch"
495 cd "$d0/$d" # am in a pipe, shouldn't use enter
496 git branch -r -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
501 while read -r d BRANCH REV TEXT; do
502 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
505 if [ x"$REV" = x"->" ]; then
508 BRANCH=${BRANCH#remotes/}
509 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
510 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
511 eval "r=\$branches_repos_$ID"
513 eval "branches_repos_$ID=\$r"
515 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
516 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
517 eval "r=\$branches_repos_$ID"
518 printf "%-60s %s\n" "$BRANCH" "$r"
525 dv=`visible_repo_name "$d"`
526 enter "$d0/$d" verbose
527 r=`git symbolic-ref HEAD`
529 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
530 # we have uncommitted changes
531 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
532 if ! verbose git merge origin/"`repobranch "$d"`"; then
533 check_mergeconflict "$d"
534 exit 1 # this should ALWAYS be fatal
544 dv=`visible_repo_name "$d"`
545 enter "$d0/$d" verbose
546 r=`git symbolic-ref HEAD`
548 diffdata=`git diff --color HEAD`
549 if [ -n "$diffdata" ]; then
550 # we have uncommitted changes
551 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?" 'echo "$diffdata" | less -r'; then
552 verbose git commit -a
555 rem=`git config "branch.$r.remote" || echo origin`
556 bra=`git config "branch.$r.merge" || echo "$r"`
557 upstream="$rem/${bra#refs/heads/}"
558 if ! git rev-parse "$upstream" >/dev/null 2>&1; then
559 upstream="origin/`repobranch "$d"`"
561 logdata=`git log --color "$upstream".."$r"`
562 if [ -n "$logdata" ]; then
563 if yesno "Push \"$r\" in $dv?" 'echo "$logdata" | less -r'; then
564 verbose git push "$rem" HEAD
567 if [ x"$submit" = x"-s" ]; then
570 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
583 if [ -z "$CC" ]; then
584 export CC="gcc -DSUPPORTIPV6"
597 export CC="$CC -g -mtune=native -march=native"
605 if [ -n "$WE_HATE_OUR_USERS" ]; then
606 TARGETS="sv-$debug cl-$debug"
607 elif [ x"`uname`" = x"Darwin" ]; then
610 TARGETS="sv-$debug cl-$debug sdl-$debug"
613 # AGL cannot be compiled on systems with a kernel > 10.x (Snow Leopard)
614 TARGETS="sv-$debug sdl-$debug"
617 export CC="$CC -I$PWD/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks/SDL.framework/Headers -F$PWD/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
619 TARGETS="sv-$debug cl-$debug sdl-$debug"
621 if [ $# -gt 0 ] && [ x"$1" = x"" ]; then
622 # if we give the command make the arg "", it will surely fail (invalid filename),
623 # so better handle it as an empty client option
626 elif [ -n "$1" ]; then
628 TARGETS_SAVE=$TARGETS
633 TARGETS="$TARGETS sdl-debug"
636 TARGETS="$TARGETS cl-debug"
639 TARGETS="$TARGETS sv-debug"
642 BAD_TARGETS="$BAD_TARGETS $X"
646 if [ -n "$TARGETS" ]; then # at least a valid client
648 else # no valid client, let's assume this option is not meant to be a client then
649 TARGETS=$TARGETS_SAVE
653 if [ -z "$MAKEFLAGS" ]; then
654 if [ -f /proc/cpuinfo ]; then
655 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
656 if [ $ncpus -gt 1 ]; then
660 if [ -n "$WE_HATE_OUR_USERS" ]; then
661 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw LIB_JPEG= CFLAGS_LIBJPEG="
665 enter "$d0/d0_blind_id" verbose
667 verbose make $MAKEFLAGS distclean
669 if ! [ -f Makefile ]; then
670 verbose sh autogen.sh
673 verbose make $MAKEFLAGS
675 enter "$d0/fteqcc" verbose
677 verbose make $MAKEFLAGS clean
679 verbose make $MAKEFLAGS
681 enter "$d0/data/xonotic-data.pk3dir" verbose
683 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
685 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
687 enter "$d0/darkplaces" verbose
688 if [ x"$BAD_TARGETS" = x" " ]; then
689 echo "Warning: invalid empty client, default clients will be used."
692 verbose make $MAKEFLAGS clean
694 for T in $TARGETS; do
695 verbose make $MAKEFLAGS STRIP=: "$@" "$T"
697 for T in $BAD_TARGETS; do
698 echo "Warning: discarded invalid client $T."
701 verbose "$SELF" update-maps
704 if [ -n "$WE_HATE_OUR_USERS" ]; then
706 export PATH="$d0/misc/buildfiles/win32:$d0/d0_blind_id/.libs:$PATH"
707 elif [ x"`uname`" = x"Darwin" ]; then
708 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS:$d0/d0_blind_id/.libs"
709 export DYLD_FRAMEWORK_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
712 export LD_LIBRARY_PATH="$d0/d0_blind_id/.libs"
716 sdl|glx|agl|dedicated)
725 if ! [ -x "darkplaces/darkplaces$client" ]; then
726 if [ -x "darkplaces/darkplaces$client.exe" ]; then
729 echo "Client darkplaces/darkplaces$client not found, aborting"
733 set -- "darkplaces/darkplaces$client" -xonotic -mygames "$@"
735 # if pulseaudio is running: USE IT
736 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
737 if ps -C pulseaudio >/dev/null; then
738 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
739 export SDL_AUDIODRIVER=pulse
746 if [ -n "$USE_GDB" ]; then
747 set -- gdb --args "$@"
748 elif which gdb >/dev/null 2>&1; then
749 set -- gdb --batch -x savecore.gdb --args "$@"
750 elif which catchsegv >/dev/null 2>&1; then
751 set -- catchsegv "$@"
755 if [ -f xonotic.core ]; then
756 if yesno "The program has CRASHED. Do you want to examine the core dump?"; then
757 gdb "$binary" xonotic.core
758 #elif yesno "You did not want to examine the core dump. Do you want to provide it - including your DarkPlaces checkout - to the Xonotic developers?"; then
759 # tar cvzf xonotic.core.tar.gz xonotic.core darkplaces/*.c darkplaces/*.h
761 # rm -f xonotic.core.tar.gz
763 echo "The core dump can be examined later by"
764 echo " gdb $binary xonotic.core"
770 if [ x"$1" = x"-k" ]; then
775 if verbose cd "$d0/$d"; then
787 patchdir=`mktemp -d -t save-patches.XXXXXX`
789 enter "$d0/$d" verbose
790 git branch -v -v | cut -c 3- | {
792 while read -r BRANCH REV UPSTREAM TEXT; do
795 UPSTREAM=${UPSTREAM#\[}
796 UPSTREAM=${UPSTREAM%\]}
797 UPSTREAM=${UPSTREAM%:*}
801 UPSTREAM=origin/"`repobranch "$d"`"
805 if [ x"$REV" = x"->" ]; then
808 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
809 echo "$d" > "$patchdir/$i/info.txt"
810 echo "$BRANCH" >> "$patchdir/$i/info.txt"
811 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
812 echo "$TRACK" >> "$patchdir/$i/info.txt"
815 rm -rf "$patchdir/$i"
820 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
825 patchdir=`mktemp -d -t restore-patches.XXXXXX`
826 ( cd "$patchdir" && tar xvzf - ) < "$infile"
828 for P in "$patchdir"/*/info.txt; do
835 verbose git checkout HEAD^0
836 verbose git branch -D "$BRANCH"
837 if [ x"$TRACK" = x"true" ]; then
838 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
840 verbose git branch -b "$BRANCH" "$UPSTREAM"
852 report=$report"$*$LF"
857 report=$report" $*$LF"
862 o=`"$@" | sed 's/^/ /' || true`
866 enter "$d0/$d" verbose
867 base="`repobranch "$d"`"
869 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
870 case "${ref#refs/remotes/origin/}" in
883 if [ -n "$branch" ]; then
884 if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
893 l0=`git rev-list "$base".."$ref" | wc -l`
894 l1=`git rev-list master.."$ref" | wc -l`
895 if [ $l0 -gt $l1 ]; then
902 reportecho " Branch $ref:"
903 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
904 logdata=`git log --color "$realbase".."$ref"`
905 if [ -z "$logdata" ]; then
906 reportecho4 "--> not merging, no changes vs master"
907 if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
908 git push origin :"${ref#refs/remotes/origin/}"
909 reportecho4 "--> branch deleted"
912 diffdata=`git diff --color --find-copies-harder --ignore-space-change "$realbase"..."$ref"`
913 if [ -z "$diffdata" ]; then
914 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
915 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
916 git push origin :"${ref#refs/remotes/origin/}"
917 reportecho4 "--> branch deleted"
919 elif [ -z "$branch" ] && [ -n "$note" ]; then
920 reportdo4 echo "$note"
921 reportecho4 "--> not merging, already had this one rejected before"
922 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
923 git checkout "$realbase"
924 org=`git rev-parse HEAD`
925 if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
926 git reset --hard "$org"
927 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
929 reportecho4 "--> merge failed"
930 elif ! "$SELF" compile 2>&1 | tee "$t"; then
931 git reset --hard "$org"
932 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
934 reportecho4 "--> compile failed"
935 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
936 git reset --hard "$org"
937 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
938 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
939 if [ x"$note" = x"del" ]; then
940 git push origin :"${ref#refs/remotes/origin/}"
941 reportecho4 "--> test failed, branch deleted"
942 elif [ -n "$note" ]; then
943 reportdo4 echo "$note"
944 reportecho4 "--> test failed"
946 reportecho4 "--> test failed, postponed"
950 case ",`repoflags "$d"`," in
952 # we do quite a mess here... luckily we know $org
953 git fetch # svn needs to be current
954 git rebase -i --onto origin/master "$org"
955 git svn dcommit --add-author-from
956 git reset --hard "$org"
962 reportecho4 "--> MERGED"
963 if yesno "Delete original branch \"$ref\"?"; then
964 git push origin :"${ref#refs/remotes/origin/}"
965 reportecho4 "--> branch deleted"
969 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
970 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
971 if [ x"$note" = x"del" ]; then
972 git push origin :"${ref#refs/remotes/origin/}"
973 reportecho4 "--> branch deleted"
974 elif [ -n "$note" ]; then
975 reportdo4 echo "$note"
976 reportecho4 "--> rejected"
978 reportecho4 "--> postponed"
987 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
999 # ./all clean [-m] [-f | -fu | -fU] [-r] [-D]
1000 # ./all clean --reclone
1003 if [ x"$1" = x"--reclone" ]; then
1010 elif [ x"$1" = x"-f" ]; then
1012 elif [ x"$1" = x"-u" ]; then
1014 elif [ x"$1" = x"-U" ]; then
1017 elif [ x"$1" = x"-fu" ]; then
1020 elif [ x"$1" = x"-fU" ]; then
1024 elif [ x"$1" = x"-m" ]; then
1026 elif [ x"$1" = x"-r" ]; then
1028 elif [ x"$1" = x"-D" ]; then
1041 if $gotoupstream; then
1043 msg "Must also use -f (delete local changes) when using -u"
1046 if $gotomaster; then
1047 if $fetchupstream; then
1048 verbose git fetch origin
1049 verbose git remote prune origin
1051 verbose git checkout -f "`repobranch "$d"`"
1052 verbose git reset --hard origin/"`repobranch "$d"`"
1054 r=`git symbolic-ref HEAD`
1056 rem=`git config "branch.$r.remote" || echo origin`
1057 bra=`git config "branch.$r.merge" || echo "$r"`
1058 upstream="$rem/${bra#refs/heads/}"
1059 if $fetchupstream; then
1060 verbose git fetch "$rem"
1061 verbose git remote prune "$rem"
1063 if ! git rev-parse "$upstream" >/dev/null 2>&1; then
1064 upstream="origin/`repobranch "$d"`"
1066 verbose git reset --hard "$upstream"
1068 elif $gotomaster; then
1070 verbose git checkout -f "`repobranch "$d"`"
1071 verbose git reset --hard
1073 verbose git checkout "`repobranch "$d"`"
1076 verbose git reset --hard
1078 if $rmuntracked; then
1081 verbose git clean -df
1084 verbose git clean -xdf
1088 if $killbranches; then
1089 git for-each-ref --format='%(refname)' refs/heads/ | while IFS= read -r B; do
1090 if [ x"$B" != x"`git symbolic-ref HEAD`" ]; then
1091 verbose git branch -D "${B#refs/heads/}"
1094 git rev-parse refs/heads/master >/dev/null 2>&1 || verbose git branch -t master origin/master || true
1095 git rev-parse "refs/heads/`repobranch "$d"`" >/dev/null 2>&1 || verbose git branch -t "`repobranch "$d"`" origin/"`repobranch "$d"`" || true
1100 # release building goes here
1102 #"$SELF" each git clean -fxd
1103 case "$RELEASETYPE" in
1105 msg "Building a BETA"
1108 msg "Building a RELEASE"
1111 echo >&2 -n "$ESC[2J$ESC[H"
1118 msg " +---------------------------------------------------------.---+"
1120 msg " +---------------------------------------------------------^---+"
1122 msg " | / \ This is the official release build system. |"
1123 msg " | | | If you are not a member of the Xonotic Core Team, |"
1124 msg " | | STOP | you are not supposed to use this script and should |"
1125 msg " | | | instead use ./all compile to compile the engine |"
1126 msg " | \____/ and game code. |"
1128 msg " | [ I understand ] |"
1129 msg " +-------------------------------------------------------------+"
1131 # A LOT of build infrastructure is required:
1134 # - .ssh/config must be configured so the following
1135 # host names are reachable and have a compile
1136 # infrastructure set up:
1137 # - xonotic-build-linux32 (with gcc on x86)
1138 # - xonotic-build-linux64 (with gcc on x86_64)
1139 # - xonotic-build-win32 (with i586-mingw32msvc-g++)
1140 # - xonotic-build-win64 (with amd64-mingw32msvc-g++
1141 # and x86_64-w64-mingw32-g++)
1142 # - xonotic-build-osx (with Xcode and SDL.framework)
1143 # - AMD Compressonator installed in WINE
1144 # - ResEdit installed in WINE
1145 # - a lot of other requirements you will figure out
1146 # while reading the error messages
1147 # - environment variable RELEASETYPE set
1148 # - optionally, environment variable RELEASEDATE set
1153 verbose rm -rf Xonotic Xonotic*.zip
1154 verbose mkdir -p Xonotic
1155 if [ -n "$RELEASEDATE" ]; then
1156 verbose echo "$RELEASEDATE" > Xonotic/stamp.txt
1158 verbose date +%Y%m%d > Xonotic/stamp.txt
1160 verbose git archive --format=tar HEAD -- Docs misc server xonotic-linux-glx.sh xonotic-linux-sdl.sh misc/buildfiles key_0.d0pk | {
1162 verbose mkdir data fteqcc source source/darkplaces source/fteqcc
1164 verbose rm -rf misc/builddeps
1165 verbose mv misc/buildfiles/win32/* . || true
1166 verbose mv misc/buildfiles/win64 bin64 || true
1167 verbose mv misc/buildfiles/osx/* . || true
1168 verbose rm -rf misc/buildfiles
1169 verbose rm -rf misc/pki
1172 verbose cd darkplaces
1173 verbose git archive --format=tar HEAD
1175 verbose cd Xonotic/source/darkplaces
1180 verbose git archive --format=tar HEAD
1182 verbose cd Xonotic/source/fteqcc
1186 verbose cd data/xonotic-data.pk3dir
1187 verbose git archive --format=tar HEAD -- qcsrc Makefile
1189 verbose cd Xonotic/source
1192 rm -f Xonotic/key_15.d0pk
1194 release-compile-run)
1203 if [ -n "$targetfiles" ]; then
1204 case " $HOSTS_THAT_ARE_DISABLED " in
1209 case " $HOSTS_THAT_ARE_MYSELF " in
1211 verbose rsync --delete -zLvaSHP "$srcdir"/ "$buildpath/"
1212 verbose rsync --delete -zLvaSHP "$depsdir"/ "$buildpath.deps/"
1213 verbose ln -snf "$buildpath.deps" "$buildpath/.deps"
1214 verbose eval make -C "$buildpath" clean $maketargets $makeflags
1215 for f in $targetfiles; do
1216 verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
1220 verbose rsync --delete -zLvaSHP "$srcdir"/ "$host:$buildpath/"
1221 verbose rsync --delete -zLvaSHP "$depsdir"/ "$host:$buildpath.deps/"
1222 verbose ssh "$host" "ln -snf $buildpath.deps $buildpath/.deps && cd $buildpath && nice -`nice` make clean $maketargets $makeflags"
1223 for f in $targetfiles; do
1224 verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
1228 # now rebrand the binaries...
1229 for f in $targetfiles; do
1230 #verbose "$d0/misc/tools/rebrand-darkplaces-engine.sh" "${XONOTIC_BRAND:-$d0/misc/tools/xonotic.brand}" "${f##*:}" || true
1233 verbose "$d0/misc/tools/change-icon-of-exe.sh" "$d0/misc/logos/icons_ico/xonotic.ico" "$f"
1235 d=`mktemp -d -t rebrand.XXXXXX`
1237 echo "-mygames" > darkplaces.opt
1238 zip -9r darkplaces.zip darkplaces.opt
1251 fteqcc_maketargets=$3
1253 darkplaces_maketargets=$5
1255 host=xonotic-build-$suffix
1256 verbose "$SELF" release-compile-run "$host" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "Xonotic/source/fteqcc" "$d0/misc/builddeps/dp.$suffix" "$fteqcc_files"
1257 verbose "$SELF" release-compile-run "$host" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$d0/misc/builddeps/dp.$suffix" "$darkplaces_files"
1259 release-engine-win32)
1260 verbose "$SELF" release-compile win32 \
1261 'STRIP=: DP_MAKE_TARGET=mingw CC="i586-mingw32msvc-gcc -march=i686 -g -Wl,--dynamicbase -Wl,--nxcompat -I.deps/include -L.deps/lib -DUSE_WSPIAPI_H -DSUPPORTIPV6" WINDRES="i586-mingw32msvc-windres" SDL_CONFIG=".deps/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN32RELEASE=1 D3D=0' \
1262 win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
1264 verbose "$SELF" release-compile win32 \
1265 'STRIP=: DP_MAKE_TARGET=mingw CC="i586-mingw32msvc-gcc -g -Wl,--dynamicbase -Wl,--nxcompat -I.deps/include -L.deps/lib -DUSE_WSPIAPI_H -DSUPPORTIPV6" WINDRES="i586-mingw32msvc-windres" SDL_CONFIG=".deps/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN32RELEASE=1 D3D=0' \
1267 release 'darkplaces.exe:Xonotic/xonotic.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
1269 release-engine-win64)
1270 verbose "$SELF" release-compile win64 \
1271 'STRIP=: DP_MAKE_TARGET=mingw CC="amd64-mingw32msvc-gcc -g -Wl,--dynamicbase -Wl,--nxcompat -I.deps/include -L.deps/lib -DSUPPORTIPV6" WINDRES="amd64-mingw32msvc-windres" SDL_CONFIG=".deps/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN64RELEASE=1 D3D=0' \
1272 win 'fteqcc.exe:Xonotic/fteqcc/fteqcc-x64.exe' \
1273 'sv-release sdl-release' 'darkplaces-sdl.exe:Xonotic/xonotic-x64-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-x64-dedicated.exe'
1274 verbose "$SELF" release-compile win64 \
1275 'STRIP=: DP_MAKE_TARGET=mingw CC="x86_64-w64-mingw32-gcc -g -Wl,--dynamicbase -Wl,--nxcompat -I.deps/include -L.deps/lib -DSUPPORTIPV6" WINDRES="x86_64-w64-mingw32-windres" SDL_CONFIG=".deps/bin/sdl-config" LIB_JPEG= CFLAGS_LIBJPEG= WIN64RELEASE=1 D3D=0' \
1277 cl-release 'darkplaces.exe:Xonotic/xonotic-x64.exe'
1280 # gcc on OSX is buggy, needs -fno-reorder-blocks for a release build to succeed
1281 verbose "$SELF" release-compile osx \
1282 'STRIP=: CC="gcc -g -arch i386 -arch ppc -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -I.deps/include -L.deps/lib -fno-reorder-blocks -DSUPPORTIPV6"' \
1283 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
1284 'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
1285 verbose "$SELF" release-compile osx \
1286 'STRIP=: CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -I.deps/include -L.deps/lib -fno-reorder-blocks -DSUPPORTIPV6"' \
1288 'cl-release' 'darkplaces-agl:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-agl-bin'
1290 release-engine-linux32)
1291 verbose "$SELF" release-compile linux32 \
1292 'STRIP=: CC="gcc -m32 -march=i686 -g -I.deps/include -L.deps/lib -DSUPPORTIPV6" DP_MODPLUG_STATIC_LIBDIR=.deps/lib LIB_JPEG=.deps/lib/libjpeg.a DP_CRYPTO_STATIC_LIBDIR=.deps/lib' \
1293 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
1294 release 'darkplaces-glx:Xonotic/xonotic-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux32-dedicated'
1296 release-engine-linux64)
1297 verbose "$SELF" release-compile linux64 \
1298 'STRIP=: CC="gcc -m64 -g -I.deps/include -L.deps/lib -DSUPPORTIPV6" DP_MODPLUG_STATIC_LIBDIR=.deps/lib LIB_JPEG=.deps/lib/libjpeg.a DP_CRYPTO_STATIC_LIBDIR=.deps/lib' \
1299 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
1300 release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
1303 verbose "$SELF" release-engine-linux32 &
1304 verbose "$SELF" release-engine-linux64 &
1305 verbose "$SELF" release-engine-win32 &
1306 verbose "$SELF" release-engine-win64 &
1307 verbose "$SELF" release-engine-osx &
1316 verbose "$SELF" update-maps
1319 case "$RELEASETYPE" in
1321 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 clean all
1324 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 FTEQCCFLAGS_WATERMARK= clean all
1327 verbose rm -f Xonotic/source/*/fteqcc.log
1329 release-buildpk3-transform-raw)
1332 release-buildpk3-transform-normal)
1335 # texture: convert to jpeg and dds
1336 verbose export do_jpeg=true
1337 verbose export jpeg_qual_rgb=95
1338 verbose export jpeg_qual_a=99
1339 verbose export do_dds=true
1340 verbose export dds_flags=
1341 verbose export do_ogg=false
1342 verbose export del_src=true
1343 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1345 release-buildpk3-transform-low)
1348 # texture: convert to jpeg and dds
1349 # music: reduce bitrate
1350 verbose export do_jpeg=true
1351 verbose export jpeg_qual_rgb=80
1352 verbose export jpeg_qual_a=95
1353 verbose export do_dds=false
1354 verbose export do_ogg=true
1355 verbose export ogg_qual=1
1356 verbose export del_src=true
1357 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1359 release-buildpk3-transform-lowdds)
1362 # texture: convert to jpeg and dds
1363 # music: reduce bitrate
1364 verbose export do_jpeg=false
1365 verbose export do_jpeg_if_not_dds=true
1366 verbose export jpeg_qual_rgb=80
1367 verbose export jpeg_qual_a=95
1368 verbose export do_dds=true
1369 verbose export dds_flags=
1370 verbose export do_ogg=true
1371 verbose export ogg_qual=1
1372 verbose export del_src=true
1373 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1386 verbose rm -rf Xonotic/temp
1387 verbose mkdir -p Xonotic/temp
1390 verbose git archive --format=tar HEAD
1392 verbose cd Xonotic/temp
1395 verbose cd Xonotic/temp
1396 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
1397 verbose cp ../source/progs.dat .
1398 verbose cp ../source/csprogs.dat .
1399 verbose cp ../source/menu.dat .
1400 verbose rm -rf qcsrc
1401 gv=`grep "^gameversion " "defaultXonotic.cfg" | awk '{ print $2 }'`
1402 major=$(($gv / 10000))
1403 minor=$(($gv / 100 - $major * 100))
1404 patch=$(($gv - $major * 10000 - $minor * 100))
1405 versionstr="$major.$minor.$patch"
1406 case "$RELEASETYPE" in
1408 versionstr="$versionstr""beta"
1412 s/^set g_xonoticversion [^ ]* /set g_xonoticversion $versionstr /;
1413 s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
1414 s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
1415 " defaultXonotic.cfg
1417 verbose cd gfx/menu/luminos
1418 verbose cp "$d0"/mediasource/gfx/menu/luminos_versionbuilder/background_l2.svg .
1419 verbose "$d0"/mediasource/gfx/menu/luminos_versionbuilder/versionbuilder "$versionstr"
1420 verbose rm background_l2.svg
1423 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
1424 for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
1425 if [ -f "$X" ]; then
1427 verbose rm -f maps/*.log maps/*.irc maps/*.lin
1431 verbose export git_src_repo="$d0/$src" # skip hash-object
1432 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
1433 verbose mkzip "../../$dst" *
1435 verbose rm -rf Xonotic/temp
1438 stamp=`cat Xonotic/stamp.txt`
1444 dst="data/xonotic-$stamp-${dst#data/xonotic-}"
1450 while [ "$#" -gt 1 ]; do
1451 verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
1457 verbose "$SELF" release-buildpk3s data/font-nimbussansl.pk3dir raw ''
1458 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir normal '' raw '-raw' low '-low' lowdds '-lowdds'
1459 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir normal '' raw '-raw' low '-low' lowdds '-lowdds'
1460 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir raw '' low '-low'
1461 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir low ''
1463 release-pack-needsx11)
1466 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
1469 verbose "$SELF" release-pack
1474 stamp=`cat Xonotic/stamp.txt`
1475 # exe and dll files do not need +x, so this makes them eligible for 7zip compression too
1476 chmod a-x Xonotic/*.exe Xonotic/*.dll || true
1477 # let's pass crypto import laws of some nasty countries
1478 crypto_libs=`find Xonotic -name \*d0_rijndael\*`
1479 if [ -n "$crypto_libs" ]; then
1480 verbose mkzip Xonotic-$stamp-crypto.zip \
1484 # build the archives
1485 verbose mkzip Xonotic-$stamp-engine.zip \
1487 Xonotic/bin64/*.dll \
1490 Xonotic/xonotic.exe \
1491 Xonotic/source/darkplaces/
1492 verbose cp Xonotic-$stamp-engine.zip Xonotic-$stamp-common.zip
1493 verbose mkzip Xonotic-$stamp-common.zip \
1494 Xonotic/source/fteqcc/ \
1495 Xonotic/source/qcsrc/ \
1500 Xonotic/key_0.d0pk \
1501 Xonotic/data/font-nimbussansl-$stamp.pk3
1502 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
1503 verbose mkzip0 Xonotic-$stamp.zip \
1504 Xonotic/data/xonotic-$stamp-data.pk3 \
1505 Xonotic/data/xonotic-$stamp-maps.pk3 \
1506 Xonotic/data/xonotic-$stamp-music.pk3 \
1507 Xonotic/data/xonotic-$stamp-nexcompat.pk3
1508 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-low.zip
1509 verbose mkzip0 Xonotic-$stamp-low.zip \
1510 Xonotic/data/xonotic-$stamp-data-low.pk3 \
1511 Xonotic/data/xonotic-$stamp-maps-low.pk3 \
1512 Xonotic/data/xonotic-$stamp-music-low.pk3
1513 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-lowdds.zip
1514 verbose mkzip0 Xonotic-$stamp-lowdds.zip \
1515 Xonotic/data/xonotic-$stamp-data-lowdds.pk3 \
1516 Xonotic/data/xonotic-$stamp-maps-lowdds.pk3 \
1517 Xonotic/data/xonotic-$stamp-music-low.pk3
1518 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
1519 verbose mkzip0 Xonotic-$stamp-high.zip \
1520 Xonotic/data/xonotic-$stamp-data-raw.pk3 \
1521 Xonotic/data/xonotic-$stamp-maps-raw.pk3 \
1522 Xonotic/data/xonotic-$stamp-music.pk3 \
1523 Xonotic/data/xonotic-$stamp-nexcompat.pk3
1526 verbose "$SELF" release-prepare
1527 verbose "$SELF" release-maps
1528 verbose "$SELF" release-engine
1529 verbose "$SELF" release-qc
1530 verbose "$SELF" release-pack-needsx11
1531 verbose "$SELF" release-zip
1536 echo " $SELF admin-merge [<branch>]"
1537 echo " $SELF branch <branch>"
1538 echo " $SELF branch <remote> <branch> [<srcbranch>]"
1539 echo " $SELF branches"
1540 echo " $SELF checkout|switch <branch>"
1541 echo " $SELF checkout|switch <remote>/<branch>"
1542 echo " $SELF clean [-m] [-f | -fu | -fU] [-r] [-D]"
1543 echo " $SELF clean --reclone"
1544 echo " $SELF compile [-c]"
1545 echo " $SELF each|foreach [-k] command..."
1546 echo " $SELF fix_upstream_rebase"
1548 echo " $SELF push|commit [-s]"
1549 echo " $SELF release"
1550 echo " $SELF restore-patches"
1551 echo " $SELF run [sdl|glx|wgl|agl|dedicated] options..."
1552 echo " $SELF save-patches"
1553 echo " $SELF update-maps"
1554 echo " $SELF update|pull [-N]"