Version 1 (modified by james, 9 years ago)
move from code snippets page

This helps you setup a repo at an arbitrary location, as a user and play with the object. Paste this into a file then run it with ipython for maximum usefulness like:

ipython ./thisfile.py url://to/my/repo

my = yum.YumBase()
my.conf.basecachedir = '/tmp/whereever'
if not os.path.exists(my.conf.basecachedir):
os.makedirs(my.conf.basecachedir)
my.conf.cache = 0
url = sys.argv[1] 

my.repos.disableRepo('*')

newrepo = yum.yumRepo.YumRepository('myrepo')
newrepo.name = 'myrepo - %s' % url
newrepo.baseurl = [url] 
newrepo.basecachedir = my.conf.basecachedir
newrepo.enablegroups = True
my.repos.add(newrepo)
my.repos.enableRepo(newrepo.id)
my.doRepoSetup(thisrepo=newrepo.id)