#!/bin/sh
#
# installTree - install the directory, all subdirs and files
#
# SYNOPSIS: 
#      installTree source dest

S=
D=

# Override if there is no tar program.

if [ $# != "2" ]
then
    exit 2
fi

S="$1"
D="$2"

TREE_PATH="$2"

if [ "$1" != "$2" ]
then
	echo
else
	exit 2
fi

if [ ! -z "$PREFIX" ]
then
        D="$PREFIX$D"
fi

if [ ! -z "$INSTALL_ROOT" ]
then
        D="$INSTALL_ROOT$D"
fi


if [ ! -d "$D" ]
then
	installDir $TREE_PATH
fi

if [ ! -d "$D" ]
then
	echo "Can't create destination dir - aborting installTree"
	exit 2
fi

echo "$D/$S"

tar cf - $S | ( cd $D ; tar xf - )

if [ -z "$FILE_OWNER" ]
then
	FILE_OWNER="root"
fi

if [ -z "$FILE_GROUP" ]
then
	FILE_GROUP="root"
fi

setTreeOwnership $FILE_OWNER $FILE_GROUP  $D/$S

mkInstallEntry -t $TREE_PATH/$S >> $LOG
