#!/bin/sh
#
# Copyright © 2005 Ryan Murray <rmurray@debian.org>
# Copyright © 2009 Thibaut VARÈNE <varenet@debian.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#######################################################################

cleanup() {
        rm -f ~/NO-DAEMON-PLEASE
}

touch ~/NO-DAEMON-PLEASE
trap cleanup 0

touch ~/EXIT-DAEMON-PLEASE
echo -n Waiting for sbuild and buildd to exit...
while [ -f ~/EXIT-DAEMON-PLEASE ]; do
        sleep 10
done
echo .

schroot -a -u root -d /root -- apt-get update
echo Upgrading chroots:
schroot -a -u root -d /root -- apt-get dist-upgrade -y
echo Cleaning chroots:
schroot -a -u root -d /root -- apt-get autoremove -y
schroot -a -u root -d /root -- debfoster -f

