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.
This commit is contained in:
Brian C. Lane 2019-08-01 12:17:00 -07:00
parent babf823b1b
commit 361c6de2de
2 changed files with 18 additions and 7 deletions

View File

@ -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)

View File

@ -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