Setup mirrors properly in Fedora 16

Fedora 16 (and older versions) comes already preconfigured so yum downloads packages from nearest mirror. That is cool, but once you are using proxy for speeding up you will be always re-downloading packages again, because mirrors are picked up in a random order.

If you uncomment the baseurl and comment out mirrorlist in the repositories, the situation is the same. The main download site does not provide RPM packages directly, but redirect to mirrors only based on geo location. Again in a random order.

If you want to be sure you are always downloading from the same place, you have to put the URL manually there. And I have a script to do it for you, just edit the MIRRORURL variable here to a nearest (or fastest) mirror. You are looking for a directory that contains releases and updates folders.
sed -i "s|^# *baseurl=$BASEURL/releases|baseurl=$MIRRURL/releases|g" /etc/yum.repos.d/fedora.repo
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/fedora.repo
sed -i "s|^# *baseurl=$BASEURL/updates|baseurl=$MIRRURL/updates|g" /etc/yum.repos.d/fedora-updates.repo
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/fedora-updates.repo
It should work in Fedora 13+. Maybe even older versions.
24 November 2011 | fedora