Projects/fedora-mirror

= fedora-mirror.py =

A tool for synchronizing a local mirror of fedora rpms.

Goals

 * Being able to cleanly maintain a local mirror for fedora packages.
 * Zero config as far as possible

Non-Goals

 * This is not a replacement for rsync - it just makes it possible for people w/o access to an rsync server to sensibly synchronize to a local repository. If you have access to rsync servers, use them.

Status

 * Using reposync as backend
 * Basics are working

Code

 * make everything configureable to the bone and internally use a nested dictionary. needs code addition to the main loop.
 * Config Parser
 * logging
 * legacy and updates-testing awareness
 * fix hierachy into the fedora mirror dir scheme
 * use separate configs for each release
 * progressbars
 * eta (complete, per repo, per file(?!))
 * more exceptions

Support files/packaging/integration

 * creation of specially crafted .repo files
 * cron integration
 * 0 conf apache serving as split package
 * mock config files as split package
 * yum localmirror config files as split package
 * discuss access rights on /srv/mirror

Source Code

 * 1) !/usr/bin/python

import os

flavourlist=["core", "extras", "updates", "updates-testing", "legacy"] versionlist=["development", "5"] archlist=["i386", "x86_64", "ppc"] subflavourlist=["debuginfo", "source"]
 * 1) targetlocation="/home/che/mirror"

from optparse import OptionParser

parser = OptionParser

parser.add_option("-d", "--dest", dest="destination", help="Sync Destination", metavar="dir", default="/srv/mirror") parser.add_option("-n", "--newonly", action="store_true", dest="newonly", help="Sync Destination", default=False) parser.add_option("-t", "--testonly", action="store_true", dest="testonly", help="No Sync Transaction", default=False) parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status msgs to stdout")

(options, args) = parser.parse_args

targetlocation = options.destination

def syncMirror (version, flavour, arch, subflavour, targetlocation): print "syncing: Fedora " + version, flavour, arch, subflavour, "to", targetlocation

if subflavour == "binary": subflavourid = "" subflavourpath = "" elif subflavour == "source": subflavourid = "-"+subflavour subflavourpath = "/SRPMS" else: subflavourid = "-"+subflavour subflavourpath = "-"+subflavour

if version == "development": repoid="mirror-"+flavour+"-"+version+subflavourid else: repoid="mirror-"+flavour+subflavourid

if subflavour == "source": targetdir=targetlocation+"/fedora/"+version+"/"+flavour+subflavourpath else: targetdir=targetlocation+"/fedora/"+version+"/"+flavour+"/"+arch+subflavourpath

if options.newonly == True: newonly = " -n" else: newonly = ""

syncdistro="mirrorreleasever="+version+" mirrorbasearch="+arch+" /usr/bin/reposync"+newonly+" -r "+repoid+" -p "+targetdir

if options.testonly == True: print syncdistro else:

try: if os.path.isdir(targetdir) == False: os.makedirs(targetdir) except: print "Error: Cannot create targetdirectory:", targetdir

os.system(syncdistro)

for version in versionlist: for flavour in flavourlist: for arch in archlist: for subflavour in subflavourlist:

if version == "development" and flavour == "updates": continue if version == "development" and flavour == "legacy": continue if version == "development" and flavour == "updates-testing": continue else: syncMirror(version, flavour, arch, subflavour, targetlocation)