Changes from Version 1 of YumCodeSnippet/SetupArbitraryRepo

Show
Ignore:
Author:
james (IP: 65.172.155.230)
Timestamp:
02/02/09 15:42:42 (9 years ago)
Comment:

move from code snippets page

Legend:

Unmodified
Added
Removed
Modified
  • YumCodeSnippet/SetupArbitraryRepo

    v0 v1  
     1 
     2This 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: 
     3 
     4{{{ ipython ./thisfile.py url://to/my/repo }}} 
     5 
     6{{{ 
     7#!python 
     8my = yum.YumBase() 
     9my.conf.basecachedir = '/tmp/whereever' 
     10if not os.path.exists(my.conf.basecachedir): 
     11os.makedirs(my.conf.basecachedir) 
     12my.conf.cache = 0 
     13url = sys.argv[1]  
     14 
     15my.repos.disableRepo('*') 
     16 
     17newrepo = yum.yumRepo.YumRepository('myrepo') 
     18newrepo.name = 'myrepo - %s' % url 
     19newrepo.baseurl = [url]  
     20newrepo.basecachedir = my.conf.basecachedir 
     21newrepo.enablegroups = True 
     22my.repos.add(newrepo) 
     23my.repos.enableRepo(newrepo.id) 
     24my.doRepoSetup(thisrepo=newrepo.id) 
     25 
     26}}}