From 361c6de2deac987c3e29f9e77363d111feba0f18 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 1 Aug 2019 12:17:00 -0700 Subject: [PATCH] livemedia-creator: Use --compress-arg in mksquashfs Previously the --compress-arg option was only used for tar, this adds support for it to the squashfs.img creation used with live isos. --- src/pylorax/creator.py | 7 ++++++- tests/pylorax/test_creator.py | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pylorax/creator.py b/src/pylorax/creator.py index 6561aaa5..bd079739 100644 --- a/src/pylorax/creator.py +++ b/src/pylorax/creator.py @@ -120,8 +120,13 @@ def squashfs_args(opts): """ compression = opts.compression or "xz" arch = ArchData(opts.arch or os.uname().machine) - if compression == "xz" and arch.bcj: + if compression == "xz" and arch.bcj and not opts.compress_args: + # default to bcj when using xz compressargs = ["-Xbcj", arch.bcj] + elif opts.compress_args: + compressargs = [] + for arg in opts.compress_args: + compressargs += arg.split(" ", 1) else: compressargs = [] return (compression, compressargs) diff --git a/tests/pylorax/test_creator.py b/tests/pylorax/test_creator.py index efd48338..7c38ba1f 100644 --- a/tests/pylorax/test_creator.py +++ b/tests/pylorax/test_creator.py @@ -56,12 +56,18 @@ class CreatorTest(unittest.TestCase): } for arch in test_arches: - opts = DataHolder(compression=None, arch=arch) + opts = DataHolder(compression=None, compress_args=[], arch=arch) self.assertEqual(squashfs_args(opts), test_arches[arch], (opts, squashfs_args(opts))) - opts = DataHolder(compression="lzma", arch="x86_64") + opts = DataHolder(compression="lzma", compress_args=[], arch="x86_64") self.assertEqual(squashfs_args(opts), ("lzma", []), (opts, squashfs_args(opts))) + opts = DataHolder(compression="xz", compress_args=["-X32767"], arch="x86_64") + self.assertEqual(squashfs_args(opts), ("xz", ["-X32767"]), (opts, squashfs_args(opts))) + + opts = DataHolder(compression="xz", compress_args=["-X32767", "-Xbcj x86"], arch="x86_64") + self.assertEqual(squashfs_args(opts), ("xz", ["-X32767", "-Xbcj", "x86"]), (opts, squashfs_args(opts))) + def make_appliance_test(self): """Test creating the appliance description XML file""" lorax_templates = find_templates("./share/") @@ -122,8 +128,8 @@ class CreatorTest(unittest.TestCase): with tempfile.TemporaryDirectory(prefix="lorax.test.root.") as mount_dir: # Make a fake kernel and initrd mkFakeBoot(mount_dir) - opts = DataHolder(project="Fedora", releasever="devel", compression="xz", arch="x86_64", - squashfs_only=True) + opts = DataHolder(project="Fedora", releasever="devel", compression="xz", compress_args=[], + arch="x86_64", squashfs_only=True) make_runtime(opts, mount_dir, work_dir) # Make sure it made an install.img @@ -146,8 +152,8 @@ class CreatorTest(unittest.TestCase): with tempfile.TemporaryDirectory(prefix="lorax.test.root.") as mount_dir: # Make a fake kernel and initrd mkFakeBoot(mount_dir) - opts = DataHolder(project="Fedora", releasever="devel", compression="xz", arch="x86_64", - squashfs_only=False) + opts = DataHolder(project="Fedora", releasever="devel", compression="xz", compress_args=[], + arch="x86_64", squashfs_only=False) make_runtime(opts, mount_dir, work_dir) # Make sure it made an install.img