# vim: filetype=zsh
set -e
+if [ -n "$ZSH_VERSION" ]; then
+ setopt SH_WORD_SPLIT
+fi
# I use this in EVERY shell script ;)
LF="
msg()
{
- echo >&2 "$ESC[1m$*$ESC[m"
+ echo >&2 "$ESC""[1m$*$ESC""[m"
}
self=`git hash-object "$SELF"`
}
repos_urls="
-. | | master |
-data/xonotic-data.pk3dir | | master |
-data/xonotic-music.pk3dir | | master |
-data/xonotic-nexcompat.pk3dir | | master | no
-darkplaces | | div0-stable | svn
-netradiant | | master |
-div0-gittools | | master | no
-d0_blind_id | | master |
-data/xonotic-maps.pk3dir | | master |
-mediasource | | master | no
-fteqcc | | master |
+. | | master |
+data/xonotic-data.pk3dir | | master |
+data/xonotic-music.pk3dir | | master |
+data/xonotic-nexcompat.pk3dir | | master | no
+darkplaces | | div0-stable | svn
+netradiant | | master |
+div0-gittools | | master | no
+d0_blind_id | | master |
+data/xonotic-maps.pk3dir | | master |
+mediasource | | master | no
+fteqcc | | xonotic-stable | noautocrlf
"
# todo: in darkplaces, change repobranch to div0-stable
verbose git config --unset remote.origin.pushurl || true
fi
verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- verbose git config core.autocrlf input
+ case ",`repoflags "$d"`," in
+ *,noautocrlf,*)
+ verbose git config --unset core.autocrlf || true
+ ;;
+ *)
+ verbose git config core.autocrlf input
+ ;;
+ esac
if [ -z "`git config push.default || true`" ]; then
verbose git config push.default current # or is tracking better?
fi
zip -0y "$@"
}
+mirrorspeed()
+{
+ # first result is to be ignored, but we use it to check status
+ git ls-remote "$1" refs/heads/master >/dev/null 2>&1 || return 1
+ { time -p git ls-remote "$1" refs/heads/master; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,'
+ # unit: clock ticks (depends on what "time" returns
+}
+
+bestmirror()
+{
+ pre=$1; shift
+ suf=$1; shift
+
+ if ! { time -p true; } >/dev/null 2>&1; then
+ return 1
+ fi
+
+ bestin=
+ bestt=
+ for in in "$@"; do
+ m=$pre$in$suf
+ if t=`mirrorspeed "$m"`; then
+ msg "$m -> $t ticks"
+ if [ -n "$t" ]; then
+ if [ -z "$bestt" ] || [ "$t" -lt "$bestt" ]; then
+ bestin=$in
+ bestt=$t
+ fi
+ fi
+ else
+ msg "$m -> FAIL"
+ fi
+ done
+ if [ -n "$bestin" ]; then
+ msg "Best mirror seems to be $pre$bestin$suf"
+ echo "$bestin"
+ else
+ return 1
+ fi
+}
+
case "$cmd" in
fix_upstream_rebase)
for d in $repos; do
case "$2" in
nl) ;;
de) ;;
+ best) ;;
default) ;;
*)
msg "Invalid location!"
msg "Possible locations for the -l option:"
msg " nl (Netherlands, run by merlijn)"
msg " de (Germany, run by divVerent)"
+ msg " best (find automatically)"
msg " default (currently nl)"
exit 1
;;
fi
shift
done
+ case "$location" in
+ best)
+ newbase=`echo "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,:// .git.xonotic.org/,"`
+ case "$newbase" in
+ *\ *)
+ if location=`bestmirror $newbase"xonotic.git" de nl`; then
+ :
+ else
+ location=current
+ fi
+ ;;
+ *)
+ location=current
+ ;;
+ esac
+ ;;
+ esac
case "$location" in
default)
location=
reportecho "$o"
}
for d in $repos; do
+ case "$d" in
+ fteqcc)
+ # sorry, fteqcc repo is managed manually
+ continue
+ ;;
+ esac
enter "$d0/$d" verbose
base="`repobranch "$d"`"
reportecho "In $d:"
reportecho4 "--> test failed, postponed"
fi
else
+ # apply crlf, or other cleanup filters (non-behavioural changes)
+ git reset --hard
+ find . -type f -exec touch {} \;
+ git commit -a --amend -C HEAD || true # don't fail if nothing to commit
+
echo "MERGING"
case ",`repoflags "$d"`," in
*,svn,*)
rmuntracked=true
elif [ x"$X" = x"-D" ]; then
killbranches=true
+ elif echo "$X" | grep '^-FFFF*UUUU*$' >/dev/null; then
+ msg ''
+ msg ' _____'
+ msg ' ,--'\''-\\P/`\\ FFFFFFF'
+ msg ' __/_ B/,-.\\ FFFFFFF'
+ msg ' / _\\ (// O\\\\ FFFFFF'
+ msg '| (O `) _\\._ _)\\ FFFUU'
+ msg '| |___/.^d0~~"\\ \\ UUUU'
+ msg '| |`~'\'' \\ | UUUU'
+ msg '| | __,C>|| UUUU'
+ msg '\\ /_ ,-/,-'\'' | UUUU'
+ msg ' \\\\_ \\_>~'\'' / UUUU-'
+ msg ''
else
- break
+ msg "Unknown arg: $X"
fi
found=true
shift
# music: reduce bitrate
verbose export do_jpeg=true
verbose export jpeg_qual_rgb=80
- verbose export jpeg_qual_a=99
+ verbose export jpeg_qual_a=97
verbose export do_dds=false
verbose export do_ogg=true
verbose export ogg_qual=1