#!/bin/sh
# ESP Package Manager v3.7.0

# Use postrun command on Solaris where available (OpenSolaris)
if [ -x $PKG_INSTALL_ROOT/usr/lib/postrun ]; then
( echo "test -x \"$CLIENT_BASEDIR/opt/ooo-dev3/program/unopkg\" || exit 0"
  echo "cd \"$CLIENT_BASEDIR/opt/ooo-dev3/program\""
  echo "umask 022"
  echo "\"$CLIENT_BASEDIR/opt/ooo-dev3/program/unopkg\" sync"
  echo  "find \"$CLIENT_BASEDIR/opt/ooo-dev3/share/prereg/bundled\" -type f -exec chmod 644 {} \\;"
) | $PKG_INSTALL_ROOT/usr/lib/postrun -c UNOPKG
else
  # No postrun available, try running unopkg directly
  test -x $BASEDIR/opt/ooo-dev3/program/unopkg || exit 0  
  "$BASEDIR/opt/ooo-dev3/program/unopkg" sync
  echo  "find \"$BASEDIR/opt/ooo-dev3/share/prereg/bundled\" -type f -exec chmod 644 {} \\;"
  if [ "$?" != "0" ]; then
    echo "\nERROR: Removal of UNO extension failed."
    test "$BASEDIR" = "$CLIENT_BASEDIR" || echo "ERROR: alternate root uninstall requires SUNWpostrun package to be installed"
    echo 'ERROR: Make sure the runtime requirements (operating system, patch level, architecture) are met.'
    exit 1
  fi
fi


exit 0  
