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:
parent
41dd493274
commit
6b8fa8447a
@ -103,7 +103,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
|
|
||||||
self.conf.add_section("compression")
|
self.conf.add_section("compression")
|
||||||
self.conf.set("compression", "type", "xz")
|
self.conf.set("compression", "type", "xz")
|
||||||
self.conf.set("compression", "speed", "9")
|
self.conf.set("compression", "args", "-9")
|
||||||
|
|
||||||
# read the config file
|
# read the config file
|
||||||
if os.path.isfile(conf_file):
|
if os.path.isfile(conf_file):
|
||||||
@ -380,7 +380,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
imgclass = factory.get_class(self.basearch)
|
imgclass = factory.get_class(self.basearch)
|
||||||
|
|
||||||
ctype = self.conf.get("compression", "type")
|
ctype = self.conf.get("compression", "type")
|
||||||
cspeed = self.conf.get("compression", "speed")
|
cargs = self.conf.get("compression", "args")
|
||||||
|
|
||||||
i = imgclass(kernellist=self.outputtree.kernels,
|
i = imgclass(kernellist=self.outputtree.kernels,
|
||||||
installtree=self.installtree,
|
installtree=self.installtree,
|
||||||
@ -390,7 +390,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
treeinfo=treeinfo,
|
treeinfo=treeinfo,
|
||||||
basearch=self.basearch,
|
basearch=self.basearch,
|
||||||
ctype=ctype,
|
ctype=ctype,
|
||||||
cspeed=cspeed)
|
cargs=cargs)
|
||||||
|
|
||||||
# backup required files
|
# backup required files
|
||||||
i.backup_required(self.workdir)
|
i.backup_required(self.workdir)
|
||||||
|
@ -79,7 +79,7 @@ SPARCDIR = "boot"
|
|||||||
class PPC(object):
|
class PPC(object):
|
||||||
|
|
||||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||||
treeinfo, basearch, ctype, cspeed):
|
treeinfo, basearch, ctype, cargs):
|
||||||
|
|
||||||
self.kernellist = kernellist
|
self.kernellist = kernellist
|
||||||
self.installtree = installtree
|
self.installtree = installtree
|
||||||
@ -89,7 +89,7 @@ class PPC(object):
|
|||||||
self.treeinfo = treeinfo
|
self.treeinfo = treeinfo
|
||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
self.ctype = ctype
|
self.ctype = ctype
|
||||||
self.cspeed = cspeed
|
self.cargs = cargs
|
||||||
self.kernels, self.initrds = [], []
|
self.kernels, self.initrds = [], []
|
||||||
|
|
||||||
self.reqs = collections.defaultdict(str)
|
self.reqs = collections.defaultdict(str)
|
||||||
@ -178,7 +178,7 @@ class PPC(object):
|
|||||||
initrd.itype = kernel.ktype
|
initrd.itype = kernel.ktype
|
||||||
|
|
||||||
logger.info("compressing the install tree")
|
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
|
# add kernel and initrd to the list
|
||||||
self.kernels.append(kernel)
|
self.kernels.append(kernel)
|
||||||
@ -361,7 +361,7 @@ class PPC(object):
|
|||||||
class X86(object):
|
class X86(object):
|
||||||
|
|
||||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||||
treeinfo, basearch, ctype, cspeed):
|
treeinfo, basearch, ctype, cargs):
|
||||||
|
|
||||||
self.kernellist = kernellist
|
self.kernellist = kernellist
|
||||||
self.installtree = installtree
|
self.installtree = installtree
|
||||||
@ -371,7 +371,7 @@ class X86(object):
|
|||||||
self.treeinfo = treeinfo
|
self.treeinfo = treeinfo
|
||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
self.ctype = ctype
|
self.ctype = ctype
|
||||||
self.cspeed = cspeed
|
self.cargs = cargs
|
||||||
self.kernels, self.initrds = [], []
|
self.kernels, self.initrds = [], []
|
||||||
|
|
||||||
self.reqs = collections.defaultdict(str)
|
self.reqs = collections.defaultdict(str)
|
||||||
@ -512,7 +512,7 @@ class X86(object):
|
|||||||
initrd.itype = kernel.ktype
|
initrd.itype = kernel.ktype
|
||||||
|
|
||||||
logger.info("compressing the install tree")
|
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
|
# add kernel and initrd to the list
|
||||||
self.kernels.append(kernel)
|
self.kernels.append(kernel)
|
||||||
@ -586,7 +586,7 @@ class X86(object):
|
|||||||
class S390(object):
|
class S390(object):
|
||||||
|
|
||||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||||
treeinfo, basearch, ctype, cspeed):
|
treeinfo, basearch, ctype, cargs):
|
||||||
|
|
||||||
self.kernellist = kernellist
|
self.kernellist = kernellist
|
||||||
self.installtree = installtree
|
self.installtree = installtree
|
||||||
@ -596,7 +596,7 @@ class S390(object):
|
|||||||
self.treeinfo = treeinfo
|
self.treeinfo = treeinfo
|
||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
self.ctype = ctype
|
self.ctype = ctype
|
||||||
self.cspeed = cspeed
|
self.cargs = cargs
|
||||||
self.kernels, self.initrds = [], []
|
self.kernels, self.initrds = [], []
|
||||||
|
|
||||||
self.reqs = collections.defaultdict(str)
|
self.reqs = collections.defaultdict(str)
|
||||||
@ -636,7 +636,7 @@ class S390(object):
|
|||||||
initrd.fpath = joinpaths(self.outputroot, IMAGESDIR, initrd.fname)
|
initrd.fpath = joinpaths(self.outputroot, IMAGESDIR, initrd.fname)
|
||||||
|
|
||||||
logger.info("compressing the install tree")
|
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
|
# run addrsize
|
||||||
addrsize = joinpaths(self.installtree.root, "usr/libexec",
|
addrsize = joinpaths(self.installtree.root, "usr/libexec",
|
||||||
@ -685,7 +685,7 @@ class S390(object):
|
|||||||
class SPARC(object):
|
class SPARC(object):
|
||||||
|
|
||||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||||
treeinfo, basearch, ctype, cspeed):
|
treeinfo, basearch, ctype, cargs):
|
||||||
|
|
||||||
self.kernellist = kernellist
|
self.kernellist = kernellist
|
||||||
self.installtree = installtree
|
self.installtree = installtree
|
||||||
@ -695,7 +695,7 @@ class SPARC(object):
|
|||||||
self.treeinfo = treeinfo
|
self.treeinfo = treeinfo
|
||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
self.ctype = ctype
|
self.ctype = ctype
|
||||||
self.cspeed = cspeed
|
self.cargs = cargs
|
||||||
self.kernels, self.initrds = [], []
|
self.kernels, self.initrds = [], []
|
||||||
|
|
||||||
self.reqs = collections.defaultdict(str)
|
self.reqs = collections.defaultdict(str)
|
||||||
@ -744,7 +744,7 @@ class SPARC(object):
|
|||||||
initrd.fpath = joinpaths(self.outputroot, SPARCDIR, initrd.fname)
|
initrd.fpath = joinpaths(self.outputroot, SPARCDIR, initrd.fname)
|
||||||
|
|
||||||
logger.info("compressing the install tree")
|
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
|
# add kernel and initrd to .treeinfo
|
||||||
kernel_arch = kernel.version.split(".")[-1]
|
kernel_arch = kernel.version.split(".")[-1]
|
||||||
|
@ -504,7 +504,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
dst = joinpaths(self.root, "sbin")
|
dst = joinpaths(self.root, "sbin")
|
||||||
shutil.copy2(src, dst)
|
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)
|
chdir = lambda: os.chdir(self.root)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
stdin=find.stdout, stdout=subprocess.PIPE,
|
stdin=find.stdout, stdout=subprocess.PIPE,
|
||||||
preexec_fn=chdir)
|
preexec_fn=chdir)
|
||||||
|
|
||||||
cmd = [type, "-%s" % speed]
|
cmd = [type, args.split()]
|
||||||
if type == "xz":
|
if type == "xz":
|
||||||
cmd.append("--check=crc32")
|
cmd.append("--check=crc32")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user