Create dracut initramfs for each kernel (#722466)
This commit is contained in:
parent
23f9879b0e
commit
d9e9b0e57c
@ -305,7 +305,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
logger.info("compressing modules")
|
logger.info("compressing modules")
|
||||||
self.installtree.compress_modules(kernel)
|
self.installtree.compress_modules(kernel)
|
||||||
|
|
||||||
logger.info("running depmod")
|
logger.info("running depmod for kernel %s" % kernel.version)
|
||||||
self.installtree.run_depmod(kernel)
|
self.installtree.run_depmod(kernel)
|
||||||
|
|
||||||
# move repos
|
# move repos
|
||||||
|
@ -46,7 +46,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
self.libdir = libdir
|
self.libdir = libdir
|
||||||
self.workdir = workdir
|
self.workdir = workdir
|
||||||
self.initramfs = None
|
self.initramfs = {}
|
||||||
|
|
||||||
self.lcmds = constants.LoraxRequiredCommands()
|
self.lcmds = constants.LoraxRequiredCommands()
|
||||||
|
|
||||||
@ -548,15 +548,19 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
rc = compressed.wait()
|
rc = compressed.wait()
|
||||||
|
|
||||||
def make_dracut_initramfs(self):
|
def make_dracut_initramfs(self):
|
||||||
outfile = "/tmp/initramfs.img" # inside the chroot
|
for kernel in self.kernels:
|
||||||
logger.debug("chrooting into installtree to create initramfs.img")
|
outfile = "/tmp/initramfs.img" # inside the chroot
|
||||||
subprocess.check_call(["chroot", self.root,
|
logger.debug("chrooting into installtree to create initramfs.img")
|
||||||
"/sbin/dracut", "--nomdadmconf", "--nolvmconf",
|
subprocess.check_call(["chroot", self.root, "/sbin/dracut",
|
||||||
"--xz", "--modules", "base dmsquash-live",
|
"--nomdadmconf", "--nolvmconf",
|
||||||
outfile, self.kernels[0].version])
|
"--xz", "--modules", "base dmsquash-live",
|
||||||
# move output file into installtree workdir
|
outfile, kernel.version])
|
||||||
self.initramfs = joinpaths(self.workdir, "initramfs.img")
|
# move output file into installtree workdir
|
||||||
shutil.move(joinpaths(self.root, outfile), self.initramfs)
|
dstdir = joinpaths(self.workdir, kernel.version)
|
||||||
|
os.makedirs(dstdir)
|
||||||
|
self.initramfs[kernel.version] = joinpaths(dstdir, "initramfs.img")
|
||||||
|
shutil.move(joinpaths(self.root, outfile),
|
||||||
|
self.initramfs[kernel.version])
|
||||||
|
|
||||||
def make_squashfs_runtime(self, runtime, kernel, type, args):
|
def make_squashfs_runtime(self, runtime, kernel, type, args):
|
||||||
"""This is a little complicated, but dracut wants to find a squashfs
|
"""This is a little complicated, but dracut wants to find a squashfs
|
||||||
@ -567,7 +571,8 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
initramfs at boot time.
|
initramfs at boot time.
|
||||||
"""
|
"""
|
||||||
# Check to be sure we have a dracut initramfs to use
|
# Check to be sure we have a dracut initramfs to use
|
||||||
assert self.initramfs, "make_dracut_initramfs has not been run!"
|
assert self.initramfs.get(kernel.version), \
|
||||||
|
"no dracut initramfs for kernel %s" % kernel.version
|
||||||
|
|
||||||
# These exact names are required by dracut
|
# These exact names are required by dracut
|
||||||
squashname = "squashfs.img"
|
squashname = "squashfs.img"
|
||||||
@ -630,15 +635,16 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
|
|
||||||
# create final image
|
# create final image
|
||||||
logger.debug("concatenating dracut initramfs and squashfs initramfs")
|
logger.debug("concatenating dracut initramfs and squashfs initramfs")
|
||||||
logger.debug("initramfs.img size = %i", os.stat(self.initramfs).st_size)
|
logger.debug("initramfs.img size = %i",
|
||||||
|
os.stat(self.initramfs[kernel.version]).st_size)
|
||||||
with open(runtime.fpath, "wb") as output:
|
with open(runtime.fpath, "wb") as output:
|
||||||
for f in self.initramfs, squash_cpio:
|
for f in self.initramfs[kernel.version], squash_cpio:
|
||||||
with open(f, "rb") as fobj:
|
with open(f, "rb") as fobj:
|
||||||
data = fobj.read(4096)
|
data = fobj.read(4096)
|
||||||
while data:
|
while data:
|
||||||
output.write(data)
|
output.write(data)
|
||||||
data = fobj.read(4096)
|
data = fobj.read(4096)
|
||||||
os.remove(self.initramfs)
|
os.remove(self.initramfs[kernel.version])
|
||||||
os.remove(squash_cpio)
|
os.remove(squash_cpio)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user