Package: debianutils
Version: 2.28.6
Severity: wishlist
Tags: patch

Hi,

        The installkernel script is beginning to show its age, and does
 not match how other packages cooperate in the installation of kernel
 images in recent (like, for the last few) releases of Debian.

        The installkernel, when run by root, runs mkboot by default,
 which talks about the importance of boot floppy diskettes (I don't even
 have a floppy drive anymore), and tries to run or not run lilo and
 elilo based on heuristics (are they installed, is grub installed -- I
 can have grub installed and yet still use lilo, but that is not
 something considered), I have tried using the current installkernel
 script as an end user, and the behaviour was not something I consider
 desirable. 

        installkernel also unconditionally creates symbolic links in
 $DESTDIR (nominally /boot).  The symlinks created are:
        $DESTDIR/{config,System.map,vmlinu[xz]}
 These symlinks are not useful if you use grub, or use official kernel
 images. Creating these links make it less useful when used to create
 kernel image packages. (running mkboot is even worse when building a
 kernel image package).

        Ideally, the symbolic links should be updated if they exist, but
 should not be created when they do not.  I have a tested version of
 installkernel that does not call mkboot, and only updates symlinks,
 but doe4s not create them.

        Next, the modern Debian installation has kernel images run
 scripts which have been dropped into /etc/kernel/{pre,post}{inst,rm}.d/ 
 directories, or put into /etc/kernel-img.conf -- and installkernel does
 not do anything like this.

        Now, when installkernel is called (by running make install in a
 kernel source directory), the modules might not yet have been
 installed, so running the scripts would be wrong (intramfs, for
 instance, depends on the modules being around)

        I would like to use intallkernel to build kernel images, since
 then I can use Kbuild interfaces to create the kernel packages, and
 greatly simplify kernel building, and make it more robust.

        manoj

--8<---------------cut here---------------start------------->8---

>From faadb82c786a9e44c3904e1e5253ec11ddb9b62d Mon Sep 17 00:00:00 2001
>From: Manoj Srivastava <[EMAIL PROTECTED]>
>Date: Sun, 8 Jun 2008 14:17:17 -0500

This patch updates the installkernel script to be useful on modern
Debian installations, which now default to grub, and not LILO, and
also tend to run initial RAM fs creators, and other post processing
steps, before hooking in their boot manager update scripts.

mkboot has not been the default way to setup a newly installed kernel
in about a decade or so.

installkernel also unconditionally created symbolic links in
$DESTDIR (nominally /boot).  The symlinks created were:
       $DESTDIR/{config,System.map,vmlinu[xz]}
These symlinks are not useful if you use grub, or use official kernel
images. Creating these links make it less useful when used to create
kernel image packages. (running mkboot is even worse when building a
kernel image package).

Ideally, the symbolic links should be updated if they exist, but
should not be created when they do not, which is what this patch does.

Next, the modern Debian installation has kernel images run scripts
which have been dropped into /etc/kernel/{pre,post}{inst,rm}.d/
directories, or put into /etc/kernel-img.conf -- and installkernel
does not do anything like this. When installkernel is called (by
running make install in a kernel source directory), the modules might
not yet have been installed, so running the scripts would be wrong
(intramfs, for instance, depends on the modules being around)

Signed-off-by: Manoj Srivastava <[EMAIL PROTECTED]>
---
 installkernel   |   31 +++++++++++++++++++++----------
 installkernel.8 |   19 ++++---------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/installkernel b/installkernel
index 8f1010f..e4e1079 100644
--- a/installkernel
+++ b/installkernel
@@ -14,6 +14,7 @@
 
 set -e
 
+# Parse the command line options
 if [ $# -eq 3 ] || [ $# -eq 4 ] ; then
   img="$2"
   map="$3"
@@ -28,6 +29,7 @@ else
   exit 1
 fi
 
+# Create backups of older versions before installing
 updatever () {
   if [ -f "$dir/$1-$ver" ] ; then
     mv "$dir/$1-$ver" "$dir/$1-$ver.old"
@@ -35,16 +37,20 @@ updatever () {
 
   cat "$2" > "$dir/$1-$ver"
 
+  # This section is for backwards compatibility only
   if test -f "$dir/$1" ; then
+    # The presence of "$dir/$1" is unusual in modern intallations, and
+    # the results are mostly unused.  So only recreate them if they
+    # already existed.
     if test -L "$dir/$1" &&
-       [ "$(readlink -f ${dir}/${1})" = "${dir}/${1}-${ver}" ]; then
-      ln -sf "$1-$ver.old" "$dir/$1.old"
+        [ "$(readlink -f ${dir}/${1})" = "${dir}/${1}-${ver}" ]; then
+        ln -sf "$1-$ver.old" "$dir/$1.old"
+        ln -sf "$1-$ver" "$dir/$1"
     else
-      mv "$dir/$1" "$dir/$1.old"
+        mv "$dir/$1" "$dir/$1.old"
+        cat "$2" > "$dir/$1"
     fi
   fi
-
-  ln -sf "$1-$ver" "$dir/$1"
 }
 
 if [ "$(basename $img)" = "vmlinux" ] ; then
@@ -60,8 +66,13 @@ if [ -f "$config" ] ; then
   updatever config "$config"
 fi
 
-if [ "$(basename $img)" = "vmlinux" ] && [ "$(id -u)" = "0" ] ; then
-  mkboot -i ${dir}/vmlinux-${ver}
-else
-  mkboot -i ${dir}/vmlinuz-${ver}
-fi
+## This is very far from existing practice in modern Debian installations
+########################################################################
+# if [ "$(basename $img)" = "vmlinux" ] && [ "$(id -u)" = "0" ] ; then #
+#   mkboot -i ${dir}/vmlinux-${ver}                                    #
+# else                                                                 #
+#   mkboot -i ${dir}/vmlinuz-${ver}                                    #
+# fi                                                                   #
+########################################################################
+ 
+exit 0
diff --git a/installkernel.8 b/installkernel.8
index 14511c3..1749c6e 100644
--- a/installkernel.8
+++ b/installkernel.8
@@ -12,27 +12,16 @@ tree.  It is called by the Linux kernel makefiles when
 is invoked there.
 .P
 The new kernel is installed into
-.IR {directory}/vmlinuz-{version} ,
-a link is made from
+.IR {directory}/vmlinuz-{version} .
+If a symbolic link 
+.I {directory}/vmlinuz
+already exists, it is refreshed by making a link from
 .I {directory}/vmlinuz
 to the new kernel, and the previously installed kernel is available as
 .IR {directory}/vmlinuz.old .
-If you use LILO, 
-.I /etc/lilo.conf
-should contain entries for the images
-.IR {directory}/vmlinuz " and " {directory}/vmlinuz.old .
-.RI ( {version}
-is the new kernel's version.)
-.P
-.B installkernel
-calls
-.B mkboot -i
-to make the system bootable after the kernel is installed.
 .SH BUGS
 installkernel resides in /sbin only because the Linux kernel makefiles
 call it from there.  It should really be in /usr/sbin.  It isn't
 needed to boot a system, and it calls
 .BR mkboot ,
 which depends on the /usr partition being mounted.
-.SH "SEE ALSO"
-mkboot(8), lilo(8), lilo.conf(5)
-- 
1.5.5.3


--8<---------------cut here---------------end--------------->8---

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.25.3 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages debianutils depends on:
ii  libc6                         2.7-12     GNU C Library: Shared libraries

debianutils recommends no packages.

-- no debconf information

-- 
"That government is best which governs least." Thomas Jefferson
Manoj Srivastava <[EMAIL PROTECTED]> <http://www.golden-gryphon.com/>  
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to