[Yum-devel] repoclosure patch
Bill Nottingham
notting at redhat.com
Thu Jun 2 20:20:57 UTC 2005
(Warning: I'm not subscribed; please CC: me on replies.)
The attached adds option parsing to repoclosure, and adds the
following options:
1) -c - specify a different conf file
2) -a - specify what base arch to use to check the repository
Basically, both needed for checking 'repositories other than the
ones you're using on a machine.' Such as the rawhide trees you just
built, or something like that. :)
Bill
-------------- next part --------------
Index: repoclosure.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum-utils/repoclosure.py,v
retrieving revision 1.2
diff -u -r1.2 repoclosure.py
--- repoclosure.py 22 Mar 2005 13:54:33 -0000 1.2
+++ repoclosure.py 2 Jun 2005 20:20:30 -0000
@@ -25,6 +25,8 @@
import yum.Errors
import sys
import os
+from optparse import OptionParser
+import rpmUtils.arch
flagsdict = {'GT':'>', 'LT':'<', 'EQ': '=', 'GE':'>=', 'LE':'<='}
@@ -46,7 +48,15 @@
return val
-
+def parseArgs():
+ usage = "usage: %s [-c <config file>] [-a <arch>] [repoid] [repoid2...]" % sys.argv[0]
+ parser = OptionParser(usage=usage)
+ parser.add_option("-c", default='/etc/yum.conf', dest="config",
+ help='config file to use (defaults to /etc/yum.conf)')
+ parser.add_option("-a", default=None, dest="arch",
+ help='check as if running the specified arch (default: current arch)')
+ (opts, args) = parser.parse_args()
+ return (opts, args)
class YumQuiet(yum.YumBase):
def __init__(self):
@@ -55,10 +65,10 @@
def log(self, value, msg):
pass
-def main(repoids=None):
-
+def main(args):
+ (opts, repoids) = parseArgs()
my = YumQuiet()
- my.doConfigSetup()
+ my.doConfigSetup(fn = opts.config)
if hasattr(my.repos, 'sqlite'):
my.repos.sqlite = False
my.repos._selectSackType()
@@ -67,7 +77,7 @@
my.conf.setConfigOption('cache', 1)
print 'Not running as root, might not be able to import all of cache'
- if repoids is not None:
+ if repoids:
for repo in my.repos.repos.values():
if repo.id not in repoids:
repo.disable()
@@ -76,7 +86,7 @@
my.doRepoSetup()
print 'Reading in repository metadata - please wait....'
- my.doSackSetup()
+ my.doSackSetup(rpmUtils.arch.getArchList(opts.arch))
for repo in my.repos.listEnabled():
try:
More information about the Yum-devel
mailing list