[arch-releng] [PATCH] Moved kernel parameter generation into get_kernel_parameters

pyther at pyther.net pyther at pyther.net
Wed Jan 26 12:42:05 EST 2011


The function now stores parameters into var kernel_parameters. The
new function does not set the kernel name (vmlinuz). This must now be
done in the bootloader configuration code.
---
 src/core/libs/lib-ui-interactive.sh |  134 +++++++++++++++++++----------------
 1 files changed, 74 insertions(+), 60 deletions(-)

diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 829556a..0449d99 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -1048,76 +1048,27 @@ generate_grub_menulst() {
     # keep the file from being completely bogus
 	[ "$grubdev" = "DEVICE NOT FOUND" ] && grubdev=
 	if [ -z "$grubdev" ]; then
-                notify "Your root boot device could not be autodetected by setup.  Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly."
-                grubdev="(hd0,0)"
-            fi
-            # remove default entries by truncating file at our little tag (#-*)
-            sed -i -e '/#-\*/q' $grubmenu
-
-	# find label or uuid of the root partition
-	case $PART_ACCESS in
-		label)
-			local _label="$(getlabel $_rootpart)"
-			if [ -n "${_label}" ]; then
-			    _rootpart="/dev/disk/by-label/${_label}"
-			fi
-			;;
-		uuid)
-			local _uuid="$(getuuid $_rootpart)"
-			if [ -n "${_uuid}" ]; then
-			    _rootpart="/dev/disk/by-uuid/${_uuid}"
-			fi
-			;;
-	esac
+        notify "Your root boot device could not be autodetected by setup.  Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly."
+        grubdev="(hd0,0)"
+    fi
 
-		# handle dmraid/mdadm,lvm,dm_crypt etc. replace entries where needed automatically
-		kernel="kernel $subdir/vmlinuz26 root=${_rootpart} ro"
-		if get_anchestors_mount ';/;'
-		then
-			if echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '2p' | grep -q 'raw$'
-			then
-				debug 'FS' 'Grub kernel line? Found / on dm_crypt on raw'
-				raw_device=`echo "$ANSWER_DEVICES" | sed -n '2p' | cut -d ' ' -f1`
-				crypt_device=`echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1`
-				kernel="kernel $subdir/vmlinuz26 root=$crypt_device cryptdevice=$raw_device:`basename $crypt_device` ro"
-			elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '4p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '5p' | grep -q 'raw$'
-			then
-				debug 'FS' 'Grub kernel line? Found / on lvm on dm_crypt on raw'
-				lv_device=`echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1`
-				crypt_device=`echo "$ANSWER_DEVICES" | sed -n '4p' | cut -d ' ' -f1`
-				raw_device=`echo "$ANSWER_DEVICES" | sed -n '5p' | cut -d ' ' -f1`
-				kernel="kernel $subdir/vmlinuz26 root=$lv_device cryptdevice=$raw_device:`basename $crypt_device` ro"
-			elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '2p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '5p' | grep -q 'raw$'
-			then
-				debug 'FS' 'Grub kernel line? Found / on dm_crypt on lvm on raw'
-				crypt_device=`echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1`
-				lv_device=`echo "$ANSWER_DEVICES" | sed -n '2p' | cut -d ' ' -f1`
-				kernel="kernel $subdir/vmlinuz26 root=$crypt_device cryptdevice=$lv_device:`basename $crypt_device` ro"
-			elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'raw$'
-			then
-				debug 'FS' 'Grub kernel line? Found / on raw'
-			elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '4p' | grep -q 'raw$'
-			then
-				debug 'FS' 'Grub kernel line? Found / on lvm on raw'
-			else
-				debug 'FS' 'Grub kernel line? Could not figure this one out'
-				show_warning "Disk setup detection" "Are you using some really fancy dm_crypt/lvm/softraid setup?\nI could not figure it out, so the kernel line will be the default: you'll probably need to edit it.\nPlease file a bug for this and supply all files from /tmp/aif/"
-			fi
-		else
-			show_warning "Disk setup detection" "Could not find out where your / is.  Did you setup filesystems/blockdevices? manual/autoprepare?  If yes, please file a bug and tell us about this"
-		fi
-            cat >>$grubmenu <<EOF
+    # remove default entries by truncating file at our little tag (#-*)
+    sed -i -e '/#-\*/q' $grubmenu
+
+    get_kernel_parameters
+
+    cat >>$grubmenu <<EOF
 
 # (0) Arch Linux
 title  Arch Linux
 root   $grubdev
-$kernel
+kernel $subdir/vmlinuz26 $kernel_parameters
 initrd $subdir/kernel26.img
 
 # (1) Arch Linux
 title  Arch Linux Fallback
 root   $grubdev
-$kernel
+kernel $subdir/vmlinuz26 $kernel_parameters
 initrd $subdir/kernel26-fallback.img
 
 # (2) Windows
@@ -1179,6 +1130,69 @@ EOF
     fi
 }
 
+get_kernel_parameters()
+{
+    get_device_with_mount '/' || return 1
+    local _rootpart="$ANSWER_DEVICE"
+
+    case "$PART_ACCESS" in
+        label)
+            local _label="$(getlabel $_rootpart)"
+            if [[ -n "${_label}" ]]; then
+                _rootpart="/dev/disk/by-label/${_label}"
+            fi
+        ;;
+        uuid)
+            local _uuid="$(getuuid $_rootpart)"
+            if [[ -n "${_uuid}" ]]; then
+                _rootpart="/dev/disk/by-uuid/${_uuid}"
+            fi
+        ;;
+    esac
+
+    kernel_parameters="root=$_rootpart ro"
+
+    # No seperate /boot partition
+    if [[ -z "$bootdev" ]]; then
+        subdir='/boot'
+    fi
+
+    if get_anchestors_mount ';/;'
+    then
+        if echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '2p' | grep -q 'raw$'
+        then
+            debun 'FS' 'get_kernel_options - Found / on dm_crypt on raw'
+            raw_device="$(echo "$ANSWER_DEVICES" | sed -n '2p' | cut -d ' ' -f1)"
+            crypt_device="$(echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1)"
+            kernel_parameters="root=$crypt_device cryptdevice=$raw_device:`basename $crypt_device` ro"
+        elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '4p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '5p' | grep -q 'raw$'
+        then
+            debug 'FS' 'get_kernel_options - Found / on lvm on dm_crypt on raw'
+            lv_device="$(echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1)"
+            crypt_device="$(echo "$ANSWER_DEVICES" | sed -n '4p' | cut -d ' ' -f1)"
+            raw_device="$(echo "$ANSWER_DEVICES" | sed -n '5p' | cut -d ' ' -f1)"
+            kernel_parameters="root=$lv_device cryptdevice=$raw_device:`basename $crypt_device` ro"
+        elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWER_DEVICES" | sed -n '2p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '5p' | grep -q 'raw$'
+        then
+            debug 'FS' 'get_kernel_options - Found / on dm_crypt on lvm on raw'
+            crypt_device="$(echo "$ANSWER_DEVICES" | sed -n '1p' | cut -d ' ' -f1)"
+            lv_device="$(echo "$ANSWER_DEVICES" | sed -n '2p' | cut -d ' ' -f1)"
+            kernel_parameters="root=$crypt_device cryptdevice=$lv_device:`basename $crypt_device` ro"
+        elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'raw$'
+        then
+            debug 'FS' 'get_kernel_parameters - Found / on raw'
+        elif echo "$ANSWER_DEVICES" | sed -n '1p' | grep -q 'lvm-lv$' && echo "$ANSWER_DEVICES" | sed -n '4p' | grep -q 'raw$'
+        then
+            debug 'FS' 'get_kernel_parameters - Found / on lvm on raw'
+        else
+            debug 'FS' 'get_kernel_parameters - Could not figure this one out'
+            show_warning "Disk setup detection" "Are you using some really fancy dm_crypt/lvm/softraid setup?\nI could not figure it out, so the kernel line will be the default: you'll probably need to edit it.\nPlease file a bug for this and supply all files from /tmp/aif/"
+        fi
+    else
+	show_warning "Disk setup detection" "Could not find out where your / is.  Did you setup filesystems/blockdevices? manual/autoprepare?  If yes, please file a bug and tell us about this"
+    fi
+}
+
 
 # displays installation source selection menu
 # and sets up relevant config files
-- 
1.7.3.5



More information about the arch-releng mailing list