![](https://secure.gravatar.com/avatar/73a8f5105a881a41b5fe876b1ca926fc.jpg?s=120&d=mm&r=g)
Hi there, Nowadays most of us select a specific dl.sf.net mirror my means of /etc/hosts; this works good in most cases, however it has a couple of disadvantages: - it's static; added/removed hosts lead to errors - you potentially don't use the fastest server - sometimes, even your stable server might not have a file. As in our last IRC meeting the idea of addressing this in pkgutils was frowned upon (:-)), I chose a pure "userspace" approach, where the script is called from pkgmk.conf, and changes the entries in the 'source' array to select a mirror. The tool initially reads in a file and checks whether these servers (in order of appearance) have the source file to be downloaded by means of an HTTP HEAD request; if no mirror in this file has it, it'll run 'dig dl.sf.net', ping the hosts, sort them by ping time, and check whether one of those hosts have the file (chances are they do ;-)). Of course, the script can also generate an initial mirror file, which contains just a list of hosts sorted by their ping time; chances are you want to reorder it slightly to give preference to an "optimal" host, even if their ping time is slightly worse. When replacing a /etc/hosts setup, you gain a fallback when your main mirror doesn't have the file, or if it's offline; you pay that with an additional HTTP HEAD request. Or to put it slightly different, when using this script, if a download fails then it's definitely not a mirroring/DNS RR problem :-). The script can be found at http://jw.tks6.net/files/crux/sf-mirror-tool All you need is the following line in your pkgmk.conf, preferably after the last PKGMK_SOURCE_DIR setting (since it'll otherwise do an HTTP HEAD even if the file has already been downloaded): if [ "$PKGMK_DOWNLOAD" = "yes" ]; then . /path/to/sf-mirror-tool sf_replace_source verbose fi There are a number of things left to do, especially providing better feedback to the user (i.e. to point out that certain mirrors always fail, or even automatically disable them), but I'd still appreciate some feedback along the way, hence this post :-). Best regards, Johannes -- Johannes Winkelmann mailto:jw@tks6.net Zurich, Switzerland http://jw.tks6.net