#!/bin/sh
# an installation script for linux_base

if [ "$2" != "PRE-INSTALL" ]; then
  exit 0
fi

if [ -z "`kldstat -v | grep -E 'linux(aout|elf)'`" ]; then
  echo 'Linux mode is not enabled.'
  echo 'Loading linux kernel module now...'
  if ! kldload linux; then
    echo 'The linux kernel module could not be loaded.'
    echo 'Please enable linux mode manually and retry.'
    exit 1
  fi
fi

if [ ! -f @PREFIX@/usr/share/locale/zh_TW.Big5/LC_CTYPE ] && \
     [ -f @PREFIX@/lib/ld.so ]; then
  echo ----------------------------------------------
  echo You have linux_base installed!
  echo Please remove it before install zh-linux_base.
  echo ----------------------------------------------
  exit 1
fi

if [ -f @PREFIX@/usr/share/locale/zh_TW.Big5/LC_CTYPE ] && \
     [ ! -f @PREFIX@/CLE-0.9p1 ]; then
  echo --------------------------------------------------------------------
  echo You have previous release of zh-linux_base or zh-CLE_base installed!
  echo Please remove it before install this version.
  echo --------------------------------------------------------------------
  exit 1
fi

exit 0
