#!/bin/sh
# (c) Copyright 2002-2011. CodeWeavers, Inc.
set -e
# Setup logging
if [ -n "$CX_LOG" ]
then
[ "$CX_LOG" = "-" ] || exec 2>>"$CX_LOG"
echo >&2
echo "***** `date`" >&2
echo "Starting: $0 $@" >&2
set -x
fi
# Note:
# - 'dpkg --purge' may call this script twice: first with action=remove
# and then with action=purge
action="$1"
CX_ROOT="/opt/@product_id@"
export CX_ROOT
if [ -f "$CX_ROOT/.productid" ]
then
productid=`cat "$CX_ROOT/.productid"`
else
productid="@product_id@"
fi
if [ \( "$action" = "purge" -o "$action" = "remove" \) -a ! -f "$CX_ROOT/bin/cxmenu" ]
then
if [ "$action" = "purge" ]
then
CX_PURGE="all"
else
CX_PURGE="desktopdata"
fi
# We cannot do this bit before because prerm does not know whether
# the administrator is doing a 'dpkg --purge' or a 'dpkg --remove'.
# It does mean we have some extra directories to remove manually.
# This script expects CX_ROOT and productid to be set
if [ -z "$CX_PURGE" ]
then
CX_PURGE="all"
fi
if [ "$CX_PURGE" = "desktopdata" -o "$CX_PURGE" = "all" ]
then
rm -rf "$CX_ROOT"/support/desktopdata
fi
if [ "$CX_PURGE" = "all" ]
then
rm -f "$CX_ROOT/etc/$productid".conf*
rm -f "$CX_ROOT/etc/license.txt" "$CX_ROOT/etc/license.sig"
rm -f "$CX_ROOT"/support/default
rm -rf "$CX_ROOT"/support/installers
rm -f "$CX_ROOT"/.uninstalled
# Delete bottles.
ls -d "$CX_ROOT"/support/*/cxbottle.conf 2>/dev/null | while read bottlefile
do
dir=`dirname "$bottlefile"`
rm -rf "$dir"
done
rmdir "$CX_ROOT"/support 2>/dev/null || true
rm -f "$CX_ROOT/.productid"
elif [ -d "$CX_ROOT" ]
then
touch "$CX_ROOT/.uninstalled"
fi
rmdir "$CX_ROOT/etc" 2>/dev/null || true
rmdir "$CX_ROOT/support" 2>/dev/null || true
rmdir "$CX_ROOT" 2>/dev/null || true
fi
#DEBHELPER#