#!/bin/sh # # Copyright (C) 2013 Daniel Francis # # 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. check_root () { echo "#############################" echo "Checking for root permissions" echo "#############################" if [ `whoami` != root ]; then echo $0 ": Need to run as root. Stopping." exit fi echo "##### OK #####" } clean_install () { echo "##########################" echo "Cleaning install directory" echo "##########################" if [ -d ./install ]; then rm -Rf ./install fi mkdir install echo "[OK]" } copy_files () { echo "#############" echo "Copying files" echo "#############" cp sources.list install/etc/apt/ cp sugar-env-setup.sh install/usr/bin/ cp sugar-build-clone.sh install/usr/bin/ cp sugar-build-command install/usr/bin/ cp install/etc/bash.bashrc install/root/.bashrc echo "##### OK #####" } create_symlinks () { echo "#######################" echo "Creating symbolic links" echo "#######################" ln -s install/home/sugar/sugar-build/source ./source mkdir install/home/sugar/sugar-build/activities ln -s install/home/sugar/sugar-build/activities ./activities echo "##### OK #####" } # Installation function installenv () { check_root clean_install echo "######################" echo "Installing base system" echo "######################" debootstrap --variant=buildd quantal ./install http://archive.ubuntu.com/ubuntu/ copy_files ./sugar-chroot install sugar-env-setup.sh create_symlinks } chrootshell () { check_root ./sugar-chroot install su sugar } # Help message usage () { echo "Usage:" echo $0 install - Install the environment and build Sugar echo $0 shell - A virtual shell to run Sugar echo $0 help - Show this help message and exit } #Check for arguments case $1 in install) installenv ;; shell) chrootshell ;; symlinks) create_symlinks ;; *) usage ;; esac