lorax: Add option to exclude packages

Sometimes the repos you are using have broken deps. Now you
can exclude packages with -e or --excludepkgs
This commit is contained in:
Brian C. Lane 2012-01-04 13:39:12 -08:00
parent 3c02a01a81
commit b41ab87427
1 changed files with 8 additions and 2 deletions

View File

@ -67,6 +67,9 @@ def main(args):
help="config file", metavar="STRING")
optional.add_option("--proxy", default=None,
help="repo proxy url:port", metavar="STRING")
optional.add_option("-e", "--excludepkgs", default=[],
action="append", metavar="STRING",
help="package glob to exclude (may be listed multiple times)")
# add the option groups to the parser
parser.add_option_group(required)
@ -106,7 +109,7 @@ def main(args):
os.mkdir(yumtempdir)
yb = get_yum_base_object(installtree, opts.source, opts.mirrorlist,
yumtempdir, opts.proxy)
yumtempdir, opts.proxy, opts.excludepkgs)
if yb is None:
print("error: unable to create the yumbase object", file=sys.stderr)
@ -122,7 +125,7 @@ def main(args):
def get_yum_base_object(installroot, repositories, mirrorlists=[],
tempdir="/tmp", proxy=None):
tempdir="/tmp", proxy=None, excludepkgs=[]):
def sanitize_repo(repo):
if repo.startswith("/"):
@ -160,6 +163,9 @@ def get_yum_base_object(installroot, repositories, mirrorlists=[],
if proxy:
data["proxy"] = proxy
if excludepkgs:
data["exclude"] = " ".join(excludepkgs)
c.add_section(section)
map(lambda (key, value): c.set(section, key, value), data.items())