#!/bin/sh # Avoid executing multiple times. if [ -n "$DEB_MAINT_PARAMS" ]; then eval set -- "$DEB_MAINT_PARAMS" if [ -z "$1" ] || [ "$1" != "remove" ]; then exit 0 fi fi # Determine if symlinks are to be maintained, and if so, where. if [ -h /vmlinuz -o -h /vmlinuz.old ] then SYMLINKDIR=/ elif [ -h /boot/vmlinuz -o -h /boot/vmlinuz.old ] then SYMLINKDIR=/boot else SYMLINKDIR= fi # Are we going to do symlinks? if [ -n "$SYMLINKDIR" ] then vmlinuz_dir=/boot if [ "$vmlinuz_dir" = "$SYMLINKDIR" ] then target_prefix= else target_prefix=boot/ fi # Change to the directory where the symlinks are maintained. cd $SYMLINKDIR # Announce intentions (to STDERR). echo "Updating symbolic links" >&2 # Silently remove any existing symbolic links. rm -f vmlinuz vmlinuz.old initrd.img initrd.img.old # Determine the name of a temporary file. outfile=$(tempfile -p outp -m 0600) # Make a list of the kernel images in the kernel image directory, # sorted in descending order by modification time, and send the # output to the temporary file. (cd "$vmlinuz_dir" && ls -td1 vmlinu[xz]-*) > $outfile # Determine the two newest kernel images. STD="$(head -n 1 $outfile)" OLD="$(head -n 2 $outfile | tail -n 1)" if [ "X$OLD" = "X$STD" ]; then OLD= fi # Delete the temporary file. rm -f $outfile if [ "X$STD" != "X" ]; then # Create the symbolic link for the newest kernel image; and # create the symbolic link for its initial RAM disk image, # if it has one. ln -s ${target_prefix}$STD vmlinuz STD2="$(echo $STD | sed 's/vmlinu[xz]-//')" if [ -f "$vmlinuz_dir/"initrd.img-$STD2 ] ; then ln -s ${target_prefix}initrd.img-$STD2 initrd.img fi if [ "X$OLD" != "X" ]; then # Create the symbolic link for the second newest kernel image, # if there is one; and create the symbolic link for its initial # RAM disk image, if it has one. ln -s ${target_prefix}$OLD vmlinuz.old OLD2="$(echo $OLD | sed 's/vmlinu[xz]-//')" if [ -f "$vmlinuz_dir/"initrd.img-$OLD2 ] ; then ln -s ${target_prefix}initrd.img-$OLD2 initrd.img.old fi fi fi fi # All done. Force a clean exit. exit 0