Added option to remove packages (parallel to installpkgs)

This commit is contained in:
Pat Riehecky 2016-11-04 14:25:33 -05:00 committed by Brian C. Lane
parent 5aa6fea8c3
commit 7ca356845b
4 changed files with 11 additions and 3 deletions

View File

@ -165,7 +165,7 @@ class Lorax(BaseLoraxClass):
def run(self, dbo, product, version, release, variant="", bugurl="",
isfinal=False, workdir=None, outputdir=None, buildarch=None, volid=None,
domacboot=True, doupgrade=True, remove_temp=False,
installpkgs=None,
installpkgs=None, excludepkgs=None,
size=2,
add_templates=None,
add_template_vars=None,
@ -176,6 +176,7 @@ class Lorax(BaseLoraxClass):
assert self._configured
installpkgs = installpkgs or []
excludepkgs = excludepkgs or []
# get lorax version
try:
@ -270,6 +271,7 @@ class Lorax(BaseLoraxClass):
rb = RuntimeBuilder(product=self.product, arch=self.arch,
dbo=dbo, templatedir=self.templatedir,
installpkgs=installpkgs,
excludepkgs=excludepkgs,
add_templates=add_templates,
add_template_vars=add_template_vars)

View File

@ -65,6 +65,9 @@ def lorax_parser():
optional.add_argument("-i", "--installpkgs", default=[],
action="append", metavar="PACKAGE",
help="package glob to install before runtime-install.tmpl runs. (may be listed multiple times)")
optional.add_argument("-e", "--excludepkgs", default=[],
action="append", metavar="PACKAGE",
help="package glob to remove before runtime-install.tmpl runs. (may be listed multiple times)")
optional.add_argument("--buildarch", default=None,
help="build architecture", metavar="ARCH")
optional.add_argument("--volid", default=None,

View File

@ -70,7 +70,7 @@ def generate_module_info(moddir, outfile=None):
class RuntimeBuilder(object):
'''Builds the anaconda runtime image.'''
def __init__(self, product, arch, dbo, templatedir=None,
installpkgs=None,
installpkgs=None, excludepkgs=None,
add_templates=None,
add_template_vars=None):
root = dbo.conf.installroot
@ -85,6 +85,7 @@ class RuntimeBuilder(object):
self.add_templates = add_templates or []
self.add_template_vars = add_template_vars or {}
self._installpkgs = installpkgs or []
self._excludepkgs = excludepkgs or []
self._runner.defaults = self.vars
self.dbo.reset()
@ -116,6 +117,8 @@ class RuntimeBuilder(object):
self._install_branding()
if len(self._installpkgs) > 0:
self._runner.installpkg(*self._installpkgs)
if len(self._excludepkgs) > 0:
self._runner.removepkg(*self._excludepkgs)
self._runner.run("runtime-install.tmpl")
for tmpl in self.add_templates:
self._runner.run(tmpl, **self.add_template_vars)

View File

@ -124,7 +124,7 @@ def main():
opts.variant, opts.bugurl, opts.isfinal,
workdir=tempdir, outputdir=opts.outputdir, buildarch=opts.buildarch,
volid=opts.volid, domacboot=opts.domacboot, doupgrade=opts.doupgrade,
installpkgs=opts.installpkgs,
installpkgs=opts.installpkgs, excludepkgs=opts.excludepkgs,
size=opts.rootfs_size,
add_templates=opts.add_templates,
add_template_vars=parsed_add_template_vars,