Package: grub-pc
Version: 1.95+20080107-1
Severity: wishlist
Tags: patch

--- Please enter the report below this line. ---

Hi Robert,

here's the patch for debconf/postinst/etc.  for extracting kopt from the old 
menu.lst to 
/etc/default/grub, as we spoke on grub mailing list.

I hope you could rework on it, to make it a good patch.

Thanks again for your work.

--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.23-1-amd64

Debian Release: lenny/sid
  500 voip-snapshots-debian-sid snapshots.seconix.com 
  500 unstable        www.emdebian.org 
  500 unstable        www.debian-multimedia.org 
  500 unstable        ftp.uk.debian.org 
  500 unstable        ftp.fr.debian.org 
  400 testing         security.debian.org 
  400 testing         ftp.fr.debian.org 
    1 experimental    ftp.fr.debian.org 

--- Package information. ---
Depends          (Version) | Installed
==========================-+-===========
base-files      (>= 4.0.1) | 4.0.2
debconf                    | 1.5.18
debconf          (>= 0.5)  | 1.5.18
 OR debconf-2.0            | 
libc6           (>= 2.7-1) | 2.7-6
liblzo2-2                  | 2.02-3

diff -Nru --exclude=i386-pc.mk /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.config ./grub2-1.95+20080107/debian/grub-pc.config
--- /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.config	2008-01-15 00:18:46.000000000 +0100
+++ ./grub2-1.95+20080107/debian/grub-pc.config	2008-01-15 00:11:02.000000000 +0100
@@ -1,7 +1,19 @@
 #!/bin/bash -e
 
+function get_kopt_from_menu.lst() {
+    if test -e /boot/grub/menu.lst; then
+	grep -v '^[[:space:]]*##' /boot/grub/menu.lst | sed -e '\+^# kopt=+!d;s/^# kopt=\(.*\)/\1/g' -e 's/ root=[^ ]*\|^root=[^ ]*/ /g' -e 's/^ro$\|^ro \| ro$\| ro / /g'| tr -s ' '
+    fi
+}
+
 if test -e /boot/grub/menu.lst ; then
   . /usr/share/debconf/confmodule
+  present=`grep -v '^[[:space:]]*#' /etc/default/grub | grep 'GRUB_CMDLINE_LINUX' | wc -l`
+  if test "x${present}" = "x0" ; then
+      kopt=`get_kopt_from_menu.lst`
+        db_set grub-pc/kernel_options ${kopt} || true
+  fi
   db_input high grub-pc/chainload_from_menu.lst || true
+  db_input high grub-pc/kernel_options || true
   db_go
 fi
diff -Nru --exclude=i386-pc.mk /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.postinst ./grub2-1.95+20080107/debian/grub-pc.postinst
--- /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.postinst	2008-01-15 00:18:46.000000000 +0100
+++ ./grub2-1.95+20080107/debian/grub-pc.postinst	2008-01-15 00:11:02.000000000 +0100
@@ -1,5 +1,18 @@
 #!/bin/bash -e
 
+function write_kopt()
+{
+    present=`grep -v '^[[:space:]]*#' /etc/default/grub | grep 'GRUB_CMDLINE_LINUX' | wc -l`
+    if [ "x${present}" = "x1" ]
+    then
+	mask=s/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX=\"$1\"/  
+	sed -i "${mask}" /etc/default/grub
+    else
+	echo GRUB_CMDLINE_LINUX=\"$1\" >> /etc/default/grub
+    fi
+}
+
+
 case "$1" in
   configure)
     . /usr/share/debconf/confmodule
@@ -11,6 +24,13 @@
       grub-mkdevicemap
     fi
 
+    # get kernel line parameter and place it in /etc/default/grub
+    # adding it or modifying it
+    db_get grub-pc/kernel_options
+    if [ ! -z "${RET}" ]; then
+	write_kopt "${RET}"
+    fi
+
     db_get grub-pc/chainload_from_menu.lst
     if $RET && test -e /boot/grub/menu.lst && ! test -e /boot/grub/core.img ; then
       # If there's no core.img setup, create one (but do not risk writing to MBR).
diff -Nru --exclude=i386-pc.mk /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.templates ./grub2-1.95+20080107/debian/grub-pc.templates
--- /tmp/grub-orig/grub2-1.95+20080107/debian/grub-pc.templates	2008-01-15 00:18:46.000000000 +0100
+++ ./grub2-1.95+20080107/debian/grub-pc.templates	2008-01-15 00:11:02.000000000 +0100
@@ -17,3 +17,13 @@
  you can do so by issuing (as root) the following command:
  .
  grub-install "(hd0)" && update-grub
+
+Template: grub-pc/kernel_options
+Type: string
+Default:
+Description: Kernel command line parameters
+ Value of kernel command line parameters. By default, value is
+ extracted from old /boot/grub/menu.lst if exists. Here you can
+ place value to fix acpi or apic on your computer, and also parameters
+ for splash boot (splashy, usplash, ...)
+ .

Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée

Reply via email to