1#!/bin/sh
2
3# Abort on error.
4set -e
5
6symlink_match()
7{
8	local SYMLINK="$1"
9	local SYMLINK_TARGET="$2"
10
11	[ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \
12	[ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ]
13}
14
15SYMLINK=/usr/share/doc/comerr-dev
16SYMLINK_TARGET=libcomerr2
17SYMLINK_TARGET2=libcom-err2
18
19if [ "$1" = "purge" ] && [ -h "${SYMLINK}.dpkg-backup" ]
20then
21	rm -f "${SYMLINK}.dpkg-backup"
22fi
23if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] &&
24   [ -n "$2" ] && [ ! -e "$SYMLINK" ] && [ -h "${SYMLINK}.dpkg-backup" ]
25then
26    if symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" ||
27       symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET2"
28    then
29	echo "Restoring backup of $SYMLINK ..."
30	mv "${SYMLINK}.dpkg-backup" "$SYMLINK"
31    fi
32fi
33
34#DEBHELPER#
35
36exit 0
37