[Lunar-commits] <moonbase-core> Merge pull request #307 from cavalier38/bootloader-plugin

Auke Kok sofar+github at foo-projects.org
Sat May 4 09:00:20 CEST 2013


commit 4a9d79eed7709226a4267a272163fec8c8b1cbb2
Author: Auke Kok <sofar+github at foo-projects.org>
Date: Sat, 04 May 2013 00:00:14 -0700
URL: https://github.com/lunar-linux/moonbase-core/commit/4a9d79eed7709226a4267a272163fec8c8b1cbb2

Merge pull request #307 from cavalier38/bootloader-plugin

Bootloader plugin
---
  kernel/dracut/plugin.d/bootloader-dracut.plugin | +2/-2     
  system/grub/plugin.d/bootloader-grub.plugin     | +6/-2     
  system/grub2/plugin.d/bootloader-grub2.plugin   | +28/-0    
  system/lilo/plugin.d/bootloader-lilo.plugin     | +16/-2    
  4 files changed, 52 insertions(+), 6 deletions(-)

--- a/kernel/dracut/plugin.d/bootloader-dracut.plugin
+++ b/kernel/dracut/plugin.d/bootloader-dracut.plugin
@@ -16,7 +16,7 @@ plugin_kernel_updatebootloader_dracut()
 
   debug_msg "plugin_kernel_updatebootloader_dracut ($@)"
 
-  KVERSION=`echo $1 | cut -d- -f1`
+  KVERSION="$1-$(arch)"
 
   # create an old copy of the previous initramfs
   if [ -f "/boot/initramfs-$KVERSION.img" ]; then
@@ -24,7 +24,7 @@ plugin_kernel_updatebootloader_dracut()
   fi
 
   # we can force dracut as we copied the old initramfs
-  dracut -f "/boot/initramfs-$KVERSION.img" "$KVERSION"
+  dracut -f "/boot/initramfs-$KVERSION.img" "$1"
 
   # right now we want to have it run all bootloaders?
   return 2
--- a/system/grub/plugin.d/bootloader-grub.plugin
+++ b/system/grub/plugin.d/bootloader-grub.plugin
@@ -94,6 +94,10 @@ plugin_kernel_updatebootloader_grub()
     debug_msg "kernel  $GRUB_BOOT/$1 $CMDLINE"
     echo   "title   $2"
     echo   "kernel  $GRUB_BOOT/$1 $CMDLINE"
+    if [ -f "$GRUB_BOOT/$3" ] ; then
+      debug_msg "initrd  $GRUB_BOOT/$3"
+      echo "initrd  $GRUB_BOOT/$3"
+    fi
     echo   ""
   }
 
@@ -107,10 +111,10 @@ plugin_kernel_updatebootloader_grub()
   {
     local ARCH=$(arch)
     if ! has_grub_title "$2" /boot/grub/menu.lst ; then
-      print_grub_image "vmlinuz-$1-$ARCH" "$2" >> /boot/grub/menu.lst.new
+      print_grub_image "vmlinuz-$1-$ARCH" "$2" "initramfs-$1-$ARCH.img" >> /boot/grub/menu.lst.new
     fi
     if [ -f /boot/vmlinuz-$1-$ARCH.old ] && ! has_grub_title "$2.old" /boot/grub/menu.lst ; then
-      print_grub_image "vmlinuz-$1-$ARCH.old" "$2.old" >> /boot/grub/menu.lst.new
+      print_grub_image "vmlinuz-$1-$ARCH.old" "$2.old" "initramfs-$1-$ARCH.old.img" >> /boot/grub/menu.lst.new
     fi
   }
 
--- /dev/null
+++ b/system/grub2/plugin.d/bootloader-grub2.plugin
@@ -0,0 +1,28 @@
+#!/bin/bash
+#############################################################
+#                                                           #
+# bootloader-grub2.plugin - plugin that generate grub.cfg   #
+#                                                           #
+#############################################################
+#                                                           #
+# Copyright 2013 by Peter de Ridder under GPLv2             #
+#                                                           #
+#############################################################
+
+
+plugin_kernel_updatebootloader_grub2()
+{
+  # preferred? - master switch for experienced users
+  if [ -n "$BOOTLOADER" -a "$BOOTLOADER" != "grub2" ]; then
+    return 2
+  fi
+  debug_msg "plugin_kernel_updatebootloader_grub2 ($@)"
+
+  grub-mkconfig -o /boot/grub/grub.cfg
+
+  # right now we want to have it run all bootloaders?
+  return 2
+}
+
+
+plugin_register KERNEL_UPDATEBOOTLOADER plugin_kernel_updatebootloader_grub2
--- a/system/lilo/plugin.d/bootloader-lilo.plugin
+++ b/system/lilo/plugin.d/bootloader-lilo.plugin
@@ -40,6 +40,11 @@ plugin_kernel_updatebootloader_lilo() {
           # rename the image too since the module moved it to .old
           IMAGE="image = /boot/vmlinuz-$1-$ARCH.old"
         fi
+        SINITRD=$(echo $INITRD | tr -d '[:blank:]' | sed 's/initrd=//')
+        if [ "$SIMAGE" == "/boot/initramfs-$1-$ARCH" ]; then
+          # rename the image too since the module moved it to .old
+          INITRD="   initrd = /boot/initramfs-$1-$ARCH.old.img"
+        fi
       elif [ "$SLABEL" == "$2.old" ]; then
         # delete this one!
         return
@@ -47,6 +52,9 @@ plugin_kernel_updatebootloader_lilo() {
       echo "$IMAGE"
     fi
     echo "$LABEL"
+    if [ -n "$INITRD" ] ; then
+      echo "$INITRD"
+    fi
     for OPTIONS in "${OPTIONS[@]}" ; do
       echo "$OPTIONS"
     done
@@ -63,12 +71,15 @@ plugin_kernel_updatebootloader_lilo() {
     # we didn't have this label yet - insert it rightaway
     echo "image = /boot/vmlinuz-$1-$ARCH"
     echo "    label = $2"
+    if [ -f "/boot/initramfs-$1-$ARCH.img" ] ; then
+      echo "    initrd = /boot/initramfs-$1-$ARCH.img"
+    fi
     if [ -z "$READONLY" ]; then
       echo "    read-only"
     fi
 
     (( IMAGE_COUNT=0 ))
-    unset IMAGE OTHER LABEL OPTIONS
+    unset IMAGE OTHER LABEL OPTIONS INITRD
     # list old images
     while read LINE ; do
       if echo $LINE | grep -qw "image\|other" ; then
@@ -81,7 +92,7 @@ plugin_kernel_updatebootloader_lilo() {
 
         # output and reset
         output_image $1 $2
-        unset IMAGE OTHER LABEL OPTIONS
+        unset IMAGE OTHER LABEL OPTIONS INITRD
       fi
 
       # store the lines
@@ -95,6 +106,9 @@ plugin_kernel_updatebootloader_lilo() {
         label=*)
           LABEL="$LINE"
           ;;
+        initrd=*)
+          INITRD="$LINE"
+          ;;
         *)
           OPTIONS=( "${OPTIONS[@]}" "$LINE" )
           ;;




More information about the Lunar-commits mailing list