Package: memtest86+
Version: 1.70-3
Severity: normal
Tags: patch

Hi,

I am using grub.
And when I installed memtest86+, update-grub will not run automatically.
So I need to run update-grub manually.
(Adding the entry for memtest86+ to /boot/grub/menu.lst is unsuitable because
 update-grub will automatically adds the entry for memtest86+ to 
/boot/grub/menu.lst.
 So the entry for memtest86+ will appears twice if edit /boot/grub/menu.lst 
manually.)

It would be nice to run update-grub automatically when memtest86+ is installed.


The postinst script for memtest86+ is as follow:
if test -e /boot/grub/grub.cfg && which update-grub > /dev/null ; then
    update-grub
fi

This code means:
 * If /boot/grub/grub.cfg is exists, and
 * update-grub is available, then
 * run update-grub.

However, /boot/grub/grub.cfg is a part of grub2, not available in grub.
I suggest to change this behaviour to as follow:
 * If one of /boot/grub/grub.cfg, /boot/grub/menu.lst or 
/boot/boot/grub/menu.lst is exists, and
 * update-grub is available, then
 * run update-grub.

Note: According to /usr/share/doc/grub/README.Debian.gz,
      /boot/boot/grub/menu.lst is used if /boot is a separate partition.

Additionally, I think it is better to use /usr/sbin/update-grub instead of 
update-grub.

Here is a code I suggest:
if [ -e /boot/grub/grub.cfg -o -e /boot/grub/menu.lst -o -e 
/boot/boot/grub/menu.lst ] &&
  [ -x /usr/sbin/update-grub ]
then
    /usr/sbin/update-grub
fi


Note that update-grub is also executed in postrm as well as postinst.
In postrm script, update-grub should be executed when "$1" is "remove".
Otherwise update-grub will executed two times, when package is removed and when 
package is purged.

I have attached a patch to fix postinst and postrm script.


Thanks,
Morita Sho

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-2-k7 (SMP w/1 CPU core)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-- no debconf information
diff -ur memtest86+-1.70.orig/debian/postinst memtest86+-1.70/debian/postinst
--- memtest86+-1.70.orig/debian/postinst        2007-11-01 01:38:05.000000000 
+0900
+++ memtest86+-1.70/debian/postinst     2007-11-01 04:39:40.000000000 +0900
@@ -17,8 +17,10 @@
     fi
 fi
 
-if test -e /boot/grub/grub.cfg && which update-grub > /dev/null ; then
-    update-grub
+if [ -e /boot/grub/grub.cfg -o -e /boot/grub/menu.lst -o -e 
/boot/boot/grub/menu.lst ] &&
+  [ -x /usr/sbin/update-grub ]
+then
+    /usr/sbin/update-grub
 fi
 
 #DEBHELPER#
diff -ur memtest86+-1.70.orig/debian/postrm memtest86+-1.70/debian/postrm
--- memtest86+-1.70.orig/debian/postrm  2007-11-01 01:38:05.000000000 +0900
+++ memtest86+-1.70/debian/postrm       2007-11-01 04:39:53.000000000 +0900
@@ -1,8 +1,11 @@
-#!/bin/bash
+#!/bin/sh
 set -e
 
-if which update-grub > /dev/null ; then
-    update-grub
+if [ "$1" = "remove" ] &&
+  [ -e /boot/grub/grub.cfg -o -e /boot/grub/menu.lst -o -e 
/boot/boot/grub/menu.lst ] &&
+  [ -x /usr/sbin/update-grub ]
+then
+    /usr/sbin/update-grub
 fi
 
 #DEBHELPER#

Reply via email to