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

= Status: =


 * Using reposync as backend


 * Basics are working

= Todo: =

Code:

 * ConfigParser


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