]> 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 287dfdced62b10fc1da61d7d20b3c0e7573251d0..64cd09977905099018505f0f63de0af3c09af378 100755 (executable)
--- a/all
+++ b/all
@@ -343,7 +343,7 @@ 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*,,'
+       { 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
 }
 
@@ -352,6 +352,10 @@ 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
@@ -368,8 +372,12 @@ bestmirror()
                        msg "$m -> FAIL"
                fi
        done
-       msg "Best mirror seems to be $pre$bestin$suf"
-       echo "$bestin"
+       if [ -n "$bestin" ]; then
+               msg "Best mirror seems to be $pre$bestin$suf"
+               echo "$bestin"
+       else
+               return 1
+       fi
 }
 
 case "$cmd" in
@@ -491,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=
@@ -506,17 +531,6 @@ case "$cmd" in
                                                ;;
                                esac
                                ;;
-                       best)
-                               base=`echo "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,:// .git.xonotic.org/,"`
-                               case "$base" in
-                                       *\ *)
-                                               location=`bestmirror $base"xonotic.git" de nl`
-                                               ;;
-                                       *)
-                                               location=
-                                               ;;
-                               esac
-                               ;;
                esac
                if [ -n "$location" ]; then
                        base=`echo "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,://$location.git.xonotic.org/,"`