diff --git a/build/suse-post.sh b/build/suse-post.sh new file mode 100644 index 0000000000000000000000000000000000000000..7efe83df630f8d4b8781872c73e5a7788bf914a2 --- /dev/null +++ b/build/suse-post.sh @@ -0,0 +1,82 @@ +if [ -f /boot/vmlinuz-%ver_str ]; then + image=vmlinuz +elif [ -f /boot/image-%ver_str ]; then + image=image +elif [ -f /boot/vmlinux-%ver_str ]; then + image=vmlinux +else + # nothing to do (UML kernels for example). + exit 0 +fi + +case %ver_str in + (*xen*|*um*) + NOBOOTSPLASH="-s off" + SHORTNM=%ver_str + SHORTNM=-${SHORTNM##*-} + ;; + (*) + unset NOBOOTSPLASH + unset SHORTNM + ;; +esac + +# If we have old symlinks, rename them to *.previous +if [ -L /boot/$image$SHORTNM -a \ + "$(readlink /boot/$image$SHORTNM)" != $image-%ver_str ]; then + mv /boot/$image$SHORTNM /boot/$image$SHORTNM.previous +fi +relink $image-%ver_str /boot/$image$SHORTNM + +if test "$YAST_IS_RUNNING" != instsys ; then + if [ -f /etc/fstab ]; then + echo Setting up /lib/modules/%ver_str + if [ -x /sbin/update-modules.dep ]; then + /sbin/update-modules.dep -v %ver_str + else + /sbin/depmod -a -F /boot/System.map-%ver_str %ver_str + fi + cd /boot + /sbin/mkinitrd -k $image-%ver_str -i initrd-%ver_str $NOBOOTSPLASH + + if [ -L /boot/initrd$SHORTNM -a \ + "$(readlink /boot/initrd)" != initrd-%ver_str ]; then + mv /boot/initrd$SHORTNM /boot/initrd$SHORTNM.previous + fi + if [ -e /boot/initrd-%ver_str ]; then + relink initrd-%ver_str /boot/initrd$SHORTNM + else + rm -f /boot/initrd$SHORTNM + fi + else + echo "please run mkinitrd as soon as your system is complete" + fi +fi + +if [ "$YAST_IS_RUNNING" != instsys ]; then + # Notify boot loader that a new kernel image has been installed. + # (during initial installation the boot loader configuration does not + # yet exist when the kernel is installed, but yast kicks the boot + # loader itself later.) + if [ -x /sbin/new-kernel-pkg ]; then + /sbin/new-kernel-pkg %ver_str + elif [ -x /usr/lib/bootloader/bootloader_entry ]; then + # handle 10.2 and SLES10 SP1 + /usr/lib/bootloader/bootloader_entry \ + add \ + %flavor \ + %ver_str \ + vmlinuz-%ver_str \ + initrd-%ver_str + elif [ -x /sbin/update-bootloader ]; then + # handle 10.1 and SLES10 GA + /sbin/update-bootloader \ + --add \ + --image /boot/vmlinuz-%ver_str \ + --initrd /boot/initrd-%ver_str + /sbin/update-bootloader --refresh + else + echo "You may need to setup and install the boot loader using the" + echo "available bootloader for your platform (e.g. grub, lilo, zipl, ...)." + fi +fi diff --git a/build/suse-postun.sh b/build/suse-postun.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac9f30c1eb836b38f2deee9eab3b428b0c8a2a4f --- /dev/null +++ b/build/suse-postun.sh @@ -0,0 +1,77 @@ +if [ -L /boot/vmlinux ]; then + image=vmlinux +elif [ -L /boot/vmlinuz ]; then + image=vmlinuz +elif [ -L /boot/image ]; then + image=image +else + # nothing to do (UML kernels for example). + exit 0 +fi + +case %ver_str in + (*xen*|*um*) + SHORTNM=%ver_str + SHORTNM=-${SHORTNM##*-} + ;; + (*) + unset SHORTNM + ;; +esac + +if [ "$(readlink /boot/$image$SHORTNM)" = $image-%ver_str ]; then + # This may be the last kernel RPM on the system, or it may + # be an update. In both of those cases the symlinks will + # eventually be correct. Only if this kernel + # is removed and other kernel rpms remain installed, + # find the most recent of the remaining kernels, and make + # the symlinks point to it. This makes sure that the boot + # manager will always have a kernel to boot in its default + # configuration. + shopt -s nullglob + for img in $(cd /boot ; ls -dt $image-*$SHORTNM); do + initrd=initrd-${img#*-} + if [ -f /boot/$img -a -f /boot/$initrd ]; then + relink $img /boot/${img%%%%-*}$SHORTNM + relink $initrd /boot/${initrd%%%%-*}$SHORTNM + + # Notify the boot loader that a new kernel image is active. + if [ -x /sbin/new-kernel-pkg ]; then + /sbin/new-kernel-pkg $(/sbin/get_kernel_version /boot/$img) + fi + break + fi + done + shopt -u nullglob +fi + +# remove the bootloader entry for the kernel being removed +if [ -x /usr/lib/bootloader/bootloader_entry ]; then + # handle 10.2 and SLES10 SP1 + /usr/lib/bootloader/bootloader_entry \ + remove \ + smp \ + %ver_str \ + vmlinuz-%ver_str \ + initrd-%ver_str +elif [ -x /sbin/update-bootloader ]; then + # handle 10.1 and SLES10 GA + /sbin/update-bootloader --image /boot/vmlinuz-%ver_str \ + --initrd /boot/initrd-%ver_str \ + --remove --force + /sbin/update-bootloader --refresh +fi + +# Check whether there is a .previous link to the image we're about +# to remove or to the image we point the new symlink to (so .previous +# would be identical to the current symlink) +case "$(readlink /boot/$image$SHORTNM.previous)" in +$image-%ver_str|$(readlink /boot/$image$SHORTNM)) + rm -f /boot/$image$SHORTNM.previous ;; +esac +case "$(readlink /boot/initrd$SHORTNM.previous)" in +initrd-%ver_str|$(readlink /boot/initrd$SHORTNM)) + rm -f /boot/initrd$SHORTNM.previous ;; +esac +# created in %post +rm -f /boot/initrd-%ver_str