Add --squashfs-only option to drop inner rootfs.img layer

Make runtime directly into squashfs image. This reduces largely
unreproducible ext4 layer, but requires anaconda's dracut module
modification to properly mount the image.

(cherry picked from commit 27e611629f)
Signed-off-by: Brian C. Lane <bcl@redhat.com>

Resolves: rhbz#1846282
This commit is contained in:
Marek Marczykowski-Górecki 2018-10-03 20:00:19 +02:00 committed by Brian C. Lane
parent edee60437d
commit 6291373794
5 changed files with 27 additions and 7 deletions

View File

@ -187,7 +187,8 @@ class Lorax(BaseLoraxClass):
add_arch_template_vars=None,
verify=True,
user_dracut_args=None,
skip_branding=False):
skip_branding=False,
squashfs_only=False):
assert self._configured
@ -320,9 +321,16 @@ class Lorax(BaseLoraxClass):
compressargs += ["-Xbcj", self.arch.bcj]
else:
logger.info("no BCJ filter for arch %s", self.arch.basearch)
rb.create_runtime(joinpaths(installroot,runtime),
compression=compression, compressargs=compressargs,
size=size)
if squashfs_only:
# Create an ext4 rootfs.img and compress it with squashfs
rb.create_squashfs_runtime(joinpaths(installroot,runtime),
compression=compression, compressargs=compressargs,
size=size)
else:
# Create an ext4 rootfs.img and compress it with squashfs
rb.create_ext4_runtime(joinpaths(installroot,runtime),
compression=compression, compressargs=compressargs,
size=size)
rb.finished()
logger.info("preparing to build output tree and boot images")

View File

@ -109,6 +109,8 @@ def lorax_parser(dracut_default=""):
help="Do not verify SSL certificates")
optional.add_argument("--skip-branding", action="store_true", default=False,
help="Disable automatic branding package selection. Use --installpkgs to add custom branding.")
optional.add_argument("--squashfs-only", action="store_true", default=False,
help="Use a plain squashfs filesystem for the runtime.")
# dracut arguments
dracut_group = parser.add_argument_group("dracut arguments")

View File

@ -203,7 +203,7 @@ def make_runtime(opts, mount_dir, work_dir, size=None):
rb = RuntimeBuilder(product, arch, fake_dbo)
compression, compressargs = squashfs_args(opts)
log.info("Creating runtime")
rb.create_runtime(joinpaths(work_dir, RUNTIME), size=size,
rb.create_ext4_runtime(joinpaths(work_dir, RUNTIME), size=size,
compression=compression, compressargs=compressargs)

View File

@ -229,7 +229,16 @@ class RuntimeBuilder(object):
runcmd(["depmod", "-a", "-F", ksyms, "-b", root, kernel.version])
generate_module_info(moddir+kernel.version, outfile=moddir+"module-info")
def create_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=None, size=2):
def create_squashfs_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=None, size=2):
"""Create a plain squashfs runtime"""
compressargs = compressargs or []
os.makedirs(os.path.dirname(outfile))
# squash the rootfs
imgutils.mksquashfs(self.vars.root, outfile, compression, compressargs)
def create_ext4_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=None, size=2):
"""Create a squashfs compressed ext4 runtime"""
# make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
compressargs = compressargs or []
workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")

View File

@ -193,7 +193,8 @@ def main():
add_arch_template_vars=parsed_add_arch_template_vars,
remove_temp=True, verify=opts.verify,
user_dracut_args=opts.dracut_args,
skip_branding=opts.skip_branding)
skip_branding=opts.skip_branding,
squashfs_only=opts.squashfs_only)
# Release the lock on the tempdir
os.close(dir_fd)