OSDN Git Service

fix mirrorlist generator master
authorpaperbenni <paperbenni@gmail.com>
Sat, 19 Dec 2020 10:46:29 +0000 (11:46 +0100)
committerpaperbenni <paperbenni@gmail.com>
Sat, 19 Dec 2020 10:46:29 +0000 (11:46 +0100)
askutils.sh
depend/mirrors.sh

index 311ef65..e18d64c 100755 (executable)
@@ -150,19 +150,21 @@ This could prevent the system from booting" | imenu -C; then
 # offer to choose mirror country
 askmirrors() {
     iroot askmirrors 1
-    curl -s 'https://www.archlinux.org/mirrorlist/all/' | grep -i '<option value' >/tmp/mirrors.html
-    grep -v '>All<' /tmp/mirrors.html | sed 's/.*<option value=".*">\(.*\)<\/option>.*/\1/g' |
-        sed -e "1iauto detect mirrors (not recommended for speed)" |
-        imenu -l "choose mirror location" >/tmp/mirrorselect
-    if ! grep -q 'auto detect' </tmp/mirrorselect; then
-        cat /tmp/mirrors.html | grep ">$(cat /tmp/mirrorselect)<" | grep -o '".*"' | grep -o '[^"]*' | iroot i countrycode
+    MIRRORCODE="$({
+        echo 'auto detect mirrors (not recommended for speed)'
+        curl -s 'https://archlinux.org/mirrorlist/all/' | grep '##' | grep -iEv '(linux|arch|generated|filter)' |
+            grep -o '[^# ]*' | grep '.....'
+    } | imenu -l 'select mirror location')"
+
+    if grep -q 'auto detect' <<<"$MIRRORCODE"; then
+        iroot automirrors 1
+    else
+        iroot countrycode "$MIRRORCODE"
         if echo '> manually sorting mirrors may take a long time
 use arch ranking score (recommended)
 sort all mirrors by speed' | imenu -l 'choose mirror settings' | grep -q 'speed'; then
             iroot sortmirrors 1
         fi
-    else
-        iroot automirrors 1
     fi
 }
 
index b73de25..19ab4dc 100755 (executable)
@@ -15,7 +15,7 @@ if ! iroot automirrors; then
     COUNTRYCODE="$(iroot countrycode)"
     echo "fetching mirrors for $COUNTRYCODE"
 
-    curl -s "https://www.archlinux.org/mirrorlist/?country=$COUNTRYCODE&protocol=http&protocol=https&ip_version=4&use_mirror_status=on" |
+    curl -s "https://archlinux.org/mirrorlist/?country=$COUNTRYCODE&protocol=http&protocol=https&ip_version=4&use_mirror_status=on" |
         grep -iE '(Server|generated)' |
         sed 's/^#Server /Server /g' >/tmp/mirrorlist