You are not logged in.

#1 2005-11-10 08:35:53

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

alternative to sormirrors

Since sortmirrors, or maybe it all falls upon netselect, has been broken for some time how what might be a quick and dirty way to accomplish the same task.
I dont really know the geographical location of the mirrors in pacman.d/ or how to find that information out.
Plus there might be other mirrors that I dont know about because they arent included in the file. I dont know...

Offline

#2 2005-11-10 08:55:59

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: alternative to sormirrors

Who said it was broken?  I used it a few weeks ago and it was fine...

Offline

#3 2005-11-10 09:21:39

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

Re: alternative to sormirrors

dibblethewrecker wrote:

Who said it was broken?  I used it a few weeks ago and it was fine...

This bug report

I tried using it a few days ago and it removed all my mirrors.

EDIT:

@ dibble
Does your diff fix it?

Offline

#4 2005-11-10 09:38:56

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: alternative to sormirrors

Nope my diff doesn't do much at all.  Didn't know about that bug sad  You could hunt for a netselect replacement smile

Offline

#5 2005-11-10 16:02:23

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: alternative to sormirrors

I thought sortmirrors was fixed, it worked fine for me last week, but I do remember it causing grief a while back. (Er I just noticed who posted the bug :oops:) Maybe its possible to remove the offending mirrors from the list or something... I don't know why its so random!

Dusty

Offline

#6 2005-11-11 01:44:09

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: alternative to sormirrors

I wrote a script to sort the mirros using the average response time reported from pinging each server six times. It'll create each sorted mirror include file in /etc/pacman.d/ as extra.sorted, current.sorted, testing.sorted, etc.
I'm not sure how entirely accurate it really is but I'll post a link to it if anyone is interested.

Offline

#7 2005-11-12 16:54:09

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

Re: alternative to sormirrors

Penguin wrote:

I wrote a script to sort the mirros using the average response time reported from pinging each server six times. It'll create each sorted mirror include file in /etc/pacman.d/ as extra.sorted, current.sorted, testing.sorted, etc.
I'm not sure how entirely accurate it really is but I'll post a link to it if anyone is interested.

Please do.

Offline

#8 2005-11-12 17:26:26

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: alternative to sormirrors

link

Please let me know if it seems accurate.

Offline

#9 2005-11-21 21:48:05

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,919

Re: alternative to sormirrors

rmbalfa wrote:
dibblethewrecker wrote:

Who said it was broken?  I used it a few weeks ago and it was fine...

This bug report

I tried using it a few days ago and it removed all my mirrors.

EDIT:

@ dibble
Does your diff fix it?

I had the same problem today, and found it was due to my firewall configuration.
I had blocked most of the icmp services, and it looks like netselect couldn't get a valid response from the servers and thus removed them.
after allowing icmp and restoring the original mirror files from abs, sortmirrors / netselect worked like normal again.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#10 2005-11-23 05:59:27

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

Re: alternative to sormirrors

I just tested your script. It worked fine. My server order didn't change very much actually...

Offline

#11 2006-03-21 01:28:56

midas
Member
Registered: 2005-06-08
Posts: 12
Website

Re: alternative to sormirrors

That above link doesn't work.

I googled and here is the CORRECT URL

I included the code from the sortmirrors2 script below.  I used this and it is awesome!  Nice work!

#!/bin/bash

trap "cleanup; exit 1" INT

if [ $(id -u) -ne 0 ]; then
    echo "You must be root user to run this program."
    exit 1
fi

cleanup() {
    [ -f /tmp/sortmirrors ] && rm -f /tmp/sortmirrors
    [ -f /tmp/sorted ] && rm -f /tmp/sorted
}

cleanup    

mirror_file="/etc/pacman.d/current"
ct=1
max_num=$(wc -l $mirror_file |awk {'print $1'})

while [ $ct -le $max_num ]; do
    mirror=$(sed -n "$ct"p $mirror_file)
    d_candidate=$(echo $mirror |grep ^Server |awk -F= {'print $2'} |sed 's|s||')
    candidate=$(echo $d_candidate |awk -F "//" {'print $2'} 
    |awk -F/ {'print $1'})
    if [ "$candidate" != "" ]; then
        echo -e "Testing $candidate:  \c"
               testit="ping -c6 "$(echo $candidate)""
        result=$($testit |tail -n1 |awk -F/ {'print $6'})
        echo $d_candidate%$result >>/tmp/sortmirrors
        right=$(sed -n '$p' /tmp/sortmirrors |awk -F% {'print $2'})
        echo $right"ms"
    fi

    ct=$(($ct+1))
done

# sort mirrors
times=$(cat /tmp/sortmirrors |awk -F% {'print $2'} |sort -n)

ct=0
for t in $times; do
    sorted[$ct]=$(grep $t /tmp/sortmirrors)
    ct=$(($ct+1))
done

echo -e "#n[current]n#" >/tmp/sorted
for newentry in ${sorted[@]}; do
    echo Server = $newentry >>/tmp/sorted
done

# get rid of appended calculated times
sed 's|%.*||g' /tmp/sorted -i /tmp/sorted

cp -f /tmp/sorted /etc/pacman.d/current.sorted

cp -f /tmp/sorted /etc/pacman.d/extra.sorted
sed -e 's|current|extra|g' /etc/pacman.d/extra.sorted -i /etc/pacman.d/extra.sorted

cp -f /tmp/sorted /etc/pacman.d/community.sorted
sed -e 's|current|community|g' /etc/pacman.d/community.sorted -i /etc/pacman.d/community.sorted

cp -f /tmp/sorted /etc/pacman.d/testing.sorted
sed -e 's|current|testing|g' /etc/pacman.d/testing.sorted -i /etc/pacman.d/testing.sorted

cp -f /tmp/sorted /etc/pacman.d/unstable.sorted
sed -e 's|current|unstable|g' /etc/pacman.d/unstable.sorted -i /etc/pacman.d/unstable.sorted

cp -f /tmp/sorted /etc/pacman.d/release.sorted
sed -e 's|current|release|g' /etc/pacman.d/release.sorted -i /etc/pacman.d/release.sorted

echo -e "n==> Append ".sorted" to your Include = line in /etc/pacman.conf to use the sorted mirrors."
cleanup

Offline

#12 2006-03-21 02:43:10

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: alternative to sormirrors

haha! I can't believe you found that through google 8)
I also wrote the same thing in python when I first learned the language:
http://infiditus.homelinux.org/arch/misc/sortmirrors.py

But I really don't know how accurate they are because they only use the average response times from pinging the server 6 times...

Offline

#13 2006-05-23 05:49:58

midas
Member
Registered: 2005-06-08
Posts: 12
Website

Re: alternative to sormirrors

Still its a pretty cool script nice work

Offline

Board footer

Powered by FluxBB