Use xz and gzip commands instead of libraries
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.
This commit is contained in:
parent
97d7db6780
commit
79b6e5bfa1
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user