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 data/xonotic-maps.pk3dir | | master |
121 mediasource | | master | no
122 fteqcc | http://github.com/Blub/qclib.git | 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?"
138 pushbase=`git config remote.origin.pushurl || true`
141 pushbase=${pushbase%xonotic.git}
146 echo "The main repo is not xonotic.git, what have you done?"
153 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
154 if [ -n "$repo_t" ]; then
164 if [ x"$1" = x"." ]; then
165 echo "$base""xonotic.git"
167 echo "$base${1##*/}.git"
174 [ -n "$pushbase" ] || return 0
175 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
176 if [ -n "$repo_t" ]; then
181 echo "$pushbase$repo_t"
185 if [ x"$1" = x"." ]; then
186 echo "$pushbase""xonotic.git"
188 echo "$pushbase${1##*/}.git"
195 repo_t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
196 if [ -n "$repo_t" ]; then
205 echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 4 | tr -d ' '
213 # if we have the dir, always keep it
215 msg "Repository $d enabled because it already exists"
219 # if .yes file exists, always keep it
220 if [ -f "$d.yes" ]; then
221 msg "Repository $d enabled by a .yes file"
225 # if we have .no file, skip
226 if [ -f "$d.no" ]; then
227 msg "Repository $d disabled by a .no file, delete $p.no to enable"
230 # if we have matching pk3, skip
231 if [ x"$p" != x"$d" ] && [ -f "$p" ]; then
232 msg "Repository $d disabled by matching .pk3 file, delete $p or create $d.yes to enable"
235 # if "no" flag is set, skip
238 msg "Repository $d disabled by default, create $d.yes to enable"
243 msg "Repository $d enabled by default"
250 if [ "$#" = 0 ]; then
256 fix_upstream_rebase()
258 if [ -z "$r_me" ] || [ -z "$r_other" ]; then
261 r_base=`git merge-base "$r_me" "$r_other"`
263 # no merge-base? upstream did filter-branch
264 if [ -n "$r_base" ]; then
265 # otherwise, check if the two histories are "similar"
266 r_l_me=`git log --pretty="format:%s" "$r_other".."$r_me" | grep -v "^Merge" | sort -u`
267 r_l_other=`git log --pretty="format:%s" "$r_me".."$r_other" | grep -v "^Merge" | sort -u`
269 # heuristics: upstream rebase/filter-branch if more than 50% of the commits of one of the sides are in the other too
270 r_lc_me=`echo "$r_l_me" | wc -l`
271 r_lc_other=`echo "$r_l_other" | wc -l`
272 r_lc_together=`{ echo "$r_l_me"; echo "$r_l_other"; } | sort -u | wc -l`
273 r_lc_same=$(($r_lc_me + $r_lc_other - $r_lc_together))
275 if [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_me )) ] || [ $(( $r_lc_same * 2 )) -gt $(( $r_lc_other )) ]; then
276 if yesno "Probable upstream rebase detected, automatically fix?" 'git log --oneline --graph --date-order --left-right "$r_other"..."$r_me"'; then
277 git reset --hard "$r_me"
287 fix_upstream_rebase_mergeok()
289 r_me=`git rev-parse --revs-only HEAD^1 2>/dev/null || true`
290 r_other=`git rev-parse --revs-only HEAD^2 2>/dev/null || true`
294 fix_upstream_rebase_mergefail()
296 r_me=`git rev-parse --revs-only HEAD 2>/dev/null || true`
297 r_other=`git rev-parse --revs-only MERGE_HEAD 2>/dev/null || true`
303 verbose git config remote.origin.url "$1"
305 verbose git config remote.origin.pushurl "$2"
307 verbose git config --unset remote.origin.pushurl || true
309 verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
310 verbose git config core.autocrlf input
311 if [ -z "`git config push.default`" ]; then
312 verbose git config push.default current # or is tracking better?
321 find "$@" -xtype f \( -executable -or -type l \) -print > "$ziplist"
322 7za a -tzip -mx=9 -x@"$ziplist" "$archive" "$@" || true
323 zip -9y -@<"$ziplist" "$archive" || true
335 enter "$d0/$d" verbose
336 verbose fix_upstream_rebase_mergefail && verbose fix_upstream_rebase_mergeok
342 pushurl=`repopushurl "$d"`
343 branch=`repobranch "$d"`
344 if [ -d "$d0/$d" ]; then
346 fix_git_config "$url" "$pushurl"
353 if [ x"$1" = x"-N" ]; then
361 pushurl=`repopushurl "$d"`
362 branch=`repobranch "$d"`
363 if [ -d "$d0/$d" ]; then
365 enter "$d0/$d" verbose
366 r=`git symbolic-ref HEAD`
368 if git config branch.$r.remote >/dev/null 2>&1; then
369 if ! verbose git pull; then
370 fix_upstream_rebase_mergefail || true
371 check_mergeconflict "$d"
372 echo "Pulling failed. Press ENTER to continue, or Ctrl-C to abort."
375 fix_upstream_rebase_mergeok || true
380 checkself "$cmd" "$@"
382 verbose git remote prune origin
386 verbose git clone "$url" "$d0/$d"
387 enter "$d0/$d" verbose
388 fix_git_config "$url" "$pushurl"
389 if [ "$branch" != "master" ]; then
390 verbose git checkout --track -b "$branch" origin/"$branch"
397 misc/tools/xonotic-map-compiler-autobuild download
401 if [ x"$1" = x"-f" ]; then
407 if [ -z "$branch" ]; then
410 branch=${remote#origin/}
421 enter "$d0/$d" verbose
423 if [ -n "$b" ] && git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
425 verbose git checkout $checkoutflags "$b"
426 elif [ -n "$b" ] && git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
428 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
431 if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
433 verbose git checkout $checkoutflags "$b"
434 elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
436 verbose git checkout $checkoutflags --track -b "$b" "$remote/$b"
438 echo "WTF? Not even branch $b doesn't exist in $d"
443 checkself "$cmd" "$@"
447 echo "The requested branch was not found in any repository."
455 if [ -z "$branch" ]; then
459 if [ -z "$branch" ]; then
462 r=`git symbolic-ref HEAD`
469 dv=`visible_repo_name "$d"`
470 enter "$d0/$d" verbose
471 if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
472 echo "Already having this branch in $dv."
474 if yesno "Branch in $dv?"; then
475 if [ -n "$srcbranch" ]; then
478 b=origin/"`repobranch "$d"`"
479 verbose git fetch origin || true
481 # TODO do this without pushing
482 verbose git checkout -b "$branch" "$b"
483 verbose git config "branch.$branch.remote" "$remote"
484 verbose git config "branch.$branch.merge" "refs/heads/$branch"
494 cd "$d0/$d" # am in a pipe, shouldn't use enter
495 git branch -r -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
500 while read -r d BRANCH REV TEXT; do
501 if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
504 if [ x"$REV" = x"->" ]; then
507 BRANCH=${BRANCH#remotes/}
508 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
509 branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
510 eval "r=\$branches_repos_$ID"
512 eval "branches_repos_$ID=\$r"
514 echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
515 ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
516 eval "r=\$branches_repos_$ID"
517 printf "%-60s %s\n" "$BRANCH" "$r"
524 dv=`visible_repo_name "$d"`
525 enter "$d0/$d" verbose
526 r=`git symbolic-ref HEAD`
528 if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
529 # we have uncommitted changes
530 if yesno "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"; then
531 if ! verbose git merge origin/"`repobranch "$d"`"; then
532 check_mergeconflict "$d"
533 exit 1 # this should ALWAYS be fatal
543 dv=`visible_repo_name "$d"`
544 enter "$d0/$d" verbose
545 r=`git symbolic-ref HEAD`
547 diffdata=`git diff --color HEAD`
548 if [ -n "$diffdata" ]; then
549 # we have uncommitted changes
550 if yesno "Uncommitted changes in \"$r\" in $dv. Commit?" 'echo "$diffdata" | less -r'; then
551 verbose git commit -a
554 rem=`git config "branch.$r.remote" || echo origin`
555 bra=`git config "branch.$r.merge" || echo "$r"`
556 upstream="$rem/${bra#refs/heads/}"
557 if ! git rev-parse "$upstream" >/dev/null 2>&1; then
558 upstream="origin/`repobranch "$d"`"
560 logdata=`git log --color "$upstream".."$r"`
561 if [ -n "$logdata" ]; then
562 if yesno "Push \"$r\" in $dv?" 'echo "$logdata" | less -r'; then
563 verbose git push "$rem" HEAD
566 if [ x"$submit" = x"-s" ]; then
569 verbose git push "$rem" HEAD:"${bra%%/*}/finished/${bra#*/}"
581 if [ -z "$CC" ]; then
582 export CC="gcc -DSUPPORTIPV6"
594 export CC="$CC -g -mtune=native -march=native"
602 if [ -n "$WE_HATE_OUR_USERS" ]; then
603 TARGETS="sv-$debug cl-$debug"
604 elif [ x"`uname`" = x"Darwin" ]; then
607 TARGETS="sv-$debug cl-$debug sdl-$debug"
610 # AGL cannot be compiled on systems with a kernel > 10.x (Snow Leopard)
611 TARGETS="sv-$debug sdl-$debug"
614 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"
616 TARGETS="sv-$debug cl-$debug sdl-$debug"
618 if [ $# -gt 0 ] && [ x"$1" = x"" ]; then
619 # if we give the command make the arg "", it will surely fail (invalid filename),
620 # so better handle it as an empty client option
623 elif [ -n "$1" ]; then
625 TARGETS_SAVE=$TARGETS
630 TARGETS="$TARGETS sdl-debug"
633 TARGETS="$TARGETS cl-debug"
636 TARGETS="$TARGETS sv-debug"
639 BAD_TARGETS="$BAD_TARGETS $X"
643 if [ -n "$TARGETS" ]; then # at least a valid client
645 else # no valid client, let's assume this option is not meant to be a client then
646 TARGETS=$TARGETS_SAVE
650 if [ -z "$MAKEFLAGS" ]; then
651 if [ -f /proc/cpuinfo ]; then
652 ncpus=$((`grep -c '^processor :' /proc/cpuinfo`+0))
653 if [ $ncpus -gt 1 ]; then
657 if [ -n "$WE_HATE_OUR_USERS" ]; then
658 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw LIB_JPEG= CFLAGS_LIBJPEG="
662 enter "$d0/fteqcc" verbose
664 verbose make $MAKEFLAGS clean
666 verbose make $MAKEFLAGS
668 enter "$d0/data/xonotic-data.pk3dir" verbose
670 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS clean
672 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
674 enter "$d0/darkplaces" verbose
675 if [ x"$BAD_TARGETS" = x" " ]; then
676 echo "Warning: invalid empty client, default clients will be used."
679 verbose make $MAKEFLAGS clean
681 for T in $TARGETS; do
682 verbose make $MAKEFLAGS STRIP=: "$@" "$T"
684 for T in $BAD_TARGETS; do
685 echo "Warning: discarded invalid client $T."
688 verbose "$SELF" update-maps
691 if [ -n "$WE_HATE_OUR_USERS" ]; then
693 export PATH="$d0/misc/buildfiles/win32:$PATH"
694 elif [ x"`uname`" = x"Darwin" ]; then
695 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/MacOS"
696 export DYLD_FRAMEWORK_PATH="$d0/misc/buildfiles/osx/Xonotic-SDL.app/Contents/Frameworks"
702 sdl|glx|agl|dedicated)
711 if ! [ -x "darkplaces/darkplaces$client" ]; then
712 if [ -x "darkplaces/darkplaces$client.exe" ]; then
715 echo "Client darkplaces/darkplaces$client not found, aborting"
719 set -- "darkplaces/darkplaces$client" -xonotic -mygames "$@"
721 # if pulseaudio is running: USE IT
722 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
723 if ps -C pulseaudio >/dev/null; then
724 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
725 export SDL_AUDIODRIVER=pulse
732 if [ -n "$USE_GDB" ]; then
733 set -- gdb --args "$@"
734 elif which gdb >/dev/null 2>&1; then
735 set -- gdb --batch -x savecore.gdb --args "$@"
736 elif which catchsegv >/dev/null 2>&1; then
737 set -- catchsegv "$@"
741 if [ -f xonotic.core ]; then
742 if yesno "The program has CRASHED. Do you want to examine the core dump?"; then
743 gdb "$binary" xonotic.core
744 #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
745 # tar cvzf xonotic.core.tar.gz xonotic.core darkplaces/*.c darkplaces/*.h
747 # rm -f xonotic.core.tar.gz
749 echo "The core dump can be examined later by"
750 echo " gdb $binary xonotic.core"
756 if [ x"$1" = x"-k" ]; then
761 if verbose cd "$d0/$d"; then
773 patchdir=`mktemp -d -t save-patches.XXXXXX`
775 enter "$d0/$d" verbose
776 git branch -v -v | cut -c 3- | {
778 while read -r BRANCH REV UPSTREAM TEXT; do
781 UPSTREAM=${UPSTREAM#\[}
782 UPSTREAM=${UPSTREAM%\]}
783 UPSTREAM=${UPSTREAM%:*}
787 UPSTREAM=origin/"`repobranch "$d"`"
791 if [ x"$REV" = x"->" ]; then
794 if git format-patch -o "$patchdir/$i" "$UPSTREAM".."$BRANCH"; then
795 echo "$d" > "$patchdir/$i/info.txt"
796 echo "$BRANCH" >> "$patchdir/$i/info.txt"
797 echo "$UPSTREAM" >> "$patchdir/$i/info.txt"
798 echo "$TRACK" >> "$patchdir/$i/info.txt"
801 rm -rf "$patchdir/$i"
806 ( cd "$patchdir" && tar cvzf - . ) > "$outfile"
811 patchdir=`mktemp -d -t restore-patches.XXXXXX`
812 ( cd "$patchdir" && tar xvzf - ) < "$infile"
814 for P in "$patchdir"/*/info.txt; do
821 verbose git checkout HEAD^0
822 verbose git branch -D "$BRANCH"
823 if [ x"$TRACK" = x"true" ]; then
824 verbose git checkout --track -b "$BRANCH" "$UPSTREAM"
826 verbose git branch -b "$BRANCH" "$UPSTREAM"
838 report=$report"$*$LF"
843 report=$report" $*$LF"
848 o=`"$@" | sed 's/^/ /' || true`
852 enter "$d0/$d" verbose
853 base="`repobranch "$d"`"
855 for ref in `git for-each-ref --format='%(refname)' refs/remotes/origin/`; do
856 case "${ref#refs/remotes/origin/}" in
869 if [ -n "$branch" ]; then
870 if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
879 l0=`git rev-list "$base".."$ref" | wc -l`
880 l1=`git rev-list master.."$ref" | wc -l`
881 if [ $l0 -gt $l1 ]; then
888 reportecho " Branch $ref:"
889 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
890 logdata=`git log --color "$realbase".."$ref"`
891 if [ -z "$logdata" ]; then
892 reportecho4 "--> not merging, no changes vs master"
893 if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
894 git push origin :"${ref#refs/remotes/origin/}"
895 reportecho4 "--> branch deleted"
898 diffdata=`git diff --color --find-copies-harder --ignore-space-change "$realbase"..."$ref"`
899 if [ -z "$diffdata" ]; then
900 reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
901 if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
902 git push origin :"${ref#refs/remotes/origin/}"
903 reportecho4 "--> branch deleted"
905 elif [ -z "$branch" ] && [ -n "$note" ]; then
906 reportdo4 echo "$note"
907 reportecho4 "--> not merging, already had this one rejected before"
908 elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
909 git checkout "$realbase"
910 org=`git rev-parse HEAD`
911 if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
912 git reset --hard "$org"
913 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
915 reportecho4 "--> merge failed"
916 elif ! "$SELF" compile 2>&1 | tee "$t"; then
917 git reset --hard "$org"
918 GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
920 reportecho4 "--> compile failed"
921 elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
922 git reset --hard "$org"
923 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
924 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
925 if [ x"$note" = x"del" ]; then
926 git push origin :"${ref#refs/remotes/origin/}"
927 reportecho4 "--> test failed, branch deleted"
928 elif [ -n "$note" ]; then
929 reportdo4 echo "$note"
930 reportecho4 "--> test failed"
932 reportecho4 "--> test failed, postponed"
936 case ",`repoflags "$d"`," in
938 # we do quite a mess here... luckily we know $org
939 git fetch # svn needs to be current
940 git rebase -i --onto origin/master "$org"
941 git svn dcommit --add-author-from
942 git reset --hard "$org"
948 reportecho4 "--> MERGED"
949 if yesno "Delete original branch \"$ref\"?"; then
950 git push origin :"${ref#refs/remotes/origin/}"
951 reportecho4 "--> branch deleted"
955 GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
956 note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
957 if [ x"$note" = x"del" ]; then
958 git push origin :"${ref#refs/remotes/origin/}"
959 reportecho4 "--> branch deleted"
960 elif [ -n "$note" ]; then
961 reportdo4 echo "$note"
962 reportecho4 "--> rejected"
964 reportecho4 "--> postponed"
973 echo "$report" | ssh nexuiz@rm.endoftheinternet.org cat '>>' public_html/xonotic-merge-notes.txt
985 # ./all clean [-m] [-f | -fu | -fU] [-r] [-D]
986 # ./all clean --reclone
989 if [ x"$1" = x"--reclone" ]; then
996 elif [ x"$1" = x"-f" ]; then
998 elif [ x"$1" = x"-u" ]; then
1000 elif [ x"$1" = x"-U" ]; then
1003 elif [ x"$1" = x"-fu" ]; then
1006 elif [ x"$1" = x"-fU" ]; then
1010 elif [ x"$1" = x"-m" ]; then
1012 elif [ x"$1" = x"-r" ]; then
1014 elif [ x"$1" = x"-D" ]; then
1027 if $gotoupstream; then
1029 msg "Must also use -f (delete local changes) when using -u"
1032 if $gotomaster; then
1033 if $fetchupstream; then
1034 verbose git fetch origin
1035 verbose git remote prune origin
1037 verbose git checkout -f "`repobranch "$d"`"
1038 verbose git reset --hard origin/"`repobranch "$d"`"
1040 r=`git symbolic-ref HEAD`
1042 rem=`git config "branch.$r.remote" || echo origin`
1043 bra=`git config "branch.$r.merge" || echo "$r"`
1044 upstream="$rem/${bra#refs/heads/}"
1045 if $fetchupstream; then
1046 verbose git fetch "$rem"
1047 verbose git remote prune "$rem"
1049 if ! git rev-parse "$upstream" >/dev/null 2>&1; then
1050 upstream="origin/`repobranch "$d"`"
1052 verbose git reset --hard "$upstream"
1054 elif $gotomaster; then
1056 verbose git checkout -f "`repobranch "$d"`"
1057 verbose git reset --hard
1059 verbose git checkout "`repobranch "$d"`"
1062 verbose git reset --hard
1064 if $rmuntracked; then
1067 verbose git clean -df
1070 verbose git clean -xdf
1074 if $killbranches; then
1075 git for-each-ref --format='%(refname)' refs/heads/ | while IFS= read -r B; do
1076 if [ x"$B" != x"`git symbolic-ref HEAD`" ]; then
1077 verbose git branch -D "${B#refs/heads/}"
1080 git rev-parse refs/heads/master >/dev/null 2>&1 || verbose git branch -t master origin/master || true
1081 git rev-parse "refs/heads/`repobranch "$d"`" >/dev/null 2>&1 || verbose git branch -t "`repobranch "$d"`" origin/"`repobranch "$d"`" || true
1086 # release building goes here
1088 #"$SELF" each git clean -fxd
1089 case "$RELEASETYPE" in
1091 msg "Building a BETA"
1094 msg "Building a RELEASE"
1097 echo >&2 -n "$ESC[2J$ESC[H"
1104 msg " +---------------------------------------------------------.---+"
1106 msg " +---------------------------------------------------------^---+"
1108 msg " | / \ This is the official release build system. |"
1109 msg " | | | If you are no member of the Xonotic Core Team, |"
1110 msg " | | STOP | you are not supposed to use this script and should |"
1111 msg " | | | instead use ./all compile to compile the engine |"
1112 msg " | \____/ and game code. |"
1114 msg " | [ I understand ] |"
1115 msg " +-------------------------------------------------------------+"
1117 # A LOT of build infrastructure is required:
1120 # - .ssh/config must be configured so the following
1121 # host names are reachable and have a compile
1122 # infrastructure set up:
1123 # - xonotic-build-linux32 (with gcc on x86)
1124 # - xonotic-build-linux64 (with gcc on x86_64)
1125 # - xonotic-build-win32 (with i586-mingw32msvc-g++)
1126 # - xonotic-build-win64 (with amd64-mingw32msvc-g++
1127 # and x86_64-w64-mingw32-g++)
1128 # - xonotic-build-osx (with Xcode and SDL.framework)
1129 # - AMD Compressonator installed in WINE
1130 # - ResEdit installed in WINE
1131 # - a lot of other requirements you will figure out
1132 # while reading the error messages
1133 # - environment variable RELEASETYPE set
1134 # - optionally, environment variable RELEASEDATE set
1139 verbose rm -rf Xonotic Xonotic*.zip
1140 verbose mkdir -p Xonotic
1141 if [ -n "$RELEASEDATE" ]; then
1142 verbose echo "$RELEASEDATE" > Xonotic/stamp.txt
1144 verbose date +%Y%m%d > Xonotic/stamp.txt
1146 verbose git archive --format=tar HEAD -- Docs misc server xonotic-linux-glx.sh xonotic-linux-sdl.sh misc/buildfiles | {
1148 verbose mkdir data fteqcc source source/darkplaces source/fteqcc
1150 verbose rm -rf misc/builddeps
1151 verbose mv misc/buildfiles/win32/* . || true
1152 verbose mv misc/buildfiles/win64 bin64 || true
1153 verbose mv misc/buildfiles/osx/* . || true
1154 verbose rm -rf misc/buildfiles
1157 verbose cd darkplaces
1158 verbose git archive --format=tar HEAD
1160 verbose cd Xonotic/source/darkplaces
1165 verbose git archive --format=tar HEAD
1167 verbose cd Xonotic/source/fteqcc
1171 verbose cd data/xonotic-data.pk3dir
1172 verbose git archive --format=tar HEAD -- qcsrc Makefile
1174 verbose cd Xonotic/source
1178 release-compile-run)
1187 if [ -n "$targetfiles" ]; then
1188 case " $HOSTS_THAT_ARE_DISABLED " in
1193 case " $HOSTS_THAT_ARE_MYSELF " in
1195 verbose rsync --delete -zLvaSHP "$srcdir"/ "$buildpath/"
1196 verbose rsync --delete -zLvaSHP "$depsdir"/ "$buildpath.deps/"
1197 verbose ln -snf "$buildpath.deps" "$buildpath/.deps"
1198 verbose eval make -C "$buildpath" clean $maketargets $makeflags
1199 for f in $targetfiles; do
1200 verbose mv "$buildpath/${f%:*}" "${f##*:}" || true
1204 verbose rsync --delete -zLvaSHP "$srcdir"/ "$host:$buildpath/"
1205 verbose rsync --delete -zLvaSHP "$depsdir"/ "$host:$buildpath.deps/"
1206 verbose ssh "$host" "ln -snf $buildpath.deps $buildpath/.deps && cd $buildpath && nice -`nice` make clean $maketargets $makeflags"
1207 for f in $targetfiles; do
1208 verbose rsync -zvaSHP "$host:$buildpath/${f%:*}" "${f##*:}" || true
1212 # now rebrand the binaries...
1213 for f in $targetfiles; do
1214 #verbose "$d0/misc/tools/rebrand-darkplaces-engine.sh" "${XONOTIC_BRAND:-$d0/misc/tools/xonotic.brand}" "${f##*:}" || true
1217 verbose "$d0/misc/tools/change-icon-of-exe.sh" "$d0/misc/logos/icons_ico/xonotic.ico" "$f"
1219 d=`mktemp -d -t rebrand.XXXXXX`
1221 echo "-mygames" > darkplaces.opt
1222 zip -9r darkplaces.zip darkplaces.opt
1235 fteqcc_maketargets=$3
1237 darkplaces_maketargets=$5
1239 host=xonotic-build-$suffix
1240 verbose "$SELF" release-compile-run "$host" /tmp/fteqcc.build."$suffix" "$fteqcc_maketargets" "$makeflags" "Xonotic/source/fteqcc" "$d0/misc/builddeps/dp.$suffix" "$fteqcc_files"
1241 verbose "$SELF" release-compile-run "$host" /tmp/Darkplaces.build."$suffix" "$darkplaces_maketargets" "$makeflags" "Xonotic/source/darkplaces" "$d0/misc/builddeps/dp.$suffix" "$darkplaces_files"
1243 release-engine-win32)
1244 verbose "$SELF" release-compile win32 \
1245 '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' \
1246 win 'fteqcc.exe:Xonotic/fteqcc/fteqcc.exe' \
1248 verbose "$SELF" release-compile win32 \
1249 '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' \
1251 release 'darkplaces.exe:Xonotic/xonotic.exe darkplaces-sdl.exe:Xonotic/xonotic-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-dedicated.exe'
1253 release-engine-win64)
1254 verbose "$SELF" release-compile win64 \
1255 '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' \
1256 win 'fteqcc.exe:Xonotic/fteqcc/fteqcc-x64.exe' \
1257 'sv-release sdl-release' 'darkplaces-sdl.exe:Xonotic/xonotic-x64-sdl.exe darkplaces-dedicated.exe:Xonotic/xonotic-x64-dedicated.exe'
1258 verbose "$SELF" release-compile win64 \
1259 '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' \
1261 cl-release 'darkplaces.exe:Xonotic/xonotic-x64.exe'
1264 # gcc on OSX is buggy, needs -fno-reorder-blocks for a release build to succeed
1265 verbose "$SELF" release-compile osx \
1266 '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"' \
1267 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.osx' \
1268 'sv-release sdl-release' 'darkplaces-sdl:Xonotic/Xonotic-SDL.app/Contents/MacOS/xonotic-osx-sdl-bin darkplaces-dedicated:Xonotic/xonotic-osx-dedicated'
1269 verbose "$SELF" release-compile osx \
1270 '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"' \
1272 'cl-release' 'darkplaces-agl:Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-agl-bin'
1274 release-engine-linux32)
1275 verbose "$SELF" release-compile linux32 \
1276 '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' \
1277 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux32' \
1278 release 'darkplaces-glx:Xonotic/xonotic-linux32-glx darkplaces-sdl:Xonotic/xonotic-linux32-sdl darkplaces-dedicated:Xonotic/xonotic-linux32-dedicated'
1280 release-engine-linux64)
1281 verbose "$SELF" release-compile linux64 \
1282 'STRIP=: CC="gcc -m64 -g -I.deps/include -L.deps/lib -DSUPPORTIPV6" DP_MODPLUG_STATIC_LIBDIR=.deps/lib LIB_JPEG=.deps/lib/libjpeg.a' \
1283 all 'fteqcc.bin:Xonotic/fteqcc/fteqcc.linux64' \
1284 release 'darkplaces-glx:Xonotic/xonotic-linux64-glx darkplaces-sdl:Xonotic/xonotic-linux64-sdl darkplaces-dedicated:Xonotic/xonotic-linux64-dedicated'
1287 verbose "$SELF" release-engine-linux32 &
1288 verbose "$SELF" release-engine-linux64 &
1289 verbose "$SELF" release-engine-win32 &
1290 verbose "$SELF" release-engine-win64 &
1291 verbose "$SELF" release-engine-osx &
1300 verbose "$SELF" update-maps
1303 case "$RELEASETYPE" in
1305 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 clean all
1308 verbose make -C Xonotic/source FTEQCC="$d0/Xonotic/fteqcc/fteqcc.linux32" XON_BUILDSYSTEM=1 FTEQCCFLAGS_WATERMARK= clean all
1311 verbose rm -f Xonotic/source/*/fteqcc.log
1313 release-buildpk3-transform-raw)
1316 release-buildpk3-transform-normal)
1319 # texture: convert to jpeg and dds
1320 verbose export do_jpeg=true
1321 verbose export jpeg_qual_rgb=95
1322 verbose export jpeg_qual_a=99
1323 verbose export do_dds=true
1324 verbose export dds_flags=
1325 verbose export do_ogg=false
1326 verbose export del_src=true
1327 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1329 release-buildpk3-transform-low)
1332 # texture: convert to jpeg and dds
1333 # music: reduce bitrate
1334 verbose export do_jpeg=true
1335 verbose export jpeg_qual_rgb=80
1336 verbose export jpeg_qual_a=95
1337 verbose export do_dds=false
1338 verbose export do_ogg=true
1339 verbose export ogg_qual=1
1340 verbose export del_src=true
1341 find . -type f -print0 | verbose xargs -0 "$d0"/misc/tools/cached-converter.sh
1343 release-buildpk3-transform-lowdds)
1346 # texture: convert to jpeg and dds
1347 # music: reduce bitrate
1348 verbose export do_jpeg=false
1349 verbose export do_jpeg_if_not_dds=true
1350 verbose export jpeg_qual_rgb=80
1351 verbose export jpeg_qual_a=95
1352 verbose export do_dds=true
1353 verbose export dds_flags=
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
1370 verbose rm -rf Xonotic/temp
1371 verbose mkdir -p Xonotic/temp
1374 verbose git archive --format=tar HEAD
1376 verbose cd Xonotic/temp
1379 verbose cd Xonotic/temp
1380 if [ x"$src" = x"data/xonotic-data.pk3dir" ]; then
1381 verbose cp ../source/progs.dat .
1382 verbose cp ../source/csprogs.dat .
1383 verbose cp ../source/menu.dat .
1384 verbose rm -rf qcsrc
1385 gv=`grep "^gameversion " "defaultXonotic.cfg" | awk '{ print $2 }'`
1386 major=$(($gv / 10000))
1387 minor=$(($gv / 100 - $major * 100))
1388 patch=$(($gv - $major * 10000 - $minor * 100))
1389 versionstr="$major.$minor.$patch"
1390 case "$RELEASETYPE" in
1392 versionstr="$versionstr""beta"
1396 s/^set g_xonoticversion [^ ]* /set g_xonoticversion $versionstr /;
1397 s/^gameversion_min [0-9]*/gameversion_min $(( ($gv / 100) * 100 - 100 ))/;
1398 s/^gameversion_max [0-9]*/gameversion_max $(( ($gv / 100) * 100 + 199 ))/;
1399 " defaultXonotic.cfg
1401 verbose cd gfx/menu/luminos
1402 verbose cp "$d0"/mediasource/gfx/menu/luminos_versionbuilder/background_l2.svg .
1403 verbose "$d0"/mediasource/gfx/menu/luminos_versionbuilder/versionbuilder "$versionstr"
1404 verbose rm background_l2.svg
1407 if [ x"$src" = x"data/xonotic-maps.pk3dir" ]; then
1408 for X in ../../data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
1409 if [ -f "$X" ]; then
1411 verbose rm -f maps/*.log maps/*.irc maps/*.lin
1415 verbose export git_src_repo="$d0/$src" # skip hash-object
1416 verbose "$SELF" release-buildpk3-transform-$transform "Xonotic/temp"
1417 verbose mkzip "../../$dst" *
1419 verbose rm -rf Xonotic/temp
1422 stamp=`cat Xonotic/stamp.txt`
1428 dst="data/xonotic-$stamp-${dst#data/xonotic-}"
1434 while [ "$#" -gt 1 ]; do
1435 verbose "$SELF" release-buildpk3 "$src" "Xonotic/$dst$2.pk3" "$1"
1441 verbose "$SELF" release-buildpk3s data/font-nimbussansl.pk3dir raw ''
1442 verbose "$SELF" release-buildpk3s data/xonotic-data.pk3dir normal '' raw '-raw' low '-low' lowdds '-lowdds'
1443 verbose "$SELF" release-buildpk3s data/xonotic-maps.pk3dir normal '' raw '-raw' low '-low' lowdds '-lowdds'
1444 verbose "$SELF" release-buildpk3s data/xonotic-music.pk3dir raw '' low '-low'
1445 verbose "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir low ''
1447 release-pack-needsx11)
1450 verbose startx "$SELF" release-pack -- /usr/bin/Xvfb :7
1453 verbose "$SELF" release-pack
1458 stamp=`cat Xonotic/stamp.txt`
1459 # exe and dll files do not need +x, so this makes them eligible for 7zip compression too
1460 chmod a-x Xonotic/*.exe Xonotic/*.dll || true
1461 # need to use infozip for these (+x bits)
1462 verbose mkzip Xonotic-$stamp-engine.zip \
1464 Xonotic/bin64/*.dll \
1467 Xonotic/xonotic.exe \
1468 Xonotic/source/darkplaces/
1469 verbose cp Xonotic-$stamp-engine.zip Xonotic-$stamp-common.zip
1470 verbose mkzip Xonotic-$stamp-common.zip \
1471 Xonotic/source/fteqcc/ \
1472 Xonotic/source/qcsrc/ \
1477 Xonotic/data/font-nimbussansl-$stamp.pk3
1478 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp.zip
1479 verbose mkzip0 Xonotic-$stamp.zip \
1480 Xonotic/data/xonotic-$stamp-data.pk3 \
1481 Xonotic/data/xonotic-$stamp-maps.pk3 \
1482 Xonotic/data/xonotic-$stamp-music.pk3 \
1483 Xonotic/data/xonotic-$stamp-nexcompat.pk3
1484 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-low.zip
1485 verbose mkzip0 Xonotic-$stamp-low.zip \
1486 Xonotic/data/xonotic-$stamp-data-low.pk3 \
1487 Xonotic/data/xonotic-$stamp-maps-low.pk3 \
1488 Xonotic/data/xonotic-$stamp-music-low.pk3
1489 verbose cp Xonotic-$stamp-common.zip Xonotic-$stamp-lowdds.zip
1490 verbose mkzip0 Xonotic-$stamp-lowdds.zip \
1491 Xonotic/data/xonotic-$stamp-data-lowdds.pk3 \
1492 Xonotic/data/xonotic-$stamp-maps-lowdds.pk3 \
1493 Xonotic/data/xonotic-$stamp-music-low.pk3
1494 verbose mv Xonotic-$stamp-common.zip Xonotic-$stamp-high.zip
1495 verbose mkzip0 Xonotic-$stamp-high.zip \
1496 Xonotic/data/xonotic-$stamp-data-raw.pk3 \
1497 Xonotic/data/xonotic-$stamp-maps-raw.pk3 \
1498 Xonotic/data/xonotic-$stamp-music.pk3 \
1499 Xonotic/data/xonotic-$stamp-nexcompat.pk3
1502 verbose "$SELF" release-prepare
1503 verbose "$SELF" release-maps
1504 verbose "$SELF" release-engine
1505 verbose "$SELF" release-qc
1506 verbose "$SELF" release-pack-needsx11
1507 verbose "$SELF" release-zip
1512 echo " $SELF admin-merge [<branch>]"
1513 echo " $SELF branch <branch>"
1514 echo " $SELF branch <remote> <branch> [<srcbranch>]"
1515 echo " $SELF branches"
1516 echo " $SELF checkout|switch <branch>"
1517 echo " $SELF checkout|switch <remote>/<branch>"
1518 echo " $SELF clean [-m] [-f | -fu | -fU] [-r] [-D]"
1519 echo " $SELF clean --reclone"
1520 echo " $SELF compile [-c]"
1521 echo " $SELF each|foreach [-k] command..."
1522 echo " $SELF fix_upstream_rebase"
1524 echo " $SELF push|commit [-s]"
1525 echo " $SELF release"
1526 echo " $SELF restore-patches"
1527 echo " $SELF run [sdl|glx|wgl|agl|dedicated] options..."
1528 echo " $SELF save-patches"
1529 echo " $SELF update-maps"
1530 echo " $SELF update|pull [-N]"