File install-geogebra of Package geogebra

#!/bin/bash
#---------------------------------------------
# Script to install GeoGebra
#
# @author Christian Schött <schoett@gmx.de>
#---------------------------------------------

#---------------------------------------------
# Used environment variables:
#
# NAME=<name of geogebra start script> # If unset, 'geogebra' will be used. (Example: 'geogebra5-beta')
#
# DESCRIPTION=<application name shown by desktop file> # If unset, 'GeoGebra' will be used. (Example: 'GeoGebra 5.0 Beta')
#
# ARCH=[<32>|<64>|<arm>] # If unset, '32' (32bit) will be used.
#
# INSTALL=<path of install macro> # If unset, './install-sh' will be used. (Distributors may want to set their own install macro.)
#
# CHMOD=<path of chmod macro> # If unset, 'chmod' will be used. (Distributors may want to set their own chmod macro.)
#
# BINDIR=<path for executable binary files> # If unset, 'usr/bin' will be used.
#
# USE_ABSOLUTE_PATH_OF_BINDIR=<boolean> # If unset, 'false' will be used.
#
# DATADIR=<path for data files> # If unset, '/usr/share' will be used.
#
# DOCDIR=<path for doc files> # If unset, '/usr/share/doc/packages' will be used.
#
# LICENSEDIR=<path for license files> # If unset, "$DOCDIR" will be used.
#
# LIBDIR=<path for libraries> # If unset, '/usr/lib' will be used.
#
# SYSCONFDIR=<path for sysconfig files> # If unset, '/etc' will be used.
#
# USE_SYSCONFDIR=<boolean> # If unset, 'true' will be used.
#
# VERSION_CHECK_ALLOW=<boolean> # If unset, 'true' will be used.
#
# CREATE_UNINSTALLER=<boolean> # If unset, 'false' will be used. (Distributors normally have their own uninstaller.)
#
# VERBOSE_MODE=<boolean> # If unset, 'false' will be used.
#
# PORTABLE=<boolean> # If unset, 'false' will be used.
#
# PREFIX=<path> # If unset, '' will be used.

#---------------------------------------------
# If $NAME not set, use 'geogebra'.

if [ -z "$NAME" ]; then
	NAME='geogebra'
fi

#---------------------------------------------
# If $DESCRIPTION not set, use 'GeoGebra'.

if [ -z "$DESCRIPTION" ]; then
	DESCRIPTION='GeoGebra'
fi

#---------------------------------------------
# If $ARCH not set, use '32'.

if [ -z "$ARCH" ]; then
	ARCH='32'
fi

#---------------------------------------------
# If $INSTALL not set, use './install-sh'.

if [ -z "$INSTALL" ]; then
	INSTALL='./install-sh'
fi

#---------------------------------------------
# If $CHMOD not set, use 'chmod'.

if [ -z "$CHMOD" ]; then
	CHMOD='chmod'
fi

#---------------------------------------------
# If $BINDIR not set, use '/usr/bin'.

if [ -z "$BINDIR" ]; then
	BINDIR='/usr/bin'
fi

#---------------------------------------------
# If $USE_ABSOLUTE_PATH_OF_BINDIR not set, use 'false'.

if [ -z "$USE_ABSOLUTE_PATH_OF_BINDIR" ]; then
	USE_ABSOLUTE_PATH_OF_BINDIR='false'
fi

#---------------------------------------------
# If $DATADIR not set, use '/usr/share'.

if [ -z "$DATADIR" ]; then
	DATADIR='/usr/share'
fi

#---------------------------------------------
# If $LICENSEDIR not set, but $DOCDIR set, use "$DOCDIR".
 
if [ -z "$LICENSEDIR" -a -n "$DOCDIR" ]; then
	LICENSEDIR="$DOCDIR"
fi

#---------------------------------------------
# If $DOCDIR not set, use '/usr/share/doc/packages'.

if [ -z "$DOCDIR" ]; then
	DOCDIR='/usr/share/doc/packages'
fi

#---------------------------------------------
# If $LICENSEDIR not set, use "$DOCDIR".

if [ -z "$LICENSEDIR" ]; then
	LICENSEDIR="$DOCDIR"
fi

#---------------------------------------------
# If $LIBDIR not set, use '/usr/lib'.

if [ -z "$LIBDIR" ]; then
	LIBDIR='/usr/lib'
fi

#---------------------------------------------
# If $SYSCONFDIR not set, use '/etc'.

if [ -z "$SYSCONFDIR" ]; then
	SYSCONFDIR='/etc'
fi

#---------------------------------------------
# If $USE_SYSCONFDIR not set, use 'true'.

if [ -z "$USE_SYSCONFDIR" ]; then
	USE_SYSCONFDIR='true'
fi

#---------------------------------------------
# If $VERSION_CHECK_ALLOW not set, use 'true'.

if [ -z "$VERSION_CHECK_ALLOW" ]; then
	VERSION_CHECK_ALLOW='true'
fi

#---------------------------------------------
# If $CREATE_UNINSTALLER not set, use 'false'.

if [ -z "$CREATE_UNINSTALLER" ]; then
	CREATE_UNINSTALLER='false'
fi

#---------------------------------------------
# If $VERBOSE_MODE not set, use 'false'.

if [ -z "$VERBOSE_MODE" ]; then
	VERBOSE_MODE='false'
fi

#---------------------------------------------
# If $PORTABLE not set, use 'false'.

if [ -z "$PORTABLE" ]; then
	PORTABLE='false'
fi

#---------------------------------------------
# If $PREFIX not set, use ''.

if [ -z "$PREFIX" ]; then
	PREFIX=''
fi

#---------------------------------------------
# Define usage function.

function func_usage
{
	cat << _USAGE
Usage: install-geogebra [Options]

Install GeoGebra

Options:
  --help                                                  Print this help message
  --name=<name of geogebra start script>                  If unset, '$NAME' will be used. (Example: 'geogebra5-beta')
  --description=<application name shown by desktop file>  If unset, '$DESCRIPTION' will be used. (Example: 'GeoGebra 5.0 Beta')
  --arch=[<32>|<64>|<arm>]                                If unset, '$ARCH' will be used.
  --install=<path of install macro>                       If unset, '$INSTALL' will be used.
  --chmod=<path of chmod macro>                           If unset, '$CHMOD' will be used.
  --bindir=<path for executable binary files>             If unset, '$BINDIR' will be used.
  --use_absolute_path_of_bindir=<boolean>                 If unset, '$USE_ABSOLUTE_PATH_OF_BINDIR' will be used.
  --datadir=<path for data files>                         If unset, '$DATADIR' will be used.
  --docdir=<path for doc files>                           If unset, '$DOCDIR' will be used.
  --licensedir=<path for license files>                   If unset, '$LICENSEDIR' will be used.
  --libdir=<path for libraries>                           If unset, '$LIBDIR' will be used.
  --sysconfdir=<path for sysconfig files>                 If unset, '$SYSCONFDIR' will be used.
  --use_sysconfdir=<boolean>                              If unset, '$USE_SYSCONFDIR' will be used.
  --version_check_allow=<boolean>                         If unset, '$VERSION_CHECK_ALLOW' will be used.
  --create_uninstaller=<boolean>                          If unset, '$CREATE_UNINSTALLER' will be used.
  --verbose_mode=<boolean>                                If unset, '$VERBOSE_MODE' will be used.
  --portable=<boolean>                                    If unset, '$PORTABLE' will be used.
  --prefix=<path>                                         If unset, '$PREFIX' will be used.
_USAGE
}

#---------------------------------------------
# Check for options.

for i in "$@"; do
	case "$i" in
	--help | --hel | --he | --h )
		func_usage; exit 0 ;;
	esac
	if [ $(expr match "$i" '.*--name=') -ne 0 ]; then
		NAME=${i:7}
		shift $((1))
	elif [ $(expr match "$i" '.*--description=') -ne 0 ]; then
		DESCRIPTION=${i:14}
		shift $((1))
	elif [ $(expr match "$i" '.*--arch=') -ne 0 ]; then
		ARCH=${i:7}
		shift $((1))
	elif [ $(expr match "$i" '.*--install=') -ne 0 ]; then
		INSTALL=${i:10}
		shift $((1))
	elif [ $(expr match "$i" '.*--chmod=') -ne 0 ]; then
		CHMOD=${i:8}
		shift $((1))
	elif [ $(expr match "$i" '.*--bindir=') -ne 0 ]; then
		BINDIR=${i:9}
		shift $((1))
	elif [ $(expr match "$i" '.*--use_absolute_path_of_bindir=') -ne 0 ]; then
		USE_ABSOLUTE_PATH_OF_BINDIR=${i:30}
		shift $((1))
	elif [ $(expr match "$i" '.*--datadir=') -ne 0 ]; then
		DATADIR=${i:10}
		shift $((1))
	elif [ $(expr match "$i" '.*--docdir=') -ne 0 ]; then
		DOCDIR=${i:9}
		shift $((1))
	elif [ $(expr match "$i" '.*--licensedir=') -ne 0 ]; then
		LICENSEDIR=${i:13}
		shift $((1))
	elif [ $(expr match "$i" '.*--libdir=') -ne 0 ]; then
		LIBDIR=${i:9}
		shift $((1))
	elif [ $(expr match "$i" '.*--sysconfdir=') -ne 0 ]; then
		SYSCONFDIR=${i:13}
		shift $((1))
	elif [ $(expr match "$i" '.*--use_sysconfdir=') -ne 0 ]; then
		USE_SYSCONFDIR=${i:17}
		shift $((1))
	elif [ $(expr match "$i" '.*--version_check_allow=') -ne 0 ]; then
		VERSION_CHECK_ALLOW=${i:22}
		shift $((1))
	elif [ $(expr match "$i" '.*--create_uninstaller=') -ne 0 ]; then
		CREATE_UNINSTALLER=${i:21}
		shift $((1))
	elif [ $(expr match "$i" '.*--verbose_mode=') -ne 0 ]; then
		VERBOSE_MODE=${i:15}
		shift $((1))
	elif [ $(expr match "$i" '.*--portable=') -ne 0 ]; then
		PORTABLE=${i:11}
		shift $((1))
	elif [ $(expr match "$i" '.*--prefix=') -ne 0 ]; then
		PREFIX=${i:9}
		shift $((1))
	fi
done

#---------------------------------------------
# Install everything.

INSTALLED_DIRECTORIES=()
INSTALLED_FILES=()

function install_dir
{
	if [ ! -w "$PREFIX$1" ]; then
		"$INSTALL" -d -m 755 "$PREFIX$1"
	fi
	INSTALLED_DIRECTORIES[${#INSTALLED_DIRECTORIES[*]}]="$1"
}

function install_file
{
	if [ -d "$PREFIX$2" ]; then
		"$INSTALL" -m 644 "$1" "$PREFIX$2"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$2/`basename $1`"
	else
		"$INSTALL" -m 644 "$1" "$PREFIX$2"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$2"
	fi
}

install_dir "$BINDIR"
cat > "$PREFIX$BINDIR/$NAME" << EOF
#!/bin/bash
#---------------------------------------------
# Script to start GeoGebra
#---------------------------------------------

#---------------------------------------------
# Export name of this script

export GG_SCRIPTNAME=\$(basename \$0)`if [ "$USE_SYSCONFDIR" = 'true' ]; then echo -e "\n\n#---------------------------------------------\n# Export path of system directory containing geogebra.conf\n\nexport GG_SYS_CONFIG_PATH='$SYSCONFDIR/$NAME'"; fi``if [ -e "jre64" -o -e "jre32" -o -e "jrearm" ]; then echo -e "\n\n#---------------------------------------------\n# Export Java Command\n\nexport JAVACMD='$LIBDIR/$NAME/jre/bin/java'"; fi`

#---------------------------------------------
# Export allowance of version check

`if [ "$VERSION_CHECK_ALLOW" = 'false' ]; then echo "export GG_VERSIONCHECKALLOW='false'"; else echo "export GG_VERSIONCHECKALLOW='true'"; fi`

#---------------------------------------------
# Run

exec "$DATADIR/$NAME/geogebra" --joglVersion=2 "\$@"
EOF
INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$BINDIR/$NAME"
"$CHMOD" 755 "$PREFIX$BINDIR/$NAME"
install_dir "$DATADIR"
install_dir "$DATADIR/applications"

# Look for translations inside the example desktop file included
# in this package, to create an appropriate desktop file:
DESKTOPFILE_LINES=()
while read DESKTOPFILE; do
	if [ $(expr match "$DESKTOPFILE" '.*GenericName') -ne 0 ]; then
		DESKTOPFILE_LINES[${#DESKTOPFILE_LINES[*]}]="$DESKTOPFILE"
	elif [ $(expr match "$DESKTOPFILE" '.*Comment') -ne 0 ]; then
		DESKTOPFILE_LINES[${#DESKTOPFILE_LINES[*]}]="$DESKTOPFILE"
	fi
done < "geogebra.desktop"
cat > "$PREFIX$DATADIR/applications/$NAME.desktop" << EOF
[Desktop Entry]
Name=$DESCRIPTION
`IFS=$'\n'; for LINE in ${DESKTOPFILE_LINES[*]}; do echo "$LINE"; done; unset IFS`
TryExec=`if [ "$USE_ABSOLUTE_PATH_OF_BINDIR" = 'true' ]; then echo "$BINDIR/$NAME"; else echo "$NAME"; fi`
Exec=`if [ "$USE_ABSOLUTE_PATH_OF_BINDIR" = 'true' ]; then echo "$BINDIR/$NAME %F"; else echo "$NAME %F"; fi`
Icon=$NAME
Terminal=false
Type=Application
StartupNotify=true
StartupWMClass=geogebra-GeoGebra
Categories=Education;Science;Math;
MimeType=application/vnd.geogebra.file;application/vnd.geogebra.tool;
EOF
INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$DATADIR/applications/$NAME.desktop"

install_dir "$LICENSEDIR"
install_dir "$LICENSEDIR/$NAME"
install_file "_LICENSE.txt" "$LICENSEDIR/$NAME/COPYING"
if [ "$USE_SYSCONFDIR" = 'true' ]; then
	install_dir "$DOCDIR"
	install_dir "$DOCDIR/$NAME"
	cat > "$PREFIX$DOCDIR/$NAME/README" << EOF
README for GeoGebra
-------------------

The defaults for various options are stored in the default GeoGebra
configuration file $SYSCONFDIR/$NAME/geogebra.conf. You should use
$SYSCONFDIR/$NAME/geogebra.conf.local for your local settings.

Use $SYSCONFDIR/$NAME/geogebra.properties, to set a template for the
settings file of every user. This file must have a newer date than the
settings file in user's home directories, otherwise it will be ignored.
EOF
	INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$DOCDIR/$NAME/README"
fi
if [ "$PORTABLE" = 'true' ]; then
	if [ -e "jre64" -a "$ARCH" = "64" ]; then
		install_dir "$LIBDIR"
		install_dir "$LIBDIR/$NAME"
		install_dir "$LIBDIR/$NAME/jre"
		JRE_FILES=`find "jre64" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/$FILE" "$LIBDIR/$NAME/jre"
		done
		install_dir "$LIBDIR/$NAME/jre/bin"
		JRE_BIN_FILES=`find "jre64/bin" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_BIN_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/bin/$FILE" "$LIBDIR/$NAME/jre/bin"
			"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/bin/$FILE"
		done
		install_dir "$LIBDIR/$NAME/jre/lib"
		JRE_LIB_FILES=`find "jre64/lib" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/$FILE" "$LIBDIR/$NAME/jre/lib"
		done
		"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/lib/jexec"
		install_dir "$LIBDIR/$NAME/jre/lib/amd64"
		JRE_LIB_AMD64_FILES=`find "jre64/lib/amd64" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_AMD64_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/amd64/$FILE" "$LIBDIR/$NAME/jre/lib/amd64"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/amd64/headless"
		install_file "jre64/lib/amd64/headless/libmawt.so" "$LIBDIR/$NAME/jre/lib/amd64/headless"
		install_dir "$LIBDIR/$NAME/jre/lib/amd64/jli"
		install_file "jre64/lib/amd64/jli/libjli.so" "$LIBDIR/$NAME/jre/lib/amd64/jli"
		install_dir "$LIBDIR/$NAME/jre/lib/amd64/server"
		cp -d "jre64/lib/amd64/server/libjsig.so" "$PREFIX$LIBDIR/$NAME/jre/lib/amd64/server"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$LIBDIR/$NAME/jre/lib/amd64/server/libjsig.so"
		install_file "jre64/lib/amd64/server/libjvm.so" "$LIBDIR/$NAME/jre/lib/amd64/server"
		install_file "jre64/lib/amd64/server/Xusage.txt" "$LIBDIR/$NAME/jre/lib/amd64/server"
		install_dir "$LIBDIR/$NAME/jre/lib/amd64/xawt"
		install_file "jre64/lib/amd64/xawt/libmawt.so" "$LIBDIR/$NAME/jre/lib/amd64/xawt"
		install_dir "$LIBDIR/$NAME/jre/lib/cmm"
		JRE_LIB_CMM_FILES=`find "jre64/lib/cmm" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_CMM_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/cmm/$FILE" "$LIBDIR/$NAME/jre/lib/cmm"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/ext"
		JRE_LIB_EXT_FILES=`find "jre64/lib/ext" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_EXT_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/ext/$FILE" "$LIBDIR/$NAME/jre/lib/ext"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/images"
		install_dir "$LIBDIR/$NAME/jre/lib/images/cursors"
		JRE_LIB_IMAGES_CURSORS_FILES=`find "jre64/lib/images/cursors" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_IMAGES_CURSORS_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/images/cursors/$FILE" "$LIBDIR/$NAME/jre/lib/images/cursors"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/management"
		JRE_LIB_MANAGEMENT_FILES=`find "jre64/lib/management" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_MANAGEMENT_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/management/$FILE" "$LIBDIR/$NAME/jre/lib/management"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/security"
		JRE_LIB_SECURITY_FILES=`find "jre64/lib/security" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_SECURITY_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/security/$FILE" "$LIBDIR/$NAME/jre/lib/security"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/servicetag"
		install_file "jre64/lib/servicetag/jdk_header.png" "$LIBDIR/$NAME/jre/lib/servicetag"
	elif [ -e "jre32" -a "$ARCH" = "32" ]; then
		install_dir "$LIBDIR"
		install_dir "$LIBDIR/$NAME"
		install_dir "$LIBDIR/$NAME/jre"
		JRE_FILES=`find "jre32" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/$FILE" "$LIBDIR/$NAME/jre"
		done
		install_dir "$LIBDIR/$NAME/jre/bin"
		JRE_BIN_FILES=`find "jre32/bin" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_BIN_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/bin/$FILE" "$LIBDIR/$NAME/jre/bin"
			"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/bin/$FILE"
		done
		install_dir "$LIBDIR/$NAME/jre/lib"
		JRE_LIB_FILES=`find "jre32/lib" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/$FILE" "$LIBDIR/$NAME/jre/lib"
		done
		"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/lib/jexec"
		install_dir "$LIBDIR/$NAME/jre/lib/cmm"
		JRE_LIB_CMM_FILES=`find "jre32/lib/cmm" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_CMM_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/cmm/$FILE" "$LIBDIR/$NAME/jre/lib/cmm"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/ext"
		JRE_LIB_EXT_FILES=`find "jre32/lib/ext" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_EXT_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/ext/$FILE" "$LIBDIR/$NAME/jre/lib/ext"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/i386"
		JRE_LIB_I386_FILES=`find "jre32/lib/i386" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_I386_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/i386/$FILE" "$LIBDIR/$NAME/jre/lib/i386"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/i386/client"
		cp -d "jre64/lib/i386/client/libjsig.so" "$PREFIX$LIBDIR/$NAME/jre/lib/i386/client"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$LIBDIR/$NAME/jre/lib/i386/client/libjsig.so"
		install_file "jre64/lib/i386/client/libjvm.so" "$LIBDIR/$NAME/jre/lib/i386/client"
		install_file "jre64/lib/i386/client/Xusage.txt" "$LIBDIR/$NAME/jre/lib/i386/client"
		install_dir "$LIBDIR/$NAME/jre/lib/i386/headless"
		install_file "jre64/lib/i386/headless/libmawt.so" "$LIBDIR/$NAME/jre/lib/i386/headless"
		install_dir "$LIBDIR/$NAME/jre/lib/i386/jli"
		install_file "jre64/lib/i386/jli/libjli.so" "$LIBDIR/$NAME/jre/lib/i386/jli"
		install_dir "$LIBDIR/$NAME/jre/lib/i386/server"
		cp -d "jre64/lib/i386/server/libjsig.so" "$PREFIX$LIBDIR/$NAME/jre/lib/i386/server"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$LIBDIR/$NAME/jre/lib/i386/server/libjsig.so"
		install_file "jre64/lib/i386/server/libjvm.so" "$LIBDIR/$NAME/jre/lib/i386/server"
		install_file "jre64/lib/i386/server/Xusage.txt" "$LIBDIR/$NAME/jre/lib/i386/server"
		install_dir "$LIBDIR/$NAME/jre/lib/i386/xawt"
		install_file "jre64/lib/i386/xawt/libmawt.so" "$LIBDIR/$NAME/jre/lib/i386/xawt"
		install_dir "$LIBDIR/$NAME/jre/lib/images"
		install_dir "$LIBDIR/$NAME/jre/lib/images/cursors"
		JRE_LIB_IMAGES_CURSORS_FILES=`find "jre32/lib/images/cursors" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_IMAGES_CURSORS_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/images/cursors/$FILE" "$LIBDIR/$NAME/jre/lib/images/cursors"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/management"
		JRE_LIB_MANAGEMENT_FILES=`find "jre32/lib/management" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_MANAGEMENT_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/management/$FILE" "$LIBDIR/$NAME/jre/lib/management"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/security"
		JRE_LIB_SECURITY_FILES=`find "jre32/lib/security" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_SECURITY_FILES | sed 's/\n/ /g'`; do
			install_file "jre64/lib/security/$FILE" "$LIBDIR/$NAME/jre/lib/security"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/servicetag"
		install_file "jre64/lib/servicetag/jdk_header.png" "$LIBDIR/$NAME/jre/lib/servicetag"
	elif [ -e "jrearm" -a "$ARCH" = "arm" ]; then
		install_dir "$LIBDIR"
		install_dir "$LIBDIR/$NAME"
		install_dir "$LIBDIR/$NAME/jre"
		JRE_FILES=`find "jrearm" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/$FILE" "$LIBDIR/$NAME/jre"
		done
		install_dir "$LIBDIR/$NAME/jre/bin"
		JRE_BIN_FILES=`find "jrearm/bin" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_BIN_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/bin/$FILE" "$LIBDIR/$NAME/jre/bin"
			"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/bin/$FILE"
		done
		install_dir "$LIBDIR/$NAME/jre/lib"
		JRE_LIB_FILES=`find "jrearm/lib" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/$FILE" "$LIBDIR/$NAME/jre/lib"
		done
		"$CHMOD" 755 "$PREFIX$LIBDIR/$NAME/jre/lib/jexec"
		install_dir "$LIBDIR/$NAME/jre/lib/arm"
		JRE_LIB_ARM_FILES=`find "jrearm/lib/arm" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_ARM_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/arm/$FILE" "$LIBDIR/$NAME/jre/lib/arm"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/arm/headless"
		install_file "jrearm/lib/arm/headless/libmawt.so" "$LIBDIR/$NAME/jre/lib/arm/headless"
		install_dir "$LIBDIR/$NAME/jre/lib/arm/jli"
		install_file "jrearm/lib/arm/jli/libjli.so" "$LIBDIR/$NAME/jre/lib/arm/jli"
		install_dir "$LIBDIR/$NAME/jre/lib/arm/server"
		cp -d "jrearm/lib/arm/server/libjsig.so" "$PREFIX$LIBDIR/$NAME/jre/lib/arm/server"
		INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$LIBDIR/$NAME/jre/lib/arm/server/libjsig.so"
		install_file "jrearm/lib/arm/server/libjvm.so" "$LIBDIR/$NAME/jre/lib/arm/server"
		install_file "jrearm/lib/arm/server/Xusage.txt" "$LIBDIR/$NAME/jre/lib/arm/server"
		install_dir "$LIBDIR/$NAME/jre/lib/arm/xawt"
		install_file "jrearm/lib/arm/xawt/libmawt.so" "$LIBDIR/$NAME/jre/lib/arm/xawt"
		install_dir "$LIBDIR/$NAME/jre/lib/cmm"
		JRE_LIB_CMM_FILES=`find "jrearm/lib/cmm" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_CMM_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/cmm/$FILE" "$LIBDIR/$NAME/jre/lib/cmm"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/ext"
		JRE_LIB_EXT_FILES=`find "jrearm/lib/ext" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_EXT_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/ext/$FILE" "$LIBDIR/$NAME/jre/lib/ext"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/images"
		install_dir "$LIBDIR/$NAME/jre/lib/images/cursors"
		JRE_LIB_IMAGES_CURSORS_FILES=`find "jrearm/lib/images/cursors" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_IMAGES_CURSORS_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/images/cursors/$FILE" "$LIBDIR/$NAME/jre/lib/images/cursors"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/management"
		JRE_LIB_MANAGEMENT_FILES=`find "jrearm/lib/management" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_MANAGEMENT_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/management/$FILE" "$LIBDIR/$NAME/jre/lib/management"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/security"
		JRE_LIB_SECURITY_FILES=`find "jrearm/lib/security" -maxdepth 1 -type f -printf '%f\n'`
		for FILE in `echo $JRE_LIB_SECURITY_FILES | sed 's/\n/ /g'`; do
			install_file "jrearm/lib/security/$FILE" "$LIBDIR/$NAME/jre/lib/security"
		done
		install_dir "$LIBDIR/$NAME/jre/lib/servicetag"
		install_file "jrearm/lib/servicetag/jdk_header.png" "$LIBDIR/$NAME/jre/lib/servicetag"
	fi
fi
install_dir "$DATADIR/$NAME"
JARS=`ls *".jar"`
for FILE in `echo $JARS | sed 's/\n/ /g'`; do
	install_file "$FILE" "$DATADIR/$NAME"
done
install_file "geogebra" "$DATADIR/$NAME"
"$CHMOD" 755 "$PREFIX$DATADIR/$NAME/geogebra"
if [ -e "unsigned" ]; then
	install_dir "$DATADIR/$NAME/unsigned"
	UNSIGNED_JARS=`ls "unsigned"`
	for FILE in `echo $UNSIGNED_JARS | sed 's/\n/ /g'`; do
		install_file "unsigned/$FILE" "$DATADIR/$NAME/unsigned"
	done
fi
install_dir "$DATADIR/icons"
install_dir "$DATADIR/icons/hicolor"
for SIZE in 16x16 22x22 32x32 48x48 64x64 128x128 256x256; do
	install_dir "$DATADIR/icons/hicolor/$SIZE"
	install_dir "$DATADIR/icons/hicolor/$SIZE/apps"
	install_file "icons/hicolor/$SIZE/apps/geogebra.png" "$DATADIR/icons/hicolor/$SIZE/apps/$NAME.png"
done
if [ "$USE_SYSCONFDIR" = 'true' ]; then
	install_dir "$SYSCONFDIR"
	install_dir "$SYSCONFDIR/$NAME"
	cat > "$PREFIX$SYSCONFDIR/$NAME/geogebra.conf" << EOF
# PLEASE DO NOT CHANGE $SYSCONFDIR/$NAME/geogebra.conf!
# There are chances that your changes will be lost during system upgrades.
# Instead use $SYSCONFDIR/$NAME/geogebra.conf.local for your local settings.


# This is the default GeoGebra configuration file. It shows what the defaults
# for various options happen to be.
#
# If you don't need to change the default, you shouldn't uncomment the line.
# Doing so may cause run-time problems.


# JAVA OPTIONS
# -----------------------------------------------------------------------------

# Set Java command, e.g. '/usr/bin/java'.
#
`if [ "$PORTABLE" = 'true' ]; then echo "#DEFAULT_JAVACMD='$LIBDIR/$NAME/jre/bin/java'"; else echo "#DEFAULT_JAVACMD='java'"; fi`

# Set initial Java heap size, e.g. '32m'.
#
#DEFAULT_GG_XMS='32m'

# Set maximum Java heap size, e.g '512m'.
#
#DEFAULT_GG_XMX='1024m'

# Set native library path, e.g. '/usr/lib/jni'.
#
#DEFAULT_GG_DJAVA_LIBRARY_PATH=''

# Enable/disable the Xrender pipeline (true/false).
#
#DEFAULT_GG_DSUN_JAVA2D_XRENDER=''

# Enable/disable the OpenGL pipeline (true/false).
#
#DEFAULT_GG_DSUN_JAVA2D_OPENGL=''


# GEOGEBRA OPTIONS
# -----------------------------------------------------------------------------

# Enable/disable the splash screen (true/false).
#
#DEFAULT_GG_SHOWSPLASH='false'

# Enable/disable Undo (true/false).
#
#DEFAULT_GG_ENABLEUNDO=''

# Set dots per inch, eg '300' (only used in conjunction with --export).
#
#DEFAULT_GG_DPI='300'

# Turn anti-aliasing on/off (true/false).
#
#DEFAULT_GG_ANTIALIASING=''

# Allow version check (on/off or true/false for single launch).
#
`if [ "$VERSION_CHECK_ALLOW" = 'false' ]; then echo "#DEFAULT_GG_VERSIONCHECKALLOW='false'"; else echo "#DEFAULT_GG_VERSIONCHECKALLOW='true'"; fi`

EOF
	INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$SYSCONFDIR/$NAME/geogebra.conf"
fi

# Create uninstall script, if $CREATE_UNINSTALLER is not set 'false':
if [ "$CREATE_UNINSTALLER" != "false" ]; then
	cat > "$PREFIX$BINDIR/uninstall-$NAME" << EOF
#!/bin/bash
#---------------------------------------------
# Script to uninstall $DESCRIPTION
#---------------------------------------------

# Define usage function:
function func_usage
{
	cat << _USAGE
Usage: uninstall-$NAME [Options]

Uninstall $DESCRIPTION

Options:
  --help         Print this help message
  --force        Uninstall without asking questions
_USAGE
}

# Check for options:
FORCE="false"
for i in "\$@"; do
	case "\$i" in
	--help | --hel | --he | --h )
		func_usage; exit 0 ;;
	esac
	if [ "\$i" = '--force' ]; then
		FORCE="true"
	fi
done

# Look for uninstall scripts of other packages:
if [ -e "$BINDIR/uninstall-$NAME-jogl1" ]; then
	UNINSTALL_geogebra_jogl1=0
fi
if [ -e "$BINDIR/uninstall-$NAME-no3d" ]; then
	UNINSTALL_geogebra_no3d=0
fi
if [ -e "$BINDIR/uninstall-$NAME-icons-oxygen" ]; then
	UNINSTALL_geogebra_icons_oxygen=0
fi
if [ -e "$BINDIR/uninstall-geogebra-mime-data" ]; then
	UNINSTALL_geogebra_mime_data=0
fi
if [ -e "$BINDIR/uninstall-geogebra-mime-data-icons-oxygen" ]; then
	UNINSTALL_geogebra_mime_data_icons_oxygen=0
fi
if [ -e "$BINDIR/uninstall-geogebra-thumbnail-gtk" ]; then
	UNINSTALL_geogebra_thumbnail_gtk=0
fi
if [ -e "$BINDIR/uninstall-geogebra-thumbnail-kde" ]; then
	UNINSTALL_geogebra_thumbnail_kde=0
fi

# Ask to continue, if option --force is not used:
if [ "\$FORCE" = "false" ]; then
	KDIALOG_possible="false"
	QDBUS_possible="false"
	ZENITY_possible="false"
	XDIALOG_possible="false"
	if [ "\$UID" != "0" ]; then
		KDIALOG_possible="true"
		QDBUS_possible="false"
		ZENITY_possible="false"
		XDIALOG_possible="false"
		type -P kdialog &>/dev/null || KDIALOG_possible="false"
		if [ "\$KDIALOG_possible" = "true" ]; then
			QDBUS_possible="true"
			type -P qdbus &>/dev/null || QDBUS_possible="false"
		else
			ZENITY_possible="true"
			type -P zenity &>/dev/null || ZENITY_possible="false"
			if [ "\$ZENITY_possible" = "false" ]; then
				XDIALOG_possible="true"
				type -P Xdialog &>/dev/null || XDIALOG_possible="false"
			fi
		fi
	fi
	ANSWER=1
	if [ "\$KDIALOG_possible" = "true" ]; then
		kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --warningcontinuecancel "This will uninstall $DESCRIPTION\`if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then echo " and\n$DESCRIPTION-JOGL1"; fi\`\`if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then echo " and\n$DESCRIPTION-no3D"; fi\`."
		ANSWER=\$?
	elif [ "\$ZENITY_possible" = "true" ]; then
		zenity --title="$DESCRIPTION" --window-icon="$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --warning --text="This will uninstall $DESCRIPTION\`if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then echo " and\n$DESCRIPTION-JOGL1"; fi\`\`if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then echo " and\n$DESCRIPTION-no3D"; fi\`."
		ANSWER=\$?
	elif [ "\$XDIALOG_possible" = "true" ]; then
		Xdialog --title "$DESCRIPTION" --yesno "This will uninstall $DESCRIPTION\`if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then echo " and\n$DESCRIPTION-JOGL1"; fi\`\`if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then echo " and\n$DESCRIPTION-no3D"; fi\`.\n\nDo you want to continue?" 0 0
		ANSWER=\$?
	else
		echo "This will uninstall $DESCRIPTION\`if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then echo " and $DESCRIPTION-JOGL1"; fi\`\`if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then echo " and $DESCRIPTION-no3D"; fi\`."
		tput bold
		read -p "Do you want to continue? [y/n]: "
		tput sgr0
		case "\$REPLY" in
		y | Y | yes | Yes | YES )
			ANSWER=0 ;;
		esac
	fi
	if [ \$ANSWER != 0 ]; then
		exit 0
	fi
fi

# Ask for uninstallation of other packages, if option --force is not used:
if [ "\$FORCE" = "false" ]; then
	if [ "\$UNINSTALL_geogebra_mime_data" = 0 ]; then
		UNINSTALL_geogebra_mime_data=1
		if [ "\$KDIALOG_possible" = "true" ]; then
			kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --yesno "Do you want to uninstall the Mime database for GeoGebra files, too?"
			UNINSTALL_geogebra_mime_data=\$?
		elif [ "\$ZENITY_possible" = "true" ]; then
			zenity --title="$DESCRIPTION" --window-icon="$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --question --text="Do you want to uninstall the Mime database for GeoGebra files, too?"
			UNINSTALL_geogebra_mime_data=\$?
		elif [ "\$XDIALOG_possible" = "true" ]; then
			Xdialog --title "$DESCRIPTION" --yesno "Do you want to uninstall the Mime database for GeoGebra files, too?" 0 0
			UNINSTALL_geogebra_mime_data=\$?
		else
			tput bold
			read -p "Do you want to uninstall the Mime database for GeoGebra files, too? [y/n]: "
			tput sgr0
			case "\$REPLY" in
			y | Y | yes | Yes | YES )
				UNINSTALL_geogebra_mime_data=0 ;;
			esac
		fi
	fi
	if [ "\$UNINSTALL_geogebra_mime_data_icons_oxygen" = 0 ]; then
		UNINSTALL_geogebra_mime_data_icons_oxygen=1
		if [ "\$KDIALOG_possible" = "true" ]; then
			kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --yesno "Do you want to uninstall GeoGebra MIME type icons for Oxygen Icon Theme, too?"
			UNINSTALL_geogebra_mime_data_icons_oxygen=\$?
		elif [ "\$ZENITY_possible" = "true" ]; then
			zenity --title="$DESCRIPTION" --window-icon="$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --question --text="Do you want to uninstall GeoGebra MIME type icons for Oxygen Icon Theme, too?"
			UNINSTALL_geogebra_mime_data_icons_oxygen=\$?
		elif [ "\$XDIALOG_possible" = "true" ]; then
			Xdialog --title "$DESCRIPTION" --yesno "Do you want to uninstall GeoGebra MIME type icons for Oxygen Icon Theme, too?" 0 0
			UNINSTALL_geogebra_mime_data_icons_oxygen=\$?
		else
			tput bold
			read -p "Do you want to uninstall GeoGebra MIME type icons for Oxygen Icon Theme, too? [y/n]: "
			tput sgr0
			case "\$REPLY" in
			y | Y | yes | Yes | YES )
				UNINSTALL_geogebra_mime_data_icons_oxygen=0 ;;
			esac
		fi
	fi
	if [ "\$UNINSTALL_geogebra_thumbnail_gtk" = 0 ]; then
		UNINSTALL_geogebra_thumbnail_gtk=1
		if [ "\$KDIALOG_possible" = "true" ]; then
			kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --yesno "Do you want to uninstall the GTK+ Thumbnail Creator for GeoGebra files, too?"
			UNINSTALL_geogebra_thumbnail_gtk=\$?
		elif [ "\$ZENITY_possible" = "true" ]; then
			zenity --title="$DESCRIPTION" --window-icon="$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --question --text="Do you want to uninstall the GTK+ Thumbnail Creator for GeoGebra files, too?"
			UNINSTALL_geogebra_thumbnail_gtk=\$?
		elif [ "\$XDIALOG_possible" = "true" ]; then
			Xdialog --title "$DESCRIPTION" --yesno "Do you want to uninstall the GTK+ Thumbnail Creator for GeoGebra files, too?" 0 0
			UNINSTALL_geogebra_thumbnail_gtk=\$?
		else
			tput bold
			read -p "Do you want to uninstall the GTK+ Thumbnail Creator for GeoGebra files, too? [y/n]: "
			tput sgr0
			case "\$REPLY" in
			y | Y | yes | Yes | YES )
				UNINSTALL_geogebra_thumbnail_gtk=0 ;;
			esac
		fi
	fi
	if [ "\$UNINSTALL_geogebra_thumbnail_kde" = 0 ]; then
		UNINSTALL_geogebra_thumbnail_kde=1
		if [ "\$KDIALOG_possible" = "true" ]; then
			kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --yesno "Do you want to uninstall the KDE Thumbnail Creator for GeoGebra files, too?"
			UNINSTALL_geogebra_thumbnail_kde=\$?
		elif [ "\$ZENITY_possible" = "true" ]; then
			zenity --title="$DESCRIPTION" --window-icon="$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --question --text="Do you want to uninstall the KDE Thumbnail Creator for GeoGebra files, too?"
			UNINSTALL_geogebra_thumbnail_kde=\$?
		elif [ "\$XDIALOG_possible" = "true" ]; then
			Xdialog --title "$DESCRIPTION" --yesno "Do you want to uninstall the KDE Thumbnail Creator for GeoGebra files, too?" 0 0
			UNINSTALL_geogebra_thumbnail_kde=\$?
		else
			tput bold
			read -p "Do you want to uninstall the KDE Thumbnail Creator for GeoGebra files, too? [y/n]: "
			tput sgr0
			case "\$REPLY" in
			y | Y | yes | Yes | YES )
				UNINSTALL_geogebra_thumbnail_kde=0 ;;
			esac
		fi
	fi
fi

# Uninstall files and show progressbar during uninstallation, if possible and option --force is not used:
if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
	NUMBER_OF_PACKAGES=1
	if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_icons_oxygen" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_mime_data" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_mime_data_icons_oxygen" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_thumbnail_gtk" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	if [ "\$UNINSTALL_geogebra_thumbnail_kde" = 0 ]; then
		NUMBER_OF_PACKAGES=\$((NUMBER_OF_PACKAGES + 1))
	fi
	DBUSREF=\`kdialog --caption "$DESCRIPTION" --icon "$DATADIR/icons/hicolor/64x64/apps/$NAME.png" --progressbar "Uninstalling $DESCRIPTION." \$NUMBER_OF_PACKAGES\`
fi
INSTALLED_FILES=(${INSTALLED_FILES[*]})
for ((i=\${#INSTALLED_FILES[@]}-1; i>=0; i--)); do
	if [ -w "\${INSTALLED_FILES[\$i]}" ]; then
		rm -f "\${INSTALLED_FILES[\$i]}"
	fi
done
INSTALLED_DIRECTORIES=(${INSTALLED_DIRECTORIES[*]})
for ((i=\${#INSTALLED_DIRECTORIES[@]}-1; i>=0; i--)); do
	case "\${INSTALLED_DIRECTORIES[\$i]}" in
	"$BINDIR" | "$DATADIR" | "$DOCDIR" | "$LICENSEDIR" | "$LIBDIR" | "$SYSCONFDIR" )
		continue ;;
	esac
	if [ -w "\${INSTALLED_DIRECTORIES[\$i]}" ]; then
		rmdir --ignore-fail-on-non-empty "\${INSTALLED_DIRECTORIES[\$i]}"
	fi
done
if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
	qdbus \$DBUSREF Set "" value 1 >/dev/null
	PACKAGE_NUMBER=2
fi

# Uninstall GeoGebra-JOGL1, if exists:
if [ "\$UNINSTALL_geogebra_jogl1" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling $DESCRIPTION-JOGL1." >/dev/null
	fi
	$BINDIR/uninstall-$NAME-jogl1 --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi

# Uninstall GeoGebra-no3D, if exists:
if [ "\$UNINSTALL_geogebra_no3d" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling $DESCRIPTION-no3D." >/dev/null
	fi
	$BINDIR/uninstall-$NAME-no3d --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi

# Uninstall GeoGebra application icons for Oxygen Icon Theme, if exists:
if [ "\$UNINSTALL_geogebra_icons_oxygen" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling GeoGebra application icons for Oxygen Icon Theme." >/dev/null
	fi
	$BINDIR/uninstall-$NAME-icons-oxygen --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi

# Uninstall other packages, if not declined:
if [ "\$UNINSTALL_geogebra_mime_data" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling the Mime database for GeoGebra files." >/dev/null
	fi
	$BINDIR/uninstall-geogebra-mime-data --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi
if [ "\$UNINSTALL_geogebra_mime_data_icons_oxygen" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling GeoGebra MIME type icons for Oxygen Icon Theme." >/dev/null
	fi
	$BINDIR/uninstall-geogebra-mime-data-icons-oxygen --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi
if [ "\$UNINSTALL_geogebra_thumbnail_gtk" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling the GTK+ Thumbnail Creator for GeoGebra files." >/dev/null
	fi
	$BINDIR/uninstall-geogebra-thumbnail-gtk --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
		PACKAGE_NUMBER=\$((PACKAGE_NUMBER + 1))
	fi
fi
if [ "\$UNINSTALL_geogebra_thumbnail_kde" = 0 ]; then
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF setLabelText "Uninstalling the KDE Thumbnail Creator for GeoGebra files." >/dev/null
	fi
	$BINDIR/uninstall-geogebra-thumbnail-kde --force
	if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
		qdbus \$DBUSREF Set "" value \$PACKAGE_NUMBER >/dev/null
	fi
fi
if [ "\$KDIALOG_possible" = "true" -a "\$QDBUS_possible" = "true" -a "\$FORCE" = "false" ]; then
	qdbus \$DBUSREF setLabelText "Uninstallation completed." >/dev/null
	qdbus \$DBUSREF close >/dev/null
fi

# Run update-desktop-database, if possible:
UPDATE_DESKTOP_DATABASE_possible="true"
type -P update-desktop-database &>/dev/null || UPDATE_DESKTOP_DATABASE_possible="false"
if [ "\$UPDATE_DESKTOP_DATABASE_possible" = "true" ]; then
	update-desktop-database -q "$DATADIR/applications"
else
	echo "Could not execute command 'update-desktop-database -q $DATADIR/applications'."
fi

# Uninstall desktop icon, if possible:
XDG_DESKTOP_ICON_possible='true'
type -P xdg-desktop-icon &>/dev/null || XDG_DESKTOP_ICON_possible='false'
if [ "\$XDG_DESKTOP_ICON_possible" = 'true' ]; then
	xdg-desktop-icon uninstall "$NAME.desktop"
fi

# Selfdestruction:
if [ -w "$BINDIR/uninstall-$NAME" ]; then
	rm -f "$BINDIR/uninstall-$NAME"
fi
EOF
	INSTALLED_FILES[${#INSTALLED_FILES[*]}]="$BINDIR/uninstall-$NAME"
	"$CHMOD" u+x "$PREFIX$BINDIR/uninstall-$NAME"
fi

# List pathes of installed files, if $VERBOSE_MODE is not set 'false':
if [ "$VERBOSE_MODE" != "false" ]; then
	echo "`tput smul`Files of package '$NAME'`tput sgr0`"
	for FILEPATH in ${INSTALLED_FILES[*]}; do
		if [ -e "$PREFIX$FILEPATH" ]; then
			echo "$FILEPATH"
		fi
	done
fi