#!/bin/sh


check_dir ()
{
   if [ ! -d $1 ]; then
      echo
      echo "Could not find directory $1"
      echo
      exit 0
   fi
   echo "Found $1"
}


link_file ()
{
   if [ -h $2 ]; then
      rm -f $2
   fi

   if [ -f $1 -o -d $1 ]; then
      echo "ln -s $1 $2"
      ln -s $1 $2
   fi
}

copy_file ()
{
   if [ -f $1 ]; then
      echo "cp -pf $1 $2"
      cp -pf $1 $2
   else
      echo
      echo "Could not find $1"
      echo
      exit 0
   fi
}

exec_cmd ()
{
   echo "$*"
   $*
}


#
# save current working directory
#
THISDIR=`pwd`


#
# locate EmLinux installation directory
#
if [ "$NANOGTK_HOME" = "" ]; then
   INSTDIR=`dirname \`pwd\``
else
   INSTDIR=$NANOGTK_HOME
fi

check_dir $INSTDIR


#
# set testing directory
#
TESTDIR=$INSTDIR/Testbench

check_dir $TESTDIR


#
# get machine dependent information
#
CONFIG=$TESTDIR/local/etc/platform.conf
if [ -f $TESTDIR/local/etc/platform.conf ]; then
   . $CONFIG
else
   echo
   echo "Could not find $CONFIG"
   echo
   exit 0
fi


#
# check installed library and application directories
#
check_dir $INSTDIR/EmGdkPixbuf
check_dir $INSTDIR/glib-$GLIB_VER
check_dir $INSTDIR/gtk+-$GTK_VER
check_dir $INSTDIR/microwin
check_dir $INSTDIR/zlib
check_dir $INSTDIR/Application


#
# remove files not distributed with this Testing directory
#
exec_cmd cd $TESTDIR
exec_cmd mkdir tmpdir

exec_cmd cd config
files="sysconf.cfg userman.cfg"
exec_cmd mv $files ../tmpdir
exec_cmd rm -f *.cfg
exec_cmd mv ../tmpdir/* .
exec_cmd cd ..

exec_cmd cd icons
files="folder.xpm manage_folders.xpm start.xpm sysconf*"
exec_cmd mv $files ../tmpdir
exec_cmd rm -f *.gif *.xpm
exec_cmd mv ../tmpdir/* .
exec_cmd cd ..

exec_cmd rmdir tmpdir

exec_cmd rm -f deskman launcher nanowm nano-X nxkbd nxcjkkbd nxhwr
exec_cmd rm -f programs/*

exec_cmd rm -fr local/share/locale
exec_cmd rm -fr local/package

