#! /bin/sh

set -e

. /usr/share/debconf/confmodule

CONFDIR=/etc/fonts/conf.d

wqy_old_conf="70-debconf-wqy.conf"
wqy_conf="85-xfonts-wqy.conf"

if [ -z "$2" ]; then
	FIRSTINST=yes
fi

if [ -z "$FIRSTINST" ] && [ ! -h $CONFDIR/$wqy_conf ] && [ ! -h $CONFDIR/$wqy_old_conf ]; then
	# We are upgrading and no previous link
	enable_wqy="false"
else
	# First install or already linked
	enable_wqy="true"
fi

if [ "$1" = "configure" ]; then
	# if we're upgrading from an old version without fontconfig stuff.
	if [ -z "$FIRSTINST" ] && dpkg --compare-versions "$2" le 0.7.0-5-1; then
		enable_wqy="true"
	fi
fi

db_set xfonts-wqy/enable_wqy "$enable_wqy"

db_input low xfonts-wqy/enable_wqy || true
db_go
