From 3099c0a44df7914c53811817a31d81a9cb3a4832 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Wed, 20 Jul 2011 16:45:00 -0400 Subject: [PATCH] Configurable compression type/speed/bcj use * add bcj arch dict to ArchData * add "compression" settings back to __init__.py * pass them to treebuilder.create_runtime * pass them through to imgutils.mksquashfs --- src/pylorax/__init__.py | 18 +++++++++++++++--- src/pylorax/treebuilder.py | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 3b9967a3..6698e7e1 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -51,10 +51,14 @@ from discinfo import DiscInfo class ArchData(DataHolder): lib64_arches = ("x86_64", "ppc64", "sparc64", "s390x", "ia64") + bcj = dict(i386="x86", x86_64="x86", + ppc="powerpc", ppc64="powerpc", + sparc="sparc", sparc64="sparc") def __init__(self, buildarch): self.buildarch = buildarch self.basearch = getBaseArch(buildarch) self.libdir = "lib64" if self.basearch in self.lib64_arches else "lib" + self.bcj = bcj.get(self.basearch) class Lorax(BaseLoraxClass): @@ -83,7 +87,8 @@ class Lorax(BaseLoraxClass): self.conf.add_section("compression") self.conf.set("compression", "type", "xz") - self.conf.set("compression", "speed", "9") + self.conf.set("compression", "args", "") + self.conf.set("compression", "bcj", "on") # read the config file if os.path.isfile(conf_file): @@ -210,8 +215,15 @@ class Lorax(BaseLoraxClass): logger.info("creating the runtime image") runtime = "images/install.img" - # FIXME: compression options (type, speed, etc.) - rb.create_runtime(joinpaths(installroot,runtime)) + compression = self.conf.get("compression", "type") + compressargs = self.conf.get("compression", "args").split() + if self.conf.getboolean("compression", "bcj"): + if self.arch.bcj: + 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) logger.info("preparing to build output tree and boot images") treebuilder = TreeBuilder(product=self.product, arch=self.arch, diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index a6ab517d..ed3b0092 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -108,7 +108,7 @@ class RuntimeBuilder(object): check_call(["depmod", "-a", "-F", ksyms, "-b", root, kver]) generate_module_info(moddir+kver, outfile=moddir+"module-info") - def create_runtime(self, outfile="/tmp/squashfs.img"): + def create_runtime(self, outfile="/tmp/squashfs.img", compression="xz", compressargs=[]): # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir") fssize = 2 * (1024*1024*1024) # 2GB sparse file compresses down to nothin' @@ -116,7 +116,7 @@ class RuntimeBuilder(object): imgutils.mkext4img(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"), label="Anaconda", size=fssize) # squash the live rootfs and clean up workdir - imgutils.mksquashfs(workdir, outfile) + imgutils.mksquashfs(workdir, outfile, compression, compressargs) remove(workdir) class TreeBuilder(object):