Blob Blame History Raw
From e19e664d4fcb1637f8ba4a4a088454acf2f94334 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 12 Sep 2013 20:41:33 +0200
Subject: [PATCH 02/41] If we're using multiboot, add a new mbmodule not an
 initramfs

I really don't know how this ever worked.
Related: rhbz#957681

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 grubby.c       | 47 +++++++++++++++++++++++++++++++++++++++++++++--
 new-kernel-pkg |  3 ++-
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/grubby.c b/grubby.c
index bbca9d0..d91a847 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3255,6 +3255,42 @@ int updateImage(struct grubConfig * cfg, const char * image,
     return rc;
 }
 
+int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
+		 const char * image, const char * prefix, const char * initrd) {
+    struct singleEntry * entry;
+    struct singleLine * line, * kernelLine, *endLine = NULL;
+    int index = 0;
+
+    if (!image) return 0;
+
+    for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) {
+        kernelLine = getLineByType(LT_MBMODULE, entry->lines);
+        if (!kernelLine) continue;
+
+        if (prefix) {
+            int prefixLen = strlen(prefix);
+            if (!strncmp(initrd, prefix, prefixLen))
+                initrd += prefixLen;
+        }
+	endLine = getLineByType(LT_ENTRY_END, entry->lines);
+	if (endLine)
+	    removeLine(entry, endLine);
+        line = addLine(entry, cfg->cfi, preferredLineType(LT_MBMODULE,cfg->cfi),
+			kernelLine->indent, initrd);
+        if (!line)
+	    return 1;
+	if (endLine) {
+	    line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL);
+            if (!line)
+		return 1;
+	}
+
+        break;
+    }
+
+    return 0;
+}
+
 int updateInitrd(struct grubConfig * cfg, const char * image,
                  const char * prefix, const char * initrd) {
     struct singleEntry * entry;
@@ -4496,8 +4532,15 @@ int main(int argc, const char ** argv) {
     if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,
                     removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;
     if (updateKernelPath && newKernelInitrd) {
-            if (updateInitrd(config, updateKernelPath, bootPrefix,
-                             newKernelInitrd)) return 1;
+	    if (newMBKernel) {
+		    if (addMBInitrd(config, newMBKernel, updateKernelPath,
+					bootPrefix, newKernelInitrd))
+			    return 1;
+	    } else {
+		    if (updateInitrd(config, updateKernelPath, bootPrefix,
+					newKernelInitrd))
+			return 1;
+	    }
     }
     if (addNewKernel(config, template, bootPrefix, newKernelPath, 
                      newKernelTitle, newKernelArgs, newKernelInitrd, 
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 7fec1fe..6373385 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -404,7 +404,8 @@ update() {
 	    --update-kernel=$kernelImage \
 	    $INITRD \
 	    ${kernargs:+--args="$kernargs"} \
-	    ${removeargs:+--remove-args="$removeargs"}
+	    ${removeargs:+--remove-args="$removeargs"} \
+	    ${mbkernel:+--add-multiboot="$mbkernel"}
     else
 	[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
     fi
-- 
2.4.3