Since I’m a Fedora/RH guy, I’ve been using Fedora 13 for most of my VMs. (The main exception is OpenIndiana, which I have for the ZFS support – It’s sharing my crucial stuff over the network.)
Since Fedora 14’s been released, I’m going to move to that to play around with my VM infrastructure. But, one thing that I’ve been neglecting is the fact that so far I’ve been downloading all the packages from a Fedora mirror. So, today I got around to fixing it, thanks to Google, a nice blog post, and some stack overflow help.
So, code first, followed by explanations.
# This script will create a local Fedora 14 mirror via Rsync using the riken mirror. If you're in Asia, this is one of the better mirrors, since it's got 10Gbps of bandwidth.
rsync="rsync -avvrt --progress"
for ver in $verlist
if [ ! -d "$local/$ver/" ];
then mkdir "$local/$ver/"
for arch in $archlist
if [ ! -d "$local/$ver/$arch/" ];
then mkdir "$local/$ver/$arch/"
for base in $baselist
if [ ! -d "$local/$ver/$arch/$base/" ];
then mkdir "$local/$ver/$arch/$base/"
$rsync $remote $local/$ver/$arch/$base/
Unfortunately, WordPress is massacring my nicely indented code. Anyway, it’s based off this code, with a dosage of good old bash trickery to automagically create the directories. Now you can completely skip the directory creation step, the script will take care of that automatically. What is nice is that when Fedora 15 comes out, I just have to add ’15’ in the verlist, and run it again.
(As a side note, this suggests that bash can use the double bracket ([]) instead of a single bracket () for a faster comparison. But I never got it to work – I’d get an error before the script moved on automatically.)