All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: Support Linux command line variants in grub-mkconfig
@ 2010-01-18 21:03 Martin Orr
  2010-01-19 22:26 ` Robert Millan
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Orr @ 2010-01-18 21:03 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

I would like to be able to choose between alternative Linux command 
lines in my GRUB menu (specifically, I want a "selinux=0" option, but I 
can imagine that people might want other things).  I could add an extra 
script to /etc/grub.d to do this, but then I have to copy the logic in 
10_linux to detect what kernel versions are available, and they do not 
appear in the correct place in the menu.  It would be simpler if you 
could specify variant command lines in /etc/default/grub and have them 
handled automatically in 10_linux.

The attached patch allows (for example) the following configuration in 
/etc/default/grub:
GRUB_LINUX_VARIANTS="noselinux kms"

GRUB_CMDLINE_LINUX_noselinux="selinux=0"
GRUB_LABEL_LINUX_noselinux="SELinux disabled"

GRUB_CMDLINE_LINUX_kms="i915.modesetting=1"
GRUB_LABEL_LINUX_kms="KMS enabled"

This patch is only intended as a demonstration: various details of the 
implementation still need to be sorted out, such as 
internationalization.  Suggestions of wildly different 
approaches/configuration interfaces are welcome.

Best wishes,

-- 
Martin Orr

[-- Attachment #2: grub-linux-variants.diff --]
[-- Type: text/x-diff, Size: 1746 bytes --]

=== modified file 'util/grub-mkconfig.in'
--- util/grub-mkconfig.in	2009-12-12 00:43:32 +0000
+++ util/grub-mkconfig.in	2010-01-18 21:01:34 +0000
@@ -222,6 +222,11 @@
   GRUB_GFXMODE \
   GRUB_DISABLE_OS_PROBER
 
+export GRUB_LINUX_VARIANTS
+for i in $GRUB_LINUX_VARIANTS; do
+  export GRUB_CMDLINE_LINUX_${i} GRUB_LABEL_LINUX_${i}
+done
+
 if test "x${grub_cfg}" != "x"; then
   rm -f ${grub_cfg}.new
   exec > ${grub_cfg}.new

=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2010-01-14 14:04:44 +0000
+++ util/grub.d/10_linux.in	2010-01-18 21:01:34 +0000
@@ -53,11 +53,15 @@
   version="$2"
   recovery="$3"
   args="$4"
+  label="$5"
   if ${recovery} ; then
     title="$(gettext "%s, with Linux %s (recovery mode)")"
   else
     title="$(gettext "%s, with Linux %s")"
   fi
+  if [ "x$label" != "x" ]; then
+    title="${title} (${label})"
+  fi
   printf "menuentry \"${title}\" {\n" "${os}" "${version}"
   save_default_entry | sed -e "s/^/\t/"
   if [ -z "${prepare_boot_cache}" ]; then
@@ -111,11 +115,17 @@
   fi
 
   linux_entry "${OS}" "${version}" false \
-      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ""
   if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" true \
-	"single ${GRUB_CMDLINE_LINUX}"
+	"single ${GRUB_CMDLINE_LINUX}" ""
   fi
+  for i in ${GRUB_LINUX_VARIANTS}; do
+    eval cmdline=\${GRUB_CMDLINE_LINUX_${i}}
+    eval label=\${GRUB_LABEL_LINUX_${i}}
+    linux_entry "${OS}" "${version}" false \
+        "${cmdline}" "${label}"
+  done
 
   list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
 done


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-20 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 21:03 RFC: Support Linux command line variants in grub-mkconfig Martin Orr
2010-01-19 22:26 ` Robert Millan
2010-01-20 11:01   ` Martin Orr
2010-01-20 17:30     ` Joey Korkames

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.