Hogyan válasszunk automatikusan Ubuntu tükröt?

Probléma: Időnként, hosszabb-rövidebb időre meghal egy Ubuntu tükör. Ilyenkor kifejezetten macerás átírni a sources.list-et, még a sed is pont egy paranccsal több a kelleténél. Automatizáljuk a tükör választást!

Megoldás: Az apt egy ideje támogatja a mirror paramétert. A mirrornak egy tükröket tartalmazó szöveges állományt paraméterként megadva lehetségessé válik az automatikus tükörválasztás.
Pl.:

Ubuntu 14.04, Trusty Tahr

deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty universe
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates universe
 
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates multiverse
 
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse
 
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
 
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
 
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

Ubuntu 15.04, Vivid Vervet

deb mirror://mirrors.ubuntu.com/mirrors.txt vivid main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid universe
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates universe
 
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid-updates multiverse
 
deb mirror://mirrors.ubuntu.com/mirrors.txt vivid-backports main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt vivid-backports main restricted universe multiverse
 
deb http://security.ubuntu.com/ubuntu vivid-security main restricted
deb-src http://security.ubuntu.com/ubuntu vivid-security main restricted
deb http://security.ubuntu.com/ubuntu vivid-security universe
deb-src http://security.ubuntu.com/ubuntu vivid-security universe
deb http://security.ubuntu.com/ubuntu vivid-security multiverse
deb-src http://security.ubuntu.com/ubuntu vivid-security multiverse
 
deb http://archive.canonical.com/ubuntu vivid partner
deb-src http://archive.canonical.com/ubuntu vivid partner
 
deb http://extras.ubuntu.com/ubuntu vivid main
deb-src http://extras.ubuntu.com/ubuntu vivid main

Ubuntu 15.10, Wily Werewolf

deb mirror://mirrors.ubuntu.com/mirrors.txt wily main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt wily-updates main restricted
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily-updates main restricted
 
deb mirror://mirrors.ubuntu.com/mirrors.txt wily universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily universe
deb mirror://mirrors.ubuntu.com/mirrors.txt wily-updates universe
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily-updates universe
 
deb mirror://mirrors.ubuntu.com/mirrors.txt wily multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt wily-updates multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily-updates multiverse
 
deb mirror://mirrors.ubuntu.com/mirrors.txt wily-backports main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt wily-backports main restricted universe multiverse
 
deb http://security.ubuntu.com/ubuntu wily-security main restricted
deb-src http://security.ubuntu.com/ubuntu wily-security main restricted
deb http://security.ubuntu.com/ubuntu wily-security universe
deb-src http://security.ubuntu.com/ubuntu wily-security universe
deb http://security.ubuntu.com/ubuntu wily-security multiverse
deb-src http://security.ubuntu.com/ubuntu wily-security multiverse
 
deb http://archive.canonical.com/ubuntu wily partner
deb-src http://archive.canonical.com/ubuntu wily partner
 
deb http://extras.ubuntu.com/ubuntu wily main
deb-src http://extras.ubuntu.com/ubuntu wily main