diff --git a/repoquery.py b/repoquery.py index 3fe7fee..37bdfe7 100755 --- a/repoquery.py +++ b/repoquery.py @@ -24,6 +24,7 @@ import re import fnmatch import time import os +import os.path import exceptions from optparse import OptionParser @@ -625,6 +626,8 @@ def main(args): help="show all versions of packages") parser.add_option("--repoid", action="append", help="specify repoids to query, can be specified multiple times (default is all enabled)") + parser.add_option("--repofromdir", action="append", + help="specify paths to be treated as file:// repositories - complete path required, can be specified multiple times.") parser.add_option("--quiet", action="store_true", help="quiet (no output to stderr)", default=True) parser.add_option("--verbose", action="store_false", @@ -714,6 +717,18 @@ def main(args): repoq.doConfigSetup(fn=opts.conffile, debuglevel=initnoise) else: repoq.doConfigSetup(debuglevel=initnoise) + + if opts.repofromdir: + # setup the fake repos + for repopath in opts.repofromdir: + repopath = os.path.normpath(repopath) + repoid = repopath.split('/')[-1] + newrepo = yum.yumRepo.YumRepository(repoid) + newrepo.name = repopath + newrepo.baseurl = 'file://' + repopath + newrepo.basecachedir = repoq.conf.cachedir + repoq.repos.add(newrepo) + # Show what is going on, if --quiet is not set. if not opts.quiet and sys.stdout.isatty(): @@ -738,7 +753,7 @@ def main(args): if opts.show_dupes: repoq.conf.showdupesfromrepos = True - + if opts.repoid: for repo in repoq.repos.findRepos('*'): if repo.id not in opts.repoid: @@ -747,7 +762,7 @@ def main(args): repo.enable() repoq.doRepoSetup() - + for exp in regexs: if exp.endswith('.src'): needsource = 1