#!/bin/sh
###########################################################################
# Updates the chroot. It doesn't update the image nor the kernels.
#
# Copyright (C) 2010 Alkis Georgopoulos <alkisg@gmail.com>
#
# 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 3 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/>.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.
###########################################################################

# Source the sch-scripts common functions and variables.
if [ ! -f ./scripts/common/common.sh ]; then
    cd /usr/share/sch-scripts
fi
. ./scripts/common/common.sh

# Source the chroot handling functions
. ./scripts/common/chroot.sh

enter_chroot
echo_bold "Updating package information for chroot $ROOT."
if chroot "$ROOT" apt-get update; then 
    echo_bold "Upgrading packages in chroot $ROOT."
    if chroot "$ROOT" apt-get --yes dist-upgrade; then
        echo_bold "Chroot $ROOT updated successfully, remember to update the image afterwards."
    else
        echo_bold "apt-get dist-upgrade was unsuccessful."
    fi
else
    echo_bold "apt-get update was unsuccessful."
fi
exit_chroot
