refactor: rename "compression speed" -> "compression args"

This makes the compression code slightly more generic:

- [compression] "speed" config item renamed to "args"
- default changed from "9" to "-9"
- "cspeed" variables renamed "cargs"
- pass "args.split()" on compress cmdline instead of "-%s" % speed
This commit is contained in:
Will Woods 2011-06-09 13:00:20 -04:00
parent 41dd493274
commit 6b8fa8447a
3 changed files with 17 additions and 17 deletions

View File

@ -103,7 +103,7 @@ 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", "-9")
# read the config file
if os.path.isfile(conf_file):
@ -380,7 +380,7 @@ class Lorax(BaseLoraxClass):
imgclass = factory.get_class(self.basearch)
ctype = self.conf.get("compression", "type")
cspeed = self.conf.get("compression", "speed")
cargs = self.conf.get("compression", "args")
i = imgclass(kernellist=self.outputtree.kernels,
installtree=self.installtree,
@ -390,7 +390,7 @@ class Lorax(BaseLoraxClass):
treeinfo=treeinfo,
basearch=self.basearch,
ctype=ctype,
cspeed=cspeed)
cargs=cargs)
# backup required files
i.backup_required(self.workdir)

View File

@ -79,7 +79,7 @@ SPARCDIR = "boot"
class PPC(object):
def __init__(self, kernellist, installtree, outputroot, product, version,
treeinfo, basearch, ctype, cspeed):
treeinfo, basearch, ctype, cargs):
self.kernellist = kernellist
self.installtree = installtree
@ -89,7 +89,7 @@ class PPC(object):
self.treeinfo = treeinfo
self.basearch = basearch
self.ctype = ctype
self.cspeed = cspeed
self.cargs = cargs
self.kernels, self.initrds = [], []
self.reqs = collections.defaultdict(str)
@ -178,7 +178,7 @@ class PPC(object):
initrd.itype = kernel.ktype
logger.info("compressing the install tree")
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
self.installtree.compress(initrd, kernel, self.ctype, self.cargs)
# add kernel and initrd to the list
self.kernels.append(kernel)
@ -361,7 +361,7 @@ class PPC(object):
class X86(object):
def __init__(self, kernellist, installtree, outputroot, product, version,
treeinfo, basearch, ctype, cspeed):
treeinfo, basearch, ctype, cargs):
self.kernellist = kernellist
self.installtree = installtree
@ -371,7 +371,7 @@ class X86(object):
self.treeinfo = treeinfo
self.basearch = basearch
self.ctype = ctype
self.cspeed = cspeed
self.cargs = cargs
self.kernels, self.initrds = [], []
self.reqs = collections.defaultdict(str)
@ -512,7 +512,7 @@ class X86(object):
initrd.itype = kernel.ktype
logger.info("compressing the install tree")
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
self.installtree.compress(initrd, kernel, self.ctype, self.cargs)
# add kernel and initrd to the list
self.kernels.append(kernel)
@ -586,7 +586,7 @@ class X86(object):
class S390(object):
def __init__(self, kernellist, installtree, outputroot, product, version,
treeinfo, basearch, ctype, cspeed):
treeinfo, basearch, ctype, cargs):
self.kernellist = kernellist
self.installtree = installtree
@ -596,7 +596,7 @@ class S390(object):
self.treeinfo = treeinfo
self.basearch = basearch
self.ctype = ctype
self.cspeed = cspeed
self.cargs = cargs
self.kernels, self.initrds = [], []
self.reqs = collections.defaultdict(str)
@ -636,7 +636,7 @@ class S390(object):
initrd.fpath = joinpaths(self.outputroot, IMAGESDIR, initrd.fname)
logger.info("compressing the install tree")
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
self.installtree.compress(initrd, kernel, self.ctype, self.cargs)
# run addrsize
addrsize = joinpaths(self.installtree.root, "usr/libexec",
@ -685,7 +685,7 @@ class S390(object):
class SPARC(object):
def __init__(self, kernellist, installtree, outputroot, product, version,
treeinfo, basearch, ctype, cspeed):
treeinfo, basearch, ctype, cargs):
self.kernellist = kernellist
self.installtree = installtree
@ -695,7 +695,7 @@ class SPARC(object):
self.treeinfo = treeinfo
self.basearch = basearch
self.ctype = ctype
self.cspeed = cspeed
self.cargs = cargs
self.kernels, self.initrds = [], []
self.reqs = collections.defaultdict(str)
@ -744,7 +744,7 @@ class SPARC(object):
initrd.fpath = joinpaths(self.outputroot, SPARCDIR, initrd.fname)
logger.info("compressing the install tree")
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
self.installtree.compress(initrd, kernel, self.ctype, self.cargs)
# add kernel and initrd to .treeinfo
kernel_arch = kernel.version.split(".")[-1]

View File

@ -504,7 +504,7 @@ class LoraxInstallTree(BaseLoraxClass):
dst = joinpaths(self.root, "sbin")
shutil.copy2(src, dst)
def compress(self, initrd, kernel, type="xz", speed="9"):
def compress(self, initrd, kernel, type="xz", args="-9"):
chdir = lambda: os.chdir(self.root)
start = time.time()
@ -521,7 +521,7 @@ class LoraxInstallTree(BaseLoraxClass):
stdin=find.stdout, stdout=subprocess.PIPE,
preexec_fn=chdir)
cmd = [type, "-%s" % speed]
cmd = [type, args.split()]
if type == "xz":
cmd.append("--check=crc32")