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

[PATCH 1/4] 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
---
 src/pylorax/__init__.py    |    6 +++---
 src/pylorax/images.py      |   24 ++++++++++++------------
 src/pylorax/installtree.py |    4 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index 5eded80..d5da429 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -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)
diff --git a/src/pylorax/images.py b/src/pylorax/images.py
index 8cade6a..7aae553 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, 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]
diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index 13ae6f1..8501954 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", 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")
 
-- 
1.7.5.2


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