Mirroring Fedora 14 repos


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.
#!/bin/sh

# 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"
mirror=ftp.riken.jp::fedora
verlist="14"
archlist="x86_64"
baselist="os"
local=/home/mirror/fedora

for ver in $verlist
do
if [ ! -d "$local/$ver/" ];
then mkdir "$local/$ver/"
fi
for arch in $archlist
do
if [ ! -d "$local/$ver/$arch/" ];
then mkdir "$local/$ver/$arch/"
fi
for base in $baselist
do
if [ ! -d "$local/$ver/$arch/$base/" ];
then mkdir "$local/$ver/$arch/$base/"
fi
remote=$mirror/releases/$ver/Fedora/$arch/$base/
$rsync $remote $local/$ver/$arch/$base/
done
done
done

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.)

  1. No comments yet.
(will not be published)