#!/bin/sh
# invoke shell if build fails.

if [ "$EDITOR" = "" ]; then
    EDITOR="vim-tiny"
fi

echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!!!                                  !!!!"
echo "!!!!           **FTBFS**              !!!!"
echo "!!!!                                  !!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "DROPPING TO SHELL"
echo ""

apt-get install -y --force-yes $EDITOR less bash
if [ "$?" != "0" ]; then
    apt-get install -y --force-yes vim-tiny less bash
fi

cd /tmp/buildd/*/debian/..

echo ""
echo ""
echo "Use ... dpkg-buildpackage -us -uc -nc ... to restart build."
echo ""
echo "Please note that this will not copy the debs outside this chroot,"
echo "if you want them, you will have to copy them yourself."
echo ""
echo "To invoke any hook use /tmp/hooks/NAMEOFHOOK."
echo ""
echo ""

/bin/bash < /dev/tty > /dev/tty 2> /dev/tty
