[PATCH] Cleaning up the kernel postinst script

Matt Zimmerman mdz at ubuntu.com
Wed Aug 19 16:45:22 BST 2009

I came across the following bug today:


which led me to notice that the postinst doesn't print the error message
when a symlink() call fails.  This makes the failure difficult to debug.

I've attached a patch which fixes that particular problem (untested but
fairly trivial).

However, this got me thinking about the kernel postinst script in general.
It is over 1000 lines of perl code, and it has many "interesting" failure
modes.  It doesn't check error codes everywhere it should, and it just
generally has a lot of logic in it.

Because every Ubuntu user has this package installed, a lot of them trip
over these failures, resulting in the rather long (and growing) list of bugs


I'd like to suggest that it might be a good idea to radically simplify this
script, so that it doesn't have quite so many opportunities to fail.  Much
of the code in it is inherited from the kernel-package package, which is
designed to provide extreme configurability.  Just look at the list of
configuration options at the top:

my $link_in_boot      = "";  # Should be empty, mostly
my $no_symlink        = "";   # Should be empty, mostly
my $reverse_symlink   = "";   # Should be empty, mostly
my $do_symlink        = "Yes";  # target machine defined
my $do_boot_enable    = "Yes";  # target machine defined
my $do_bootfloppy     = "Yes";  # target machine defined
my $do_bootloader     = "Yes";  # target machine defined
my $move_image        = '';     # target machine defined
my $kimage            = "vmlinuz";   # Should be empty, mostly
my $loader            = "grub"; # lilo, silo, quik, palo, vmelilo, nettrom, arcboot or delo
my $image_dir         = "/boot";        # where the image is located
my $clobber_modules   = '';          # target machine defined
my $relative_links    = "";          # target machine defined
my $initrd            = "YES";        # initrd kernel
my $do_initrd         = '';     # Normally we do not
my $use_hard_links    = ''; # hardlinks do not work across fs boundaries
my $postinst_hook     = '';          #Normally we do not
my $postrm_hook       = '';          #Normally we do not
my $preinst_hook      = '';          #Normally we do not
my $prerm_hook        = '';          #Normally we do not
my $minimal_swap      = '';          # Do not swap symlinks
my $ignore_depmod_err = '';          # normally we do not
my $ramdisk           = "/usr/sbin/update-initramfs";  # List of tools to create initial ram fs.
my $notifier          = "/usr/share/update-notifier/notify-reboot-required";
my $package_name      = "linux-image-$version";
my $explicit_do_loader = 'Yes';

In this era of Linux, do end users really need to tweak many of these
things?  The default GRUB configuration doesn't even use the symlinks (these
are a holdover from LILO).  Could we get rid of them entirely?

We could continue to use the massively complex one for ports if that's
needed, but I think x86+x86_64 could be much, much simpler.

What do you think?

 - mdz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: symlink-errno.diff
Type: text/x-diff
Size: 1091 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/ubuntu-devel/attachments/20090819/5699e6a9/attachment.bin 

More information about the ubuntu-devel mailing list