message "${MESSAGE_COLOR}Starting SVN checkout of"                                       \
        "${FILE_COLOR}${SOURCE}${MESSAGE_COLOR}...${DEFAULT_COLOR}"                      
if [[ -f $SOURCE_CACHE/${SOURCE} ]]
then
  message "${MESSAGE_COLOR}Previous source found unpacking...${DEFAULT_COLOR}"           
  tar -jxf $SOURCE_CACHE/${SOURCE}                                                       
  cd openwengo-svn                                                                       
  message "${MESSAGE_COLOR}Running SVN update...${DEFAULT_COLOR}"                        
#UPDATE
#  if [[ "$OW_VERSION" == "ng" ]]
#  then
#    svn --username guest --password guest                                                  
#\
#        --non-interactive                                                                  
#\
#        update                                                                             
#\
#        http://dev.openwengo.com/svn/openwengo/trunk
#  fi                                                                                       
#&&
 # if [[ "$OW_VERSION" == "classic" ]]
 # then
    svn --username guest --password guest                                                  \
        --non-interactive                                                                  \
        update
#        http://dev.openwengo.com/svn/openwengo/softphone-classic/trunk
#  fi
  cd ..                                                                                  
  message "${MESSAGE_COLOR}Done...${DEFAULT_COLOR}"
else
  message "${MESSAGE_COLOR}Running initial SVN checkout...${DEFAULT_COLOR}"              &&

#CHECKOUT
#  if [[ "$OW_VERSION" == "ng" ]]
#  then
#    svn --username guest --password guest                                                  
#\
#        --non-interactive                                                                  
#\
#        checkout                                                                           
#\
#        http://dev.openwengo.com/svn/openwengo/trunk openwengo-ng-svn
#  fi                                                                                       
#&&
#  if [[ "$OW_VERSION" == "classic" ]]
#  then
    svn --username guest --password guest                                                  \
        --non-interactive                                                                  \
        checkout                                                                           \
        http://dev.openwengo.com/svn/openwengo/softphone-classic/trunk openwengo-svn
#  fi                                                                                       
#&&
  message "${MESSAGE_COLOR}Done...${DEFAULT_COLOR}"
fi                                                                                       

#Tarball generation

message "${MESSAGE_COLOR}Generating tarball...${DEFAULT_COLOR}"                          &&
#if [[ "$OW_VERSION" == "ng" ]]
#then
#tar -jcf                                                                                 \
#    ${SOURCE}                                                                            \
#    openwengo-ng-svn                                                                     &&
#cp  ${SOURCE} ${SOURCE_CACHE}/${SOURCE}                                                  &&
#rm  ${SOURCE}                                                                            &&
#fi                                                                                       &&
#if [[ "$OW_VERSION" == "classic" ]]
#then
tar -jcf                                                                                 \
    ${SOURCE}                                                                            \
    openwengo-svn                                                                        &&
cp  ${SOURCE} ${SOURCE_CACHE}/${SOURCE}                                                  &&
rm  ${SOURCE}                                                                            &&
#fi                                                                                       &&
message "${MESSAGE_COLOR}SVN Checkout complete...${DEFAULT_COLOR}"
