Permalink
Browse files

Merge pull request #307 from cavalier38/bootloader-plugin

Bootloader plugin
  • Loading branch information...
2 parents 6a58ab4 + 8b73ff3 commit 4a9d79eed7709226a4267a272163fec8c8b1cbb2 @sofar sofar committed May 4, 2013
@@ -16,15 +16,15 @@ 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
cp -p "/boot/initramfs-$KVERSION.img" "/boot/initramfs-$KVERSION.old.img"
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
@@ -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
}
@@ -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
@@ -40,13 +40,21 @@ 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
fi
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" )
;;

0 comments on commit 4a9d79e

Please sign in to comment.