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

View File

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