With the new kernel-package hitting Sid today, and the fact that it no longer does symlink handling by default, I thought it was time that we had an example script that shows how to do that. This is a fairly full featured script, feel free to cull down to use just what you want.
I’ll post a couple of ther scripts, if there is interest in
this. BTW, this script does far more than the old
kernel-package postisnt script ever
did.
Have fun.
1 #!/bin/sh - 2 # -*- Mode: Sh -*- 3 # 4 # This is an example of a script that can be run as a postinst hook, 5 # and manages the symbolic links in a manner similar to the kernel 6 # image default behaviour, except that the latest two versions (as 7 # determined by ls -lct) are kept. You can modify this script 8 # 9 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Manoj Srivastava 10 # Copyright 2009 Darren Salt 11 12 set -e 13 14 # The dir where symlinks are managed 15 SYMLINKDIR=/ 16 17 if [ $# -ne 2 ]; then 18 echo Usage: $0 version location 19 exit 2 20 fi 21 22 version="$1" 23 vmlinuz_location="$2" 24 vmlinuz_dir="$(dirname "$2")" 25 26 cd $SYMLINKDIR || exit 1 27 28 if [ -n "$DEB_MAINT_PARAMS" ]; then 29 eval set -- "$DEB_MAINT_PARAMS" 30 fi 31 32 if [ -z "$1" ] || [ "$1" != "configure" ]; then 33 exit 0; 34 fi 35 36 rm -f vmlinuz vmlinuz.old vmlinuz-rd vmlinuz-rd.old initrd.img initrd.img.old 37 38 # Create a temporary file safely 39 if [ -x /bin/tempfile ]; then 40 outfile=$(tempfile -p outp -m 0600); 41 else 42 set -e 43 mkdir /tmp/kernel-image-$version-$$ 44 outfile=/tmp/kernel-image-$version-$$/output 45 fi 46 47 (cd "$vmlinuz_dir" && ls -ct vmlinuz-*) > $outfile 48 49 STD="$(head -n 1 $outfile | sed 's/vmlinuz-//')" 50 OLD="$(head -n 2 $outfile | tail -n 1 | sed 's/vmlinuz-//')" 51 52 if [ "X$STD" = "X" ]; then 53 exit 0; 54 fi 55 56 # If you want version-specific links, here's how to start 57 STD24="$(grep vmlinuz-2.4 $outfile | head -n 1 | sed 's/vmlinuz-//')" || true 58 OLD24="$(grep vmlinuz-2.4 $outfile | head -n 1 | tail -n 1 | sed 's/vmlinuz-//')" || true 59 60 STD25="$(grep vmlinuz-2.5 $outfile | head -n 1 | sed 's/vmlinuz-//')" || true 61 OLD25="$(grep vmlinuz-2.5 $outfile | head -n 1 | tail -n 1 | sed 's/vmlinuz-//')" || true 62 63 echo Booting $STD, old is $OLD 64 65 if [ -f "$vmlinuz_dir/"initrd.img-$STD ] ; then 66 ln -s "$vmlinuz_dir/"initrd.img-$STD initrd.img 67 ln -s "$vmlinuz_dir/"vmlinuz-$STD vmlinuz-rd 68 else 69 ln -s "$vmlinuz_dir/"vmlinuz-$STD vmlinuz 70 fi 71 72 if [ "X$OLD" != "X" ]; then 73 if [ -f "$vmlinuz_dir/"initrd.img-$OLD ] ; then 74 ln -s "$vmlinuz_dir/"initrd.img-$OLD initrd.img.old 75 ln -s "$vmlinuz_dir/"vmlinuz-$OLD vmlinuz-rd.old 76 else 77 ln -s "$vmlinuz_dir/"vmlinuz-$OLD vmlinuz.old 78 fi 79 fi 80 81 # if [ "X$STD24" != "X" ]; then 82 # if [ -f "$vmlinuz_dir/"initrd.img-$STD24 ] ; then 83 # ln -s "$vmlinuz_dir/"initrd.img-$STD24 initrd24.img 84 # ln -s "$vmlinuz_dir/"vmlinuz-$STD24 vmlinuz24-rd 85 # else 86 # ln -s "$vmlinuz_dir/"vmlinuz-$STD24 vmlinuz24 87 # fi 88 # fi 89 # if [ "X$OLD24" != "X" ]; then 90 # if [ -f "$vmlinuz_dir/"initrd.img-$OLD24 ] ; then 91 # ln -s "$vmlinuz_dir/"initrd.img-$OLD24 initrd24.img.old 92 # ln -s "$vmlinuz_dir/"vmlinuz-$OLD vmlinuz24-rd.old 93 # else 94 # ln -s "$vmlinuz_dir/"vmlinuz-$OLD vmlinuz24.old 95 # fi 96 # fi 97 98 # Run boot loaders here. 99 #lilo 100 101 rm -f $outfile 102 if [ -d /tmp/kernel-image-$version-$$ ]; then 103 rmdir /tmp/kernel-image-$version-$$ 104 fi 105 106 exit 0





Comments