# vim: filetype=sh

finalize_fs()
{
    fs_tree="$(cd "$1"; pwd)"
    cd "$fs_tree"

    # clean up
    rm -rf proc/* sys/* dev/* tmp/* \
            $(find run -type f) $(ls -1d var/cache/* | grep -v 'debconf$') var/lock

    # install debootstick init hook on getty command
    getty_command="$(realpath --relative-to . "$(readlink -f sbin/getty)")"
    mv "$getty_command" "${getty_command}.orig"
    ln -s /opt/debootstick/live/init/getty-hook.sh "$getty_command"
    echo "GETTY_COMMAND=$getty_command" >> dbstck.conf
}
