[lorax 1/2] Use xz and gzip commands instead of libraries

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

 



We're already using find and cpio subprocesses, so using
one more subprocess is not a problem. With this approach
we can pipe cpio to the xz/gzip command, which should
help with the memory issues.
---
 lorax.spec                 |    3 ++-
 src/pylorax/constants.py   |    2 ++
 src/pylorax/installtree.py |   18 +++++++++++-------
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lorax.spec b/lorax.spec
index 9113ccd..8a0094b 100644
--- a/lorax.spec
+++ b/lorax.spec
@@ -23,7 +23,8 @@ Requires:       util-linux-ng
 Requires:       dosfstools
 Requires:       genisoimage
 Requires:       parted
-Requires:       pyliblzma
+Requires:       gzip
+Requires:       xz
 
 %ifarch %{ix86} x86_64
 Requires:       syslinux
diff --git a/src/pylorax/constants.py b/src/pylorax/constants.py
index c37f0db..eb3da2f 100644
--- a/src/pylorax/constants.py
+++ b/src/pylorax/constants.py
@@ -41,6 +41,7 @@ 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"
@@ -53,6 +54,7 @@ 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/installtree.py b/src/pylorax/installtree.py
index eda12c7..a24f450 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -26,7 +26,6 @@ import sys
 import os
 import shutil
 import gzip
-import lzma
 import re
 import glob
 import time
@@ -510,26 +509,31 @@ class LoraxInstallTree(BaseLoraxClass):
         start = time.time()
 
         # move corresponding modules to the tree
+        logger.debug("moving modules inside initrd")
         shutil.move(joinpaths(self.workdir, kernel.version),
                     joinpaths(self.root, "modules"))
 
         find = subprocess.Popen([self.lcmds.FIND, "."], stdout=subprocess.PIPE,
                                 preexec_fn=chdir)
 
-        cpio = subprocess.Popen([self.lcmds.CPIO, "--quiet", "-H", "newc", "-o"],
+        cpio = subprocess.Popen([self.lcmds.CPIO,
+                                 "--quiet", "-H", "newc", "-o"],
                                 stdin=find.stdout, stdout=subprocess.PIPE,
                                 preexec_fn=chdir)
 
         if type == "gzip":
-            compressed = gzip.open(initrd.fpath, "wb")
+            cmd = [self.lcmds.GZIP, "-9"]
         elif type == "xz":
-            compressed = lzma.LZMAFile(initrd.fpath, "w",
-                    options={"format":"xz", "level":9})
+            cmd = [self.lcmds.XZ, "-9"]
 
-        compressed.write(cpio.stdout.read())
-        compressed.close()
+        compressed = subprocess.Popen(cmd, stdin=cpio.stdout,
+                                      stdout=open(initrd.fpath, "wb"))
+
+        logger.debug("compressing")
+        rc = compressed.wait()
 
         # move modules out of the tree again
+        logger.debug("moving modules outside initrd")
         shutil.move(joinpaths(self.root, "modules", kernel.version),
                     self.workdir)
 
-- 
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