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: dosfstools
|
||||||
Requires: genisoimage
|
Requires: genisoimage
|
||||||
Requires: parted
|
Requires: parted
|
||||||
Requires: pyliblzma
|
Requires: gzip
|
||||||
|
Requires: xz
|
||||||
|
|
||||||
%ifarch %{ix86} x86_64
|
%ifarch %{ix86} x86_64
|
||||||
Requires: syslinux
|
Requires: syslinux
|
||||||
|
@ -41,6 +41,7 @@ class LoraxRequiredCommands(dict):
|
|||||||
self["DMSETUP"] = "dmsetup"
|
self["DMSETUP"] = "dmsetup"
|
||||||
self["FIND"] = "find"
|
self["FIND"] = "find"
|
||||||
self["GCONFTOOL"] = "gconftool-2"
|
self["GCONFTOOL"] = "gconftool-2"
|
||||||
|
self["GZIP"] = "gzip"
|
||||||
self["IMPLANTISOMD5"] = "implantisomd5"
|
self["IMPLANTISOMD5"] = "implantisomd5"
|
||||||
self["ISOHYBRID"] = "isohybrid"
|
self["ISOHYBRID"] = "isohybrid"
|
||||||
self["LDCONFIG"] = "ldconfig"
|
self["LDCONFIG"] = "ldconfig"
|
||||||
@ -53,6 +54,7 @@ class LoraxRequiredCommands(dict):
|
|||||||
self["PARTED"] = "parted"
|
self["PARTED"] = "parted"
|
||||||
self["SSHKEYGEN"] = "ssh-keygen"
|
self["SSHKEYGEN"] = "ssh-keygen"
|
||||||
self["UMOUNT"] = "umount"
|
self["UMOUNT"] = "umount"
|
||||||
|
self["XZ"] = "xz"
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return self[attr]
|
return self[attr]
|
||||||
|
@ -26,7 +26,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import gzip
|
import gzip
|
||||||
import lzma
|
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
@ -510,26 +509,31 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# move corresponding modules to the tree
|
# move corresponding modules to the tree
|
||||||
|
logger.debug("moving modules inside initrd")
|
||||||
shutil.move(joinpaths(self.workdir, kernel.version),
|
shutil.move(joinpaths(self.workdir, kernel.version),
|
||||||
joinpaths(self.root, "modules"))
|
joinpaths(self.root, "modules"))
|
||||||
|
|
||||||
find = subprocess.Popen([self.lcmds.FIND, "."], stdout=subprocess.PIPE,
|
find = subprocess.Popen([self.lcmds.FIND, "."], stdout=subprocess.PIPE,
|
||||||
preexec_fn=chdir)
|
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,
|
stdin=find.stdout, stdout=subprocess.PIPE,
|
||||||
preexec_fn=chdir)
|
preexec_fn=chdir)
|
||||||
|
|
||||||
if type == "gzip":
|
if type == "gzip":
|
||||||
compressed = gzip.open(initrd.fpath, "wb")
|
cmd = [self.lcmds.GZIP, "-9"]
|
||||||
elif type == "xz":
|
elif type == "xz":
|
||||||
compressed = lzma.LZMAFile(initrd.fpath, "w",
|
cmd = [self.lcmds.XZ, "-9"]
|
||||||
options={"format":"xz", "level":9})
|
|
||||||
|
|
||||||
compressed.write(cpio.stdout.read())
|
compressed = subprocess.Popen(cmd, stdin=cpio.stdout,
|
||||||
compressed.close()
|
stdout=open(initrd.fpath, "wb"))
|
||||||
|
|
||||||
|
logger.debug("compressing")
|
||||||
|
rc = compressed.wait()
|
||||||
|
|
||||||
# move modules out of the tree again
|
# move modules out of the tree again
|
||||||
|
logger.debug("moving modules outside initrd")
|
||||||
shutil.move(joinpaths(self.root, "modules", kernel.version),
|
shutil.move(joinpaths(self.root, "modules", kernel.version),
|
||||||
self.workdir)
|
self.workdir)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user