1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-23 00:43:28 +00:00
freebsd-ports/java/javavmwrapper/pkg-deinstall
Jung-uk Kim ea1e79cd5a Fix deinstallation script for 7.x. -samefile option for find(1) does not
exist there.

Reviewed by:	glewis (maintainer)
Feature safe:	yes
2012-11-02 17:12:08 +00:00

55 lines
1.3 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
# Run this script at the pre-deinstall stage
if [ "x${2}" != "xDEINSTALL" ]; then
exit 0
fi
# The option configuration file
OPTION_CONF="${PKG_PREFIX}/etc/javavm_opts.conf"
# Remove the option configuration file if its identical to the
# distributed version.
if [ -f "${OPTION_CONF}" -a -f "${OPTION_CONF}.dist" ]; then
if [ `sed -e '/^#/d' -e '/^\s*$/d' "${OPTION_CONF}" | sort | md5` = \
`sed -e '/^#/d' -e '/^\s*$/d' "${OPTION_CONF}.dist" | sort | md5` ]; then
rm -f "${OPTION_CONF}"
fi
fi
# Destroy the symbolic links that were created for every executable for a VM.
_excl_links='checkvms manvm registervm unregistervm'
_find_expr='-depth 1 -type l'
for i in ${_excl_links}; do
_find_expr="${_find_expr} ! -name ${i}"
done
_javavm_path=`realpath ${PKG_PREFIX}/bin/javavm`
for i in `find ${PKG_PREFIX}/bin ${_find_expr}`; do
if [ "${_javavm_path}" = `realpath ${i}` ]; then
rm -f "${i}"
fi
done
# The configuration file
CONF="${PKG_PREFIX}/etc/javavms"
# Ensure the configuration file exists
if [ ! -f "${CONF}" ]; then
exit 0
fi
# Ensure the configuration file has the correct permissions
if [ ! -r "${CONF}" ]; then
echo "error: can't read configuration file ${CONF}" 1>&2
exit 1
fi
# Remove the configuration file.
rm -f "${CONF}"
exit 0