#! /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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |