Whamcloud - gitweb
b=15870
[fs/lustre-release.git] / build / suse-postun.sh
1 if [ -L /boot/vmlinux ]; then
2     image=vmlinux
3 elif [ -L /boot/vmlinuz ]; then
4     image=vmlinuz
5 elif [ -L /boot/image ]; then
6     image=image
7 else
8     # nothing to do (UML kernels for example).
9     exit 0
10 fi
11
12 case %ver_str in
13     (*xen*|*um*)
14         SHORTNM=%ver_str
15         SHORTNM=-${SHORTNM##*-}
16         ;;
17     (*)
18         unset SHORTNM
19         ;;
20 esac
21
22 if [ "$(readlink /boot/$image$SHORTNM)" = $image-%ver_str ]; then
23     # This may be the last kernel RPM on the system, or it may
24     # be an update. In both of those cases the symlinks will
25     # eventually be correct. Only if this kernel
26     # is removed and other kernel rpms remain installed,
27     # find the most recent of the remaining kernels, and make
28     # the symlinks point to it. This makes sure that the boot
29     # manager will always have a kernel to boot in its default
30     # configuration.
31     shopt -s nullglob
32     for img in $(cd /boot ; ls -dt $image-*$SHORTNM); do
33         initrd=initrd-${img#*-}
34         if [ -f /boot/$img -a -f /boot/$initrd ]; then
35             relink $img /boot/${img%%%%-*}$SHORTNM
36             relink $initrd /boot/${initrd%%%%-*}$SHORTNM
37
38             # Notify the boot loader that a new kernel image is active.
39             if [ -x /sbin/new-kernel-pkg ]; then
40                 /sbin/new-kernel-pkg $(/sbin/get_kernel_version /boot/$img)
41             fi
42             break
43         fi
44     done
45     shopt -u nullglob
46 fi
47
48 # Check whether there is a .previous link to the image we're about
49 # to remove or to the image we point the new symlink to (so .previous
50 # would be identical to the current symlink)
51 case "$(readlink /boot/$image$SHORTNM.previous)" in
52 $image-%ver_str|$(readlink /boot/$image$SHORTNM))
53     rm -f /boot/$image$SHORTNM.previous ;;
54 esac
55 case "$(readlink /boot/initrd$SHORTNM.previous)" in
56 initrd-%ver_str|$(readlink /boot/initrd$SHORTNM))
57     rm -f /boot/initrd$SHORTNM.previous ;;
58 esac
59 # created in %post
60 rm -f /boot/initrd-%ver_str