#!/bin/sh set -e # summary of how this script can be called: # # * `remove' # * `purge' # * `upgrade' # * `disappear' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # # for details, see https://www.debian.org/doc/debian-policy/ or # the debian-policy package abort_conffile_transfer() { local conffile="$1" local lastver="$2" local pkgfrom="$3" local pkgto="$4" if [ "$5" != "--" ]; then echo "abort_conffile_transfer called with the wrong number of arguments" >&2 return 1 fi for _ in $(seq 1 5); do shift done # If we were installing from scratch or upgrading from a new enough version # when the error occurred, then no transfer was in progress and we don't # need to rollback any changes if [ -z "$2" ] || dpkg --compare-versions -- "$2" gt "$lastver"; then return 0 fi # If the conffile was being transferred, return it to its original location if [ -e "$conffile.dpkg-transfer" ]; then mv -f "$conffile.dpkg-transfer" "$conffile" fi # Clean up additional state rm -f "$conffile.dpkg-disappear" } NWFILTERS=" allow-arp allow-dhcp allow-dhcp-server allow-incoming-ipv4 allow-ipv4 clean-traffic clean-traffic-gateway no-arp-ip-spoofing no-arp-mac-spoofing no-arp-spoofing no-ip-multicast no-ip-spoofing no-mac-broadcast no-mac-spoofing no-other-l2-traffic no-other-rarp-traffic qemu-announce-self qemu-announce-self-rarp " case "$1" in purge) if getent group libvirt >/dev/null; then delgroup libvirt >/dev/null || true fi if getent passwd libvirt-qemu >/dev/null; then deluser libvirt-qemu >/dev/null || true fi if getent group libvirt-qemu >/dev/null; then delgroup libvirt-qemu >/dev/null || true fi # Clean up logs and cached capabilities rm -rf /var/log/libvirt \ /var/cache/libvirt/qemu/capabilities # Clean up created dirs if existent and empty, they contain precious # data otherwise for dir in /var/lib/libvirt/qemu/save \ /var/lib/libvirt/qemu/snapshot \ /var/lib/libvirt/qemu/dump \ /var/lib/libvirt/qemu/nvram \ /var/lib/libvirt/qemu/ram/libvirt/qemu \ /var/lib/libvirt/qemu/ram/libvirt \ /var/lib/libvirt/qemu/ram \ /var/lib/libvirt/qemu/channel \ /var/lib/libvirt/qemu \ /var/cache/libvirt/qemu; do [ ! -d $dir ] || rmdir --ignore-fail-on-non-empty $dir done ;; abort-install|abort-upgrade) abort_conffile_transfer \ "/etc/libvirt/qemu/networks/default.xml" \ "6.9.0-2~" \ "libvirt-daemon-system" \ "libvirt-daemon-config-network" \ -- \ "$@" for nwfilter in $NWFILTERS; do abort_conffile_transfer \ "/etc/libvirt/nwfilter/$nwfilter.xml" \ "6.9.0-2~" \ "libvirt-daemon-system" \ "libvirt-daemon-config-nwfilter" \ -- \ "$@" done # dh_apparmor can't work with dir/file profile filenames yet (#979500) ABSTRACTIONS_DIR="/etc/apparmor.d/abstractions" LOCAL_ABSTRACTIONS_DIR="/etc/apparmor.d/local/abstractions" LIBVIRT_ABSTRACTIONS="libvirt-lxc libvirt-qemu" for name in $LIBVIRT_ABSTRACTIONS; do abstraction="$ABSTRACTIONS_DIR/$name" local_abstraction="$LOCAL_ABSTRACTIONS_DIR/$name" if [ ! -e "$abstraction" ] ; then rm -f "$local_abstraction" rmdir --ignore-fail-on-non-empty "$LOCAL_ABSTRACTIONS_DIR" 2>/dev/null fi done ;; remove|upgrade|disappear|failed-upgrade) ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 ;; esac # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then systemctl --system daemon-reload >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'libvirt-guests.service' 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.service' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.service' 'virtlogd.socket' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then systemctl --system daemon-reload >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.11.4 if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'libvirtd.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installdebconf/13.11.4 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge fi # End automatically added section # Automatically added by dh_apparmor/3.0.8-3 if [ "$1" = "purge" ] && ! [ -e "/etc/apparmor.d/usr.sbin.libvirtd" ] ; then rm -f "/etc/apparmor.d/disable/usr.sbin.libvirtd" || true rm -f "/etc/apparmor.d/force-complain/usr.sbin.libvirtd" || true rm -f "/etc/apparmor.d/local/usr.sbin.libvirtd" || true rm -f /var/cache/apparmor/*/"usr.sbin.libvirtd" || true rmdir /etc/apparmor.d/disable 2>/dev/null || true rmdir /etc/apparmor.d/local 2>/dev/null || true rmdir /etc/apparmor.d 2>/dev/null || true fi # End automatically added section # Automatically added by dh_apparmor/3.0.8-3 if [ "$1" = "purge" ] && ! [ -e "/etc/apparmor.d/usr.lib.libvirt.virt-aa-helper" ] ; then rm -f "/etc/apparmor.d/disable/usr.lib.libvirt.virt-aa-helper" || true rm -f "/etc/apparmor.d/force-complain/usr.lib.libvirt.virt-aa-helper" || true rm -f "/etc/apparmor.d/local/usr.lib.libvirt.virt-aa-helper" || true rm -f /var/cache/apparmor/*/"usr.lib.libvirt.virt-aa-helper" || true rmdir /etc/apparmor.d/disable 2>/dev/null || true rmdir /etc/apparmor.d/local 2>/dev/null || true rmdir /etc/apparmor.d 2>/dev/null || true fi # End automatically added section exit 0