| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
rm_udevrule() { |
| 6 |
PKG="$1" |
| 7 |
CONFFILE="$2" |
| 8 |
|
| 9 |
if [ -e "$CONFFILE" ]; then |
| 10 |
md5sum="$(md5sum "$CONFFILE" | awk '{print $1}')" |
| 11 |
old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKG | sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")" |
| 12 |
if [ "$md5sum" = "$old_md5sum" ]; then |
| 13 |
rm -f "$CONFFILE" |
| 14 |
fi |
| 15 |
fi |
| 16 |
} |
| 17 |
|
| 18 |
case "$1" in |
| 19 |
upgrade|install|abort-upgrade) |
| 20 |
# Remove symlink, dpkg doesn't like it at all |
| 21 |
if [ -h /usr/share/doc/hplip ]; then |
| 22 |
rm -f /usr/share/doc/hplip |
| 23 |
fi |
| 24 |
|
| 25 |
# Stop and remove any daemon from old HPLIP installations |
| 26 |
if [ -x /etc/init.d/hplip ]; then |
| 27 |
pkill hpiod || true |
| 28 |
if pgrep hpiod >/dev/null; then sleep 3; pkill -9 hpiod || true; fi |
| 29 |
if pgrep hpiod >/dev/null; then |
| 30 |
echo 'Old HPLIP daemon (hpiod) should have been stopped, but did not. Please kill manually before hplip can proceed' |
| 31 |
exit 1 |
| 32 |
fi |
| 33 |
rm -fR /etc/init.d/hplip |
| 34 |
update-rc.d -f hplip remove |
| 35 |
fi |
| 36 |
|
| 37 |
# Remove obsolete config file for HPLIP startup script |
| 38 |
rm -f /etc/default/hplip |
| 39 |
|
| 40 |
# Remove obsolete udev rules |
| 41 |
rm_udevrule hplip /etc/udev/rules.d/55-hpmud.rules |
| 42 |
rm_udevrule hplip /etc/udev/rules.d/45-hplip.rules |
| 43 |
rm_udevrule hplip /etc/udev/rules.d/024_hpmud.rules |
| 44 |
rm_udevrule hplip /etc/udev/rules.d/56-hpmud_support.rules |
| 45 |
rm_udevrule hplip /etc/udev/rules.d/z60_hplip.rules |
| 46 |
rm_udevrule hplip /etc/udev/rules.d/86-hpmud_plugin.rules |
| 47 |
rm_udevrule hplip /etc/udev/rules.d/56-hpmud_add_printer.rules |
| 48 |
rm_udevrule hplip /etc/udev/rules.d/40-hplip.rules |
| 49 |
|
| 50 |
;; |
| 51 |
|
| 52 |
*) |
| 53 |
echo "preinst called with unknown argument \`$1'" >&2 |
| 54 |
exit 1 |
| 55 |
;; |
| 56 |
esac |
| 57 |
|
| 58 |
#DEBHELPER# |
| 59 |
|
| 60 |
exit 0 |