#
# Script file to make application image.
#
# Copyright (c) Realtek Semiconductor Inc. 2003
#
#  Usage: 
#    -b block_size, specify the block size to fit in all application image.
#	Each block is in 1024 bytes.
#    -s app_script, specify the script file to build file system for target.
#    -o output_file, specify the output filename
#
# $Id: mk6104ipc,v 1.1.1.1 2003/12/30 10:08:44 lance Exp $
#

CURRDIR=`pwd`
MKTOP=$CURRDIR/top.6104ipc
TMPIMG=$CURRDIR/tmpimg.img
RAMDISKSIZE=5120
MOUNTPOINT=$CURRDIR/mnt.gw
KERNEL_TOP=`cd ../..;pwd`

TARGETIMAGE=$KERNEL_TOP/linux-2.4.18/arch/mips/ramdisk/ramdisk.bz2
#TARGETIMAGE=$KERNEL_TOP/linux-2.4.18-gw/appimg/appimg

if [ -d $MOUNTPOINT ]; then
	echo ""
else
	mkdir $MOUNTPOINT
fi

./app_6104ipc_script

#./buildfs -b 5020 -s app_gw_script -o ../../linux-2.4.18/appimg/appimg

rm -f $TMPIMG
dd if=/dev/zero of=$TMPIMG bs=1k count=$RAMDISKSIZE
/sbin/mke2fs -vFm0 $TMPIMG $RAMDISKSIZE
mount -o loop $TMPIMG $MOUNTPOINT
cp -a $MKTOP/* $MOUNTPOINT
cd $MOUNTPOINT
chown -R root.root *
cd $CURRDIR
#gzip -9vfc $TMPIMG > $TARGETIMAGE
#gzip -9vfc tmpimg.img > aa 
umount $MOUNTPOINT || exit 1
rm -rf $MOUNTPOINT
#gzip -9vfc $TMPIMG > $TARGETIMAGE
#gzip -9vfc $TMPIMG > tmp.gz 
bzip2 -9vfc $TMPIMG > $TARGETIMAGE
#rm -f $TMPIMG
