From 2a6156b9da18541342c59a6b3a037bd544fbf497 Mon Sep 17 00:00:00 2001
From: Jana Cupova <jcupova@redhat.com>
Date: May 06 2021 09:40:16 +0000
Subject: Add squashfs-only and compress-arg options to livemedia


Fixes: https://pagure.io/koji/issue/2476

---

diff --git a/builder/kojid b/builder/kojid
index 9c2cd01..07a60d0 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -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)
 
diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py
index 4bc724a..ffe4762 100644
--- a/cli/koji_cli/commands.py
+++ b/cli/koji_cli/commands.py
@@ -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)
diff --git a/tests/test_cli/test_spin_commands.py b/tests/test_cli/test_spin_commands.py
index ac1bebe..7c13a16 100644
--- a/tests/test_cli/test_spin_commands.py
+++ b/tests/test_cli/test_spin_commands.py
@@ -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))
 
 

