#!/bin/sh
# $FreeBSD: ports/japanese/alias-fonts/pkg-deinstall,v 1.6 2011/09/19 14:45:01 tota Exp $

if [ $2 != "DEINSTALL" ]; then
  exit 0
fi

dir="${PKG_PREFIX}/lib/X11/fonts/local";
to="$dir/fonts.alias";
from="$to.orig";

if ! mv $to $from; then
  echo "Couldn't rename $to."
  exit 1
fi

IFS="
"

while read line; do
  trimmed=${line# *}
  case $trimmed in
    -alias-*) ;;
    *) echo $line;;
  esac
done < $from > $to
