1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00
CumulusNetworks-ifupdown2/debian/python-ifupdown2.postrm

68 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# postrm script for ifupdown2
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
postrm_remove()
{
rm -f /sbin/ifup /sbin/ifdown /sbin/ifquery
update-rc.d networking remove >/dev/null
}
# Note: We don't remove /etc/network/interfaces
postrm_purge()
{
rm -f /var/tmp/network/ifstatenew
if [ -L /etc/network/run ] ; then
rm -f /etc/network/run
elif [ -d /etc/network/run ] ; then
rmdir --ignore-fail-on-non-empty /etc/network/run
fi
}
case "$1" in
purge)
postrm_purge
;;
remove)
postrm_remove
;;
upgrade|disappear|failed-upgrade|abort-install|abort-upgrade)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
ifupdown2: fixup maintainer scripts to not crash on files not existing Ticket: CM-5735 Reviewed By: no one Testing Done: lots of repo upgrade testing by John B. This partially reverts commit 8959e8e4ec93487228733b17ef2b220ed47c1260 ("Fix bash completion for sudo users (mostly cosmetic)") in the sections where the Debian maintainer scripts were modified. In addition fixed up the Debian maintainer scripts to prevent a potential upgrade failure, discussion follows: The Cause For the upgrade Failure ================================= Commit 8959e8e4ec93487228733b17ef2b220ed47c1260 introduced changes to ifupdown2's package maintainer scripts to override some files provided by the bridge-utils and udev packages as they conflict with ifupdown2. The change to ifupdown2's postrm script is currently causing the script to exit with a failure code if the following files do not exist on the box: /etc/udev/rules.d/80-networking.rules /etc/udev/rules.d/60-bridge-network-interface.rules The reason for this is in how the script is written. Since the postrm script is configured to exit on the first command failure, the "set -e" on line 3, the commands on lines 20 and 22 will fail if the files being looked for do not exist, causing the script to exit with a non-zero exit code. Causing apt to fail the upgrade. .postrm script excerpt ---------- 20 udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null) 21 [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules 22 udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null) 23 [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules ---------- Solution -------- The solution requires having the newer version of the ifupdown2 package provide a preinst script that gets run before the older package's postrm script is run[1,2]. This gives us the opportunity to quietly fix the problem. We also fix the postrm script in newer versions of the package so it cannot bomb out in this way. Finally, removed what appears to be a poor merge from commit 5f5d84e3261bf70dd3541666a3d3a7f817727ce6. Fixes: 8959e8e4ec93487228733b17ef2b220ed47c1260 (cherry picked from commit 0eab79eb5aed4cdf0674e3f0ddad3631dd457bdc)
2015-04-20 13:41:05 -07:00
udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null || true)
[ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules
ifupdown2: fixup maintainer scripts to not crash on files not existing Ticket: CM-5735 Reviewed By: no one Testing Done: lots of repo upgrade testing by John B. This partially reverts commit 8959e8e4ec93487228733b17ef2b220ed47c1260 ("Fix bash completion for sudo users (mostly cosmetic)") in the sections where the Debian maintainer scripts were modified. In addition fixed up the Debian maintainer scripts to prevent a potential upgrade failure, discussion follows: The Cause For the upgrade Failure ================================= Commit 8959e8e4ec93487228733b17ef2b220ed47c1260 introduced changes to ifupdown2's package maintainer scripts to override some files provided by the bridge-utils and udev packages as they conflict with ifupdown2. The change to ifupdown2's postrm script is currently causing the script to exit with a failure code if the following files do not exist on the box: /etc/udev/rules.d/80-networking.rules /etc/udev/rules.d/60-bridge-network-interface.rules The reason for this is in how the script is written. Since the postrm script is configured to exit on the first command failure, the "set -e" on line 3, the commands on lines 20 and 22 will fail if the files being looked for do not exist, causing the script to exit with a non-zero exit code. Causing apt to fail the upgrade. .postrm script excerpt ---------- 20 udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null) 21 [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules 22 udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null) 23 [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules ---------- Solution -------- The solution requires having the newer version of the ifupdown2 package provide a preinst script that gets run before the older package's postrm script is run[1,2]. This gives us the opportunity to quietly fix the problem. We also fix the postrm script in newer versions of the package so it cannot bomb out in this way. Finally, removed what appears to be a poor merge from commit 5f5d84e3261bf70dd3541666a3d3a7f817727ce6. Fixes: 8959e8e4ec93487228733b17ef2b220ed47c1260 (cherry picked from commit 0eab79eb5aed4cdf0674e3f0ddad3631dd457bdc)
2015-04-20 13:41:05 -07:00
udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null || true)
[ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0