New - custom lorax templates for livemedia tasks

This adds two new options (--lorax_url and --lorax_dir) to the Koji CLI
so that it's now possible to use custom lorax templates for livemedia
tasks.  The custom templates must come from a supported, allowed SCM,
which makes it trivial to inject the whole directory structure of
template files that lorax expects.

In addition to the CLI changes, kojid's LiveMediaTask handler recognizes
these new options and acts accordingly by extending the
livemedia-creator call via its --lorax-templates option.
This commit is contained in:
John Florian 2016-12-08 11:14:49 -05:00 committed by Mike McLean
parent 86fa50077d
commit 3e2a737e32
2 changed files with 38 additions and 0 deletions

View file

@ -3081,6 +3081,29 @@ class LiveMediaTask(ImageTask):
# https://bugzilla.redhat.com/show_bug.cgi?id=1315541
bind_opts = {}
def fetch_lorax_templates_from_scm(self, build_root):
"""
Make a checkout of the lorax templates from SCM so that they may be
passed to livemedia-creator. Here we are operating outside the chroot
of the BuildRoot. The following options are essential:
- lorax_url points to the SCM containing the templates.
- lorax_dir provides a relative reference to the templates within
the checkout.
:param build_root:
The BuildRoot instance to receive the checkout.
:return:
An absolute path (from within the chroot) to where livemedia-creator
can find the checked out templates.
"""
scm = SCM(self.opts['lorax_url'])
scm.assert_allowed(self.options.allowed_scms)
logfile = os.path.join(self.workdir, 'lorax-templates-checkout.log')
checkout_dir = scm.checkout(os.path.join(build_root.rootdir(), 'tmp'),
self.session, self.getUploadDir(), logfile)
return os.path.join(build_root.relpath(checkout_dir),
self.opts['lorax_dir'])
def genISOManifest(self, image, manifile):
"""
Using iso9660 from pycdio, get the file manifest of the given image,
@ -3194,6 +3217,10 @@ class LiveMediaTask(ImageTask):
if arch == 'x86_64':
cmd.append('--macboot')
if 'lorax_url' in self.opts:
templates_dir = self.fetch_lorax_templates_from_scm(broot)
cmd.extend(['--lorax-templates', templates_dir])
# Run livemedia-creator
rv = broot.mock(['--cwd', '/tmp', '--chroot', '--'] + cmd)

View file

@ -5249,6 +5249,13 @@ def handle_spin_livemedia(options, session, args):
parser.add_option("--can-fail", action="store", dest="optional_arches",
metavar="ARCH1,ARCH2,...", default="",
help=_("List of archs which are not blocking for build (separated by commas."))
parser.add_option('--lorax_dir', metavar='DIR',
help=_('The relative path to the lorax templates '
'directory within the checkout of "lorax_url".'))
parser.add_option('--lorax_url', metavar='URL',
help=_('The URL to the SCM containing any custom lorax '
'templates that are to be used to override the '
'default templates.'))
(task_options, args) = parser.parse_args(args)
# Make sure the target and kickstart is specified.
@ -5257,6 +5264,9 @@ def handle_spin_livemedia(options, session, args):
" build target, an architecture, and a relative path to" +
" a kickstart file."))
assert False # pragma: no cover
if task_options.lorax_url is not None and task_options.lorax_dir is None:
parser.error(_('The "--lorax_url" option requires that "--lorax_dir" '
'also be used.'))
_build_image(options, task_options, session, args, 'livemedia')
@ -5638,6 +5648,7 @@ def _build_image(options, task_opts, session, args, img_type):
'format', 'install_tree_url', 'isoname', 'ksurl',
'ksversion', 'release', 'repo', 'scratch', 'skip_tag',
'specfile', 'title', 'vcpu', 'vmem', 'optional_arches',
'lorax_dir', 'lorax_url',
]
for opt in passthru_opts:
val = getattr(task_opts, opt, None)