1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#!/bin/sh
# postinst script for qemu-kvm
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
# In 0.13 we changed /usr/share/kvm/keymaps from being a directory to
# a symlink to /usr/share/qemu/keymaps/ provided by qemu-keymaps pkg.
# When upgrading dpkg does not change directory to a symlink automatically.
keymaps_to_symlink() {
keymaps=/usr/share/kvm/keymaps
target=../qemu/keymaps
if dpkg --compare-versions "$1" lt "0.13.0+dfsg-1~" &&
[ ! -L $keymaps ]; then
if [ -d $keymaps ]; then
rmdir $keymaps
fi
ln -s $target $keymaps
fi
}
case "$1" in
configure)
# Add the kvm group unless it's already there
if ! getent group kvm >/dev/null; then
addgroup --quiet --system kvm || true
fi
# even if $2==most-recently-configured-version is empty we
# should try to fix the symlink mess since we may have an
# old version which is unpacked (hence directory exists)
# but not configured. dpkg --compare-versions in keymaps_to_symlink()
# above will work correctly for empty version string too.
keymaps_to_symlink "$2"
# in 0.14.2 we moved initscript (module loading)
# from "defaults" level to just one rcS.d start
# (there's no need to unload the module anymore).
# Clean the old symlinks here.
# There's no need to bother with backwards compatibility
# since old script will work in rcS.d too.
if dpkg --compare-versions "$2" lt "0.14.2"; then
update-rc.d -f qemu-kvm remove >/dev/null
fi
# 1.1~* shipped /etc/kvm/cpus-x86_64.conf which is never used there,
# it is expected to be in /usr/share/kvm/ instead. Just remove it.
# We can't do that only when upgrading from 1.1~, since it is
# possible to install 1.1~, which will create that file, downgrade
# to previous version (this file will be kept), and upgrade to
# current version: in this case, the version we're upgrading from
# ($2) will be less than 1.1, but the file will be there anyway.
file=/etc/kvm/cpus-x86_64.conf
if dpkg --compare-versions "$2" lt 1.1.0~ && [ -f $file ]
then
echo "Removing wrongly placed (and never used) $file"
rm $file
fi
;;
abort-upgrade)
# if downgrade fails we need to restore the symlink removed in prerm
keymaps_to_symlink "$2"
;;
abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
if [ -x /etc/init.d/qemu-kvm ]; then
update-rc.d qemu-kvm start 20 S . >/dev/null
if [ ! -e /dev/kvm ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d qemu-kvm start || :
else
/etc/init.d/qemu-kvm start || :
fi
fi
fi
# if we just installed the package, udev rules aren't picked up yet,
# so udev created the device (/dev/kvm) with default permissions.
# Fix it here, but only if the perms are like default.
# (See #607391)
if [ -c /dev/kvm -a ! -L /dev/kvm ] && [ .$(stat -c %u%g /dev/kvm) = .00 ]
then
chgrp kvm /dev/kvm
chmod 0660 /dev/kvm
fi
exit 0
|