# This override plugin is intended primarily to serve during installation,
# where we can safely assume an existing LTSP chroot is not used.

case "$MODE" in
    commandline)
        add_option "purge-chroot" "purge exiting LTSP chroot if present" "advanced" "false"
        ;;
    configure)
        if [ "true" = "$LTSP_CDROM_INSTALL" ] && [ -z "$option_purge_chroot_value" ]; then
            # FIXME: this assumes that a CD install is a debian-installer
            # install, which may not always be the case
            option_purge_chroot_value="true"
        fi
        ;;
    before-install)
        ROOT=$BASE/$CHROOT
        if [ "true" = "$option_purge_chroot_value" ] && [ -d "$ROOT" ]; then
            # wipe it out, so we can try again
            rm --one-file-system --force --recursive $ROOT
        fi
        # use the default behavior
        . /usr/share/ltsp/plugins/ltsp-build-client/common/020-rootpath
        ;;
esac
