#!/bin/sh
set -eu

# If and only if we are uprading from a version lower than 0.9.5d-3,
# then we want to break the old /usr/share/doc/libbz2 symlink (which was 
# pointing to libbz2).
if [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" "<<" "0.9.5d-3"
then
    if test -L /usr/share/doc/bzip2
    then
	rm -f /usr/share/doc/bzip2
    fi
fi

# And we should never ever have a directory in /usr/doc/bzip2
if [ -d /usr/doc/bzip2 ] && [ ! -L /usr/doc/bzip2 ]
then
    echo "Cleaning up left-over /usr/doc/bzip2."
    rm -fr /usr/doc/bzip2
fi
