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
|
#!/bin/sh
set -e
# summary of how this script can be called:
#
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version> <new-version>
# * <new-preinst> `upgrade' <old-version> <new-version>
# * <old-preinst> `abort-upgrade' <new-version>
#
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
prepare_conffile_transfer() {
local conffile="$1"
local lastver="$2"
local pkgfrom="$3"
local pkgto="$4"
if [ "$5" != "--" ]; then
echo "prepare_conffile_transfer called with the wrong number of arguments" >&2
return 1
fi
for _ in $(seq 1 5); do
shift
done
# If we're installing from scratch or upgrading from a new enough version
# of the package, then no transfer needs to happen and we can stop here
if [ -z "$2" ] || dpkg --compare-versions -- "$2" gt "$lastver"; then
return 0
fi
# Depending on the current state of the conffile, we need to perform different
# steps to transfer it. Moving the conffile to a different location depending
# on its current state achieves two goals: dpkg will see the conffile is no
# longer present on disk after $pkgfrom has been upgraded, and so it will no
# longer associate it with that package (not even as an obsolete conffile);
# more importanly, $pkgto's postinst, where the transfer process is completed,
# will be able to figure out the original state of the conffile and make sure
# it is restored
if [ -e "$conffile" ]; then
echo "Preparing transfer of config file $conffile (from $pkgfrom to $pkgto) ..."
mv -f "$conffile" "$conffile.dpkg-transfer"
else
# If the conffile is no longer present on the disk, it means the admin
# has deleted it, and we should preserve this local modification
touch "$conffile.dpkg-disappear"
fi
}
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
install|upgrade)
prepare_conffile_transfer \
"/etc/libvirt/qemu/networks/default.xml" \
"6.9.0-2~" \
"libvirt-daemon-system" \
"libvirt-daemon-config-network" \
-- \
"$@"
for nwfilter in $NWFILTERS; do
prepare_conffile_transfer \
"/etc/libvirt/nwfilter/$nwfilter.xml" \
"6.9.0-2~" \
"libvirt-daemon-system" \
"libvirt-daemon-config-nwfilter" \
-- \
"$@"
done
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|