[lorax 2/2] Allow compression type be specified in lorax.conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/pylorax/__init__.py    |   18 ++++++++++++++++--
 src/pylorax/constants.py   |    2 --
 src/pylorax/images.py      |   24 ++++++++++++++++--------
 src/pylorax/installtree.py |    9 ++-------
 4 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index e26c639..040c28f 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -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("compresssion", "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)
diff --git a/src/pylorax/constants.py b/src/pylorax/constants.py
index eb3da2f..c37f0db 100644
--- a/src/pylorax/constants.py
+++ b/src/pylorax/constants.py
@@ -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]
diff --git a/src/pylorax/images.py b/src/pylorax/images.py
index 65cf1a6..ece8b00 100644
--- a/src/pylorax/images.py
+++ b/src/pylorax/images.py
@@ -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]
diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index a24f450..18b2937 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -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, "-%d" % speed], stdin=cpio.stdout,
                                       stdout=open(initrd.fpath, "wb"))
 
         logger.debug("compressing")
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux