netselct-apt is used to select the fastest mirrors (one non-us, one of any origin) for debian package retrieval. It has two main shortcomings - it clobbers sources.list in the current directory and it only picks one mirror of each type. Both of these are fixed with the below script. Hope you find it useful!

usage: script.pl [distro] [#mirrors] >> /etc/apt/sources.list
#! /usr/bin/perl -w use strict; if (scalar(@ARGV)==0){ print "#Usage: [stable|unstable|testing] [number of mirrors]\n +#Assuming \"stable\" and \"3\"\n"; } my ($distro,$howMany)=@ARGV; $distro="stable" if (!defined($distro)); $howMany = 3 if (!defined($howMany)); &displayList ("$distro", &selectSome($howMany,&getMirrors("^Packages") +)); &displayList ("$distro/non-US", &selectSome($howMany,&getMirrors("Non- +US packages"))); sub displayList { my $distro=shift; my @mirrors=@_; foreach (@mirrors){ print "deb $_ $distro main contrib non-free\n"; print "# deb-src deb $_ $distro main contrib non-free\ +n"; } } sub getMirrors { my $search=shift; my $invert=shift; $search="." if (!defined($search)); my @mirrorPage = `lynx -source "http://www.debian.org/mirror/m +irrors_full"`; my @mirrors; foreach (@mirrorPage){ if ($_=~/(.*)<a href="(http:\/\/.*?)">/) { my $description=$1; my $url=$2; push @mirrors,$url if ($invert && $description!~/$ +search/i); push @mirrors,$url if (!$invert && $description=~/ +$search/i); } } return @mirrors; } sub selectSome { my $howMany=shift; my @list = @_; my $command = "netselect -v -s $howMany ".join (' ',@list); my @arr = split(/\n/,`$command`); foreach (@arr){ $_=~s/\s*-?\d+\s*([a-z]+:\/\/.*)/$1/i; #snag url } return @arr; }

In reply to netselect-apt replacement by thisismyname

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.