#!/bin/sh 

set -e

VERSION=00103-1
VERSION_2=00103-3
VERSION_3=00103-6
OLD_ALT_NAME=ttf-japanese-mincho
FONT_ENTRY=/usr/share/fonts/opentype/ipaexfont/ipaexm.ttf
FONT_ENTRY_2=/usr/share/fonts/opentype/ipaexfont/ipaexm.ttf
FONT_ENTRY_3=/usr/share/fonts/opentype/fonts-ipaexfont-mincho/ipaexm.ttf

case "$1" in
install|upgrade)
    if dpkg --compare-versions "$2" lt-nl "$VERSION"; then
        # remove old alternative otf symlinks.
        update-alternatives --remove $OLD_ALT_NAME.otf $FONT_ENTRY
    fi

    if dpkg --compare-versions "$2" lt-nl "$VERSION_2"; then
        if [ -d /usr/share/fonts/opentype/ipaexfont ]; then
          update-alternatives --remove $OLD_ALT_NAME.ttf $FONT_ENTRY_2
        fi
    fi

    if dpkg --compare-versions "$2" lt-nl "$VERSION_3"; then
        if [ -d /usr/share/fonts/opentype/fonts-ipaexfont-mincho ]; then
          update-alternatives --remove $OLD_ALT_NAME.ttf $FONT_ENTRY_3
        fi
    fi
esac



exit 0
