#!/bin/bash
#
# Copyright (C) 2013 - apps.embedded@gmail.com
# 
# This file is part of R Console.
#
# R Console 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.
#
# R Console 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 R Console.  If not, see <http://www.gnu.org/licenses/>.
#

ROOTFS=/home/debian-arm/Documents/apps/R/rootfs

# create minimum rootfs based on Debian wheezy
mkdir -p $ROOTFS
sudo debootstrap --variant=minbase wheezy $ROOTFS

pushd $ROOTFS/../

# install packages for managing the graphics
sudo chroot ./rootfs apt-get install xvfb x11vnc

# install packages for cran packages installation
sudo chroot ./rootfs apt-get install gcc gfortran g++
sudo chroot ./rootfs apt-get install libcurl3-dev
sudo chroot ./rootfs apt-get install libxml2-dev
sudo chroot ./rootfs apt-get install libtool autoconf automake
sudo chroot ./rootfs apt-get install make

# configure en_US.UTF-8 locale
sudo chroot ./rootfs apt-get install locales
sudo chroot ./rootfs dpkg-reconfigure locales

# configure tzdata America / New York
sudo chroot ./rootfs dpkg-reconfigure tzdata

# clean rootfs from downloaded packages
sudo chroot ./rootfs apt-get clean
sudo chroot ./rootfs apt-get autoclean
sudo chroot ./rootfs apt-get autoremove

# make the whole rootfs readable
sudo chmod -R a+r $ROOTFS

popd

