#!/bin/bash
                                  # image_setup.sh -
                                  # jdm corrected version
                                  # (maintains original config.)
				  # Comments start in col. 35.

usage()
{
    echo "Usage: $0 dev_img_location mount_point"
}

if [ $# -lt 2 ] ; then usage ; exit 1 ; fi

DEVELOP=/home/zaurus/develop

echo "Setting mount point $2..."
echo "$1 $2 squashfs loop,noauto 0 0" >> /etc/fstab

mkdir $DEVELOP 2> /dev/null
ln -sf $DEVELOP $2

echo "Mounting image $1..."
mount $2

if [ "`mount | grep $DEVELOP`" = "" ]; then
    echo "Failed to mount image $1 on $2"
    exit 1
fi

echo "Setting up compiler..."
TMAKEPATH=/usr/local/tmake/lib/linux-g++
echo "export TMAKEPATH=/usr/local/tmake/lib/linux-g++" >> /home/zaurus/.profile
echo "export TMAKEPATH=/usr/local/tmake/lib/linux-g++" >> /home/root/.profile

echo "export PATH=\$PATH:$2/bin" >> /home/zaurus/.profile
echo "export PATH=\$PATH:$2/bin" >> /home/root/.profile

$DEVELOP/bin/compiler_setup.sh
echo "Image setup complete."

exit 0