#!/bin/sh
if test "$2" = "POST-INSTALL"; then
  YS=$PKG_PREFIX/share/yorick
  YH=$PKG_PREFIX/lib/yorick
  x=`grep "^Y_HOME=$YH" $YH/Make.cfg`
  if test -z "$x"; then
    YB=$PKG_PREFIX/lib/yorick/bin
    ln -sf $YB/gist $PKG_PREFIX/bin/gist
    ln -sf $YB/yorick $PKG_PREFIX/bin/yorick
    s="s%^...set_site,.*%set_site, \"$YS\", \"$YH\"\\;%"
    sed -e "$s" $YB/paths.i >$YB/paths.tmp
    mv -f $YB/paths.tmp $YB/paths.i
    sed -e "s%^Y_SITE=.*%Y_SITE=$YS%g" $YH/Make.cfg >$YH/Makecfg.tmp
    rm -f $YH/Maketmpl
    sed -e "s%^Y_HOME=.*%Y_HOME=$YH%g" $YH/Makecfg.tmp >$YH/Make.cfg
    rm -f $YH/Makecfg.tmp
  fi
fi
true
