Bug#363697: debconf template to autorun update-grub in postinst

Robert Millan rmh at aybabtu.com
Thu Apr 20 13:02:25 UTC 2006


Package: grub
Version: 0.97-7.1+kbsd
Severity: wishlist
Tags: patch

Hi!

With this patch, when grub is not installed in the system (/boot/grub is not
present), a debconf question will be asked to wether user wants to install it
automaticaly or not.

It done in a very harmless and non-intrusive way:

  - Question is only asked when /boot/grub does not exist.
  - Defaults to "no".

This feature will be very useful in two situations:

  - Users who installed debian before sarge, and got LILO setup by default.
  - Debian systems not using d-i, like GNU/kFreeBSD or GNU/Hurd, which can't
  benefit from grub-installer udeb, may use this feature as a replacement.

-- System Information:
Debian Release: testing/unstable
Architecture: kfreebsd-i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: GNU/kFreeBSD 5.4-1-486
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)

Versions of packages grub depends on:
ii  debconf                       1.4.72     Debian configuration management sy
ii  libc0.1                       2.3.6-7    GNU C Library: Shared libraries
ii  libncurses5                   5.5-1+kbsd Shared libraries for terminal hand

grub recommends no packages.

-- debconf information excluded
-------------- next part --------------
diff -Nur grub-0.97.old/debian/control grub-0.97/debian/control
--- grub-0.97.old/debian/control	2006-04-20 12:28:18.000000000 +0200
+++ grub-0.97/debian/control	2006-04-20 14:47:44.000000000 +0200
@@ -9,7 +9,7 @@
 
 Package: grub
 Architecture: i386 darwin-i386 freebsd-i386 kfreebsd-i386 knetbsd-i386 netbsd-i386 openbsd-i386 hurd-i386 amd64 darwin-amd64 freebsd-amd64 kfreebsd-amd64 knetbsd-amd64 netbsd-amd64 openbsd-amd64 hurd-amd64
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, debconf
 Suggests: grub-doc, grubconf
 Description: GRand Unified Bootloader
  GRUB is a GPLed bootloader intended to unify bootloading across x86
diff -Nur grub-0.97.old/debian/control.in grub-0.97/debian/control.in
--- grub-0.97.old/debian/control.in	2006-04-20 12:28:18.000000000 +0200
+++ grub-0.97/debian/control.in	2006-04-20 14:47:37.000000000 +0200
@@ -9,7 +9,7 @@
 
 Package: grub
 Architecture: @arches@
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, debconf
 Suggests: grub-doc, grubconf
 Description: GRand Unified Bootloader
  GRUB is a GPLed bootloader intended to unify bootloading across x86
diff -Nur grub-0.97.old/debian/grub.config grub-0.97/debian/grub.config
--- grub-0.97.old/debian/grub.config	1970-01-01 01:00:00.000000000 +0100
+++ grub-0.97/debian/grub.config	2006-04-20 14:44:49.000000000 +0200
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+if ! test -e /boot/grub ; then
+  db_input high grub/install || true
+  db_go
+fi
diff -Nur grub-0.97.old/debian/grub.postinst grub-0.97/debian/grub.postinst
--- grub-0.97.old/debian/grub.postinst	1970-01-01 01:00:00.000000000 +0100
+++ grub-0.97/debian/grub.postinst	2006-04-20 14:55:43.000000000 +0200
@@ -0,0 +1,37 @@
+#! /bin/sh
+# postinst script for grub
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+    configure)
+      if ! test -e /boot/grub ; then
+        . /usr/share/debconf/confmodule 
+        db_get grub/install
+        if [ "$RET" = "true" ] ; then
+          grub-install "(hd0)"
+          update-grub -y
+        fi
+      fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff -Nur grub-0.97.old/debian/grub.templates grub-0.97/debian/grub.templates
--- grub-0.97.old/debian/grub.templates	1970-01-01 01:00:00.000000000 +0100
+++ grub-0.97/debian/grub.templates	2006-04-20 14:54:38.000000000 +0200
@@ -0,0 +1,8 @@
+Template: grub/install
+Type: boolean
+Default: false
+Description: Install GRUB to MBR?
+ It seems that the GRUB bootloader is not installed in this system.  Would you
+ like to install it to the Master Boot Record of your first hard disk?
+ .
+ Warning: This will overwrite any existing bootloader you may have installed.
diff -Nur grub-0.97.old/debian/rules grub-0.97/debian/rules
--- grub-0.97.old/debian/rules	2006-04-20 12:28:18.000000000 +0200
+++ grub-0.97/debian/rules	2006-04-20 14:51:31.000000000 +0200
@@ -261,7 +261,7 @@
 	dh_installdocs
 	dh_installexamples
 #	dh_installmenu
-#	dh_installdebconf	
+	dh_installdebconf	
 #	dh_installlogrotate	
 #	dh_installemacsen
 #	dh_installpam


More information about the Pkg-grub-devel mailing list