Add squashfs-only and compress-arg options to livemedia

Fixes: https://pagure.io/koji/issue/2476
This commit is contained in:
Jana Cupova 2021-04-26 10:32:41 +02:00 committed by Tomas Kopecek
parent df09be48e8
commit bef3eff0aa
3 changed files with 19 additions and 3 deletions

View file

@ -3569,6 +3569,12 @@ class LiveMediaTask(ImageTask):
templates_dir = self.fetch_lorax_templates_from_scm(broot)
cmd.extend(['--lorax-templates', templates_dir])
if self.opts.get('squashfs_only'):
cmd.append('--squashfs-only')
if isinstance(self.opts.get('compress_arg'), (list, tuple)):
for com_arg in self.opts['compress_arg']:
cmd.extend(['--compress-arg', com_arg])
# Run livemedia-creator
rv = broot.mock(['--cwd', broot.tmpdir(within=True), '--chroot', '--'] + cmd)

View file

@ -5796,6 +5796,10 @@ def handle_spin_livemedia(options, session, args):
help=_("Pass the nomacboot option to livemedia-creator"))
parser.add_option('--ksrepo', action="store_true",
help=_("Do not overwrite repos in the kickstart"))
parser.add_option('--squashfs-only', action="store_true",
help=_("Use a plain squashfs filesystem."))
parser.add_option('--compress-arg', action="append", default=[], metavar="ARG OPT",
help=_("List of compressions."))
(task_options, args) = parser.parse_args(args)
# Make sure the target and kickstart is specified.
@ -6177,6 +6181,7 @@ def _build_image(options, task_opts, session, args, img_type):
'ksversion', 'release', 'repo', 'scratch', 'skip_tag',
'specfile', 'vcpu', 'vmem', 'volid', 'optional_arches',
'lorax_dir', 'lorax_url', 'nomacboot', 'ksrepo',
'squashfs_only', 'compress_arg',
]
for opt in passthru_opts:
val = getattr(task_opts, opt, None)
@ -6185,7 +6190,6 @@ def _build_image(options, task_opts, session, args, img_type):
if 'optional_arches' in hub_opts:
hub_opts['optional_arches'] = hub_opts['optional_arches'].split(',')
# finally, create the task.
task_id = session.buildImage(args[0], args[1], arch, target, ksfile,
img_type, opts=hub_opts, priority=priority)
@ -6253,7 +6257,6 @@ def _build_image_oz(options, task_opts, session, args):
val = getattr(task_opts, opt, None)
if val is not None:
hub_opts[opt] = val
# finally, create the task.
task_id = session.buildImageOz(args[0], args[1], arches, target, args[3],
opts=hub_opts, priority=priority)

View file

@ -5,7 +5,8 @@ import six
import unittest
import koji
from koji_cli.commands import handle_spin_livecd, handle_spin_livemedia, handle_spin_appliance, _build_image
from koji_cli.commands import handle_spin_livecd, handle_spin_livemedia, handle_spin_appliance, \
_build_image
from . import utils
@ -41,6 +42,8 @@ LIVEMEDIA_OPTIONS = {
"ksrepo": False,
"optional_arches": None,
"volid": None,
"squashfs_only": None,
"compress_arg": None,
}
APPLIANCE_OPTIONS = {
@ -352,6 +355,7 @@ class TestSpinLiveMedia(utils.CliTestCase):
args, kwargs = build_image_mock.call_args
empty_opts = dict((k, None) for k in LIVEMEDIA_OPTIONS)
empty_opts['optional_arches'] = ''
empty_opts['compress_arg'] = []
self.assertDictEqual(empty_opts, args[1].__dict__)
self.assertEqual(args[-1], 'livemedia')
@ -426,6 +430,9 @@ Options:
templates.
--nomacboot Pass the nomacboot option to livemedia-creator
--ksrepo Do not overwrite repos in the kickstart
--squashfs-only Use a plain squashfs filesystem.
--compress-arg=ARG OPT
List of compressions.
""" % (self.progname))