Allow compression type be specified in lorax.conf
This commit is contained in:
parent
79b6e5bfa1
commit
421e4c3a00
@ -98,6 +98,13 @@ class Lorax(BaseLoraxClass):
|
||||
self.conf.add_section("templates")
|
||||
self.conf.set("templates", "ramdisk", "ramdisk.ltmpl")
|
||||
|
||||
self.conf.add_section("yum")
|
||||
self.conf.set("yum", "skipbroken", "0")
|
||||
|
||||
self.conf.add_section("compression")
|
||||
self.conf.set("compression", "type", "xz")
|
||||
self.conf.set("compression", "speed", "9")
|
||||
|
||||
# read the config file
|
||||
if os.path.isfile(conf_file):
|
||||
self.conf.read(conf_file)
|
||||
@ -251,7 +258,9 @@ class Lorax(BaseLoraxClass):
|
||||
# install packages
|
||||
for package in required:
|
||||
self.installtree.yum.install(package)
|
||||
self.installtree.yum.process_transaction()
|
||||
|
||||
skipbroken = self.conf.getboolean("yum", "skipbroken")
|
||||
self.installtree.yum.process_transaction(skipbroken)
|
||||
|
||||
# write .buildstamp
|
||||
buildstamp = BuildStamp(self.workdir, self.product, self.version,
|
||||
@ -370,13 +379,18 @@ class Lorax(BaseLoraxClass):
|
||||
factory = images.Factory()
|
||||
imgclass = factory.get_class(self.basearch)
|
||||
|
||||
ctype = self.conf.get("compression", "type")
|
||||
cspeed = self.conf.get("compression", "speed")
|
||||
|
||||
i = imgclass(kernellist=self.outputtree.kernels,
|
||||
installtree=self.installtree,
|
||||
outputroot=self.outputtree.root,
|
||||
product=self.product,
|
||||
version=self.version,
|
||||
treeinfo=treeinfo,
|
||||
basearch=self.basearch)
|
||||
basearch=self.basearch,
|
||||
ctype=ctype,
|
||||
cspeed=cspeed)
|
||||
|
||||
# backup required files
|
||||
i.backup_required(self.workdir)
|
||||
|
@ -41,7 +41,6 @@ class LoraxRequiredCommands(dict):
|
||||
self["DMSETUP"] = "dmsetup"
|
||||
self["FIND"] = "find"
|
||||
self["GCONFTOOL"] = "gconftool-2"
|
||||
self["GZIP"] = "gzip"
|
||||
self["IMPLANTISOMD5"] = "implantisomd5"
|
||||
self["ISOHYBRID"] = "isohybrid"
|
||||
self["LDCONFIG"] = "ldconfig"
|
||||
@ -54,7 +53,6 @@ class LoraxRequiredCommands(dict):
|
||||
self["PARTED"] = "parted"
|
||||
self["SSHKEYGEN"] = "ssh-keygen"
|
||||
self["UMOUNT"] = "umount"
|
||||
self["XZ"] = "xz"
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
|
@ -79,7 +79,7 @@ SPARCDIR = "boot"
|
||||
class PPC(object):
|
||||
|
||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||
treeinfo, basearch):
|
||||
treeinfo, basearch, ctype, cspeed):
|
||||
|
||||
self.kernellist = kernellist
|
||||
self.installtree = installtree
|
||||
@ -88,6 +88,8 @@ class PPC(object):
|
||||
self.version = version
|
||||
self.treeinfo = treeinfo
|
||||
self.basearch = basearch
|
||||
self.ctype = ctype
|
||||
self.cspeed = cspeed
|
||||
self.kernels, self.initrds = [], []
|
||||
|
||||
self.reqs = collections.defaultdict(str)
|
||||
@ -176,7 +178,7 @@ class PPC(object):
|
||||
initrd.itype = kernel.ktype
|
||||
|
||||
logger.info("compressing the install tree")
|
||||
self.installtree.compress(initrd, kernel, type="gzip")
|
||||
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
|
||||
|
||||
# add kernel and initrd to the list
|
||||
self.kernels.append(kernel)
|
||||
@ -359,7 +361,7 @@ class PPC(object):
|
||||
class X86(object):
|
||||
|
||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||
treeinfo, basearch):
|
||||
treeinfo, basearch, ctype, cspeed):
|
||||
|
||||
self.kernellist = kernellist
|
||||
self.installtree = installtree
|
||||
@ -368,6 +370,8 @@ class X86(object):
|
||||
self.version = version
|
||||
self.treeinfo = treeinfo
|
||||
self.basearch = basearch
|
||||
self.ctype = ctype
|
||||
self.cspeed = cspeed
|
||||
self.kernels, self.initrds = [], []
|
||||
|
||||
self.reqs = collections.defaultdict(str)
|
||||
@ -508,7 +512,7 @@ class X86(object):
|
||||
initrd.itype = kernel.ktype
|
||||
|
||||
logger.info("compressing the install tree")
|
||||
self.installtree.compress(initrd, kernel)
|
||||
self.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
|
||||
|
||||
# add kernel and initrd to the list
|
||||
self.kernels.append(kernel)
|
||||
@ -582,7 +586,7 @@ class X86(object):
|
||||
class S390(object):
|
||||
|
||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||
treeinfo, basearch):
|
||||
treeinfo, basearch, ctype, cspeed):
|
||||
|
||||
self.kernellist = kernellist
|
||||
self.installtree = installtree
|
||||
@ -591,6 +595,8 @@ class S390(object):
|
||||
self.version = version
|
||||
self.treeinfo = treeinfo
|
||||
self.basearch = basearch
|
||||
self.ctype = ctype
|
||||
self.cspeed = cspeed
|
||||
self.kernels, self.initrds = [], []
|
||||
|
||||
self.reqs = collections.defaultdict(str)
|
||||
@ -630,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.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
|
||||
|
||||
# run addrsize
|
||||
addrsize = joinpaths(self.installtree.root, "usr/libexec",
|
||||
@ -679,7 +685,7 @@ class S390(object):
|
||||
class SPARC(object):
|
||||
|
||||
def __init__(self, kernellist, installtree, outputroot, product, version,
|
||||
treeinfo, basearch):
|
||||
treeinfo, basearch, ctype, cspeed):
|
||||
|
||||
self.kernellist = kernellist
|
||||
self.installtree = installtree
|
||||
@ -688,6 +694,8 @@ class SPARC(object):
|
||||
self.version = version
|
||||
self.treeinfo = treeinfo
|
||||
self.basearch = basearch
|
||||
self.ctype = ctype
|
||||
self.cspeed = cspeed
|
||||
self.kernels, self.initrds = [], []
|
||||
|
||||
self.reqs = collections.defaultdict(str)
|
||||
@ -736,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.installtree.compress(initrd, kernel, self.ctype, self.cspeed)
|
||||
|
||||
# add kernel and initrd to .treeinfo
|
||||
kernel_arch = kernel.version.split(".")[-1]
|
||||
|
@ -504,7 +504,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
dst = joinpaths(self.root, "sbin")
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
def compress(self, initrd, kernel, type="xz"):
|
||||
def compress(self, initrd, kernel, type="xz", speed="9"):
|
||||
chdir = lambda: os.chdir(self.root)
|
||||
start = time.time()
|
||||
|
||||
@ -521,12 +521,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
stdin=find.stdout, stdout=subprocess.PIPE,
|
||||
preexec_fn=chdir)
|
||||
|
||||
if type == "gzip":
|
||||
cmd = [self.lcmds.GZIP, "-9"]
|
||||
elif type == "xz":
|
||||
cmd = [self.lcmds.XZ, "-9"]
|
||||
|
||||
compressed = subprocess.Popen(cmd, stdin=cpio.stdout,
|
||||
compressed = subprocess.Popen([type, "-%s" % speed], stdin=cpio.stdout,
|
||||
stdout=open(initrd.fpath, "wb"))
|
||||
|
||||
logger.debug("compressing")
|
||||
|
Loading…
Reference in New Issue
Block a user