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

[lorax] Create dracut initramfs for each kernel (#722466)



---
 src/pylorax/__init__.py    |    2 +-
 src/pylorax/installtree.py |   34 ++++++++++++++++++++--------------
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index 90ed763..5c89177 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -305,7 +305,7 @@ class Lorax(BaseLoraxClass):
             logger.info("compressing modules")
             self.installtree.compress_modules(kernel)
 
-            logger.info("running depmod")
+            logger.info("running depmod for kernel %s" % kernel.version)
             self.installtree.run_depmod(kernel)
 
         # move repos
diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index 0e49213..a004e73 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -46,7 +46,7 @@ class LoraxInstallTree(BaseLoraxClass):
         self.basearch = basearch
         self.libdir = libdir
         self.workdir = workdir
-        self.initramfs = None
+        self.initramfs = {}
 
         self.lcmds = constants.LoraxRequiredCommands()
 
@@ -548,15 +548,19 @@ class LoraxInstallTree(BaseLoraxClass):
         rc = compressed.wait()
 
     def make_dracut_initramfs(self):
-        outfile = "/tmp/initramfs.img" # inside the chroot
-        logger.debug("chrooting into installtree to create initramfs.img")
-        subprocess.check_call(["chroot", self.root,
-                               "/sbin/dracut", "--nomdadmconf", "--nolvmconf",
-                               "--xz", "--modules", "base dmsquash-live",
-                               outfile, self.kernels[0].version])
-        # move output file into installtree workdir
-        self.initramfs = joinpaths(self.workdir, "initramfs.img")
-        shutil.move(joinpaths(self.root, outfile), self.initramfs)
+        for kernel in self.kernels:
+            outfile = "/tmp/initramfs.img" # inside the chroot
+            logger.debug("chrooting into installtree to create initramfs.img")
+            subprocess.check_call(["chroot", self.root, "/sbin/dracut",
+                                   "--nomdadmconf", "--nolvmconf",
+                                   "--xz", "--modules", "base dmsquash-live",
+                                   outfile, kernel.version])
+            # move output file into installtree workdir
+            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):
         """This is a little complicated, but dracut wants to find a squashfs
@@ -567,7 +571,8 @@ class LoraxInstallTree(BaseLoraxClass):
         initramfs at boot time.
         """
         # 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
         squashname = "squashfs.img"
@@ -630,15 +635,16 @@ class LoraxInstallTree(BaseLoraxClass):
 
         # create final image
         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:
-            for f in self.initramfs, squash_cpio:
+            for f in self.initramfs[kernel.version], squash_cpio:
                 with open(f, "rb") as fobj:
                     data = fobj.read(4096)
                     while data:
                         output.write(data)
                         data = fobj.read(4096)
-        os.remove(self.initramfs)
+        os.remove(self.initramfs[kernel.version])
         os.remove(squash_cpio)
 
     @property
-- 
1.7.3.2


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