]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - all
cleanup more (don't change mirror if no mirror selection possible)
[xonotic/xonotic.git] / all
diff --git a/all b/all
index c6122bcca3ffc9d5c941d8a91156b48263e92a11..64cd09977905099018505f0f63de0af3c09af378 100755 (executable)
--- a/all
+++ b/all
@@ -339,6 +339,47 @@ mkzip0()
        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
@@ -438,12 +479,14 @@ case "$cmd" in
                                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
                                                ;;
@@ -456,6 +499,23 @@ case "$cmd" in
                        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=
@@ -1222,6 +1282,7 @@ case "$cmd" in
                        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'
@@ -1232,9 +1293,9 @@ case "$cmd" in
                                msg '|     |    __,C>|| UUUU'
                                msg '\\    /_ ,-/,-'\''   |  UUUU'
                                msg ' \\\\_ \\_>~'\''      /  UUUU-'
-
+                               msg ''
                        else
-                               break
+                               msg "Unknown arg: $X"
                        fi
                        found=true
                        shift
@@ -1557,7 +1618,7 @@ case "$cmd" in
                # 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