#!/bin/bash


   np=$1


#BASEVERSION=0.1
. ./*.summa


BVERSION=$BASEVERSION


PRIVERSION=$BVERSION.0
NVERSION=`svnversion`
SI=$?
if test "x$SI" = x0 ; then
          #mejorar
	  MALV=`echo $NVERSION|grep '[:M]' `
	  if test "x$MALV" != x ; then 
             if test x$np = xnp; then
    	        echo "SVN NO SICRONIZADO: $NVERSION" 1>&2;
             fi
	     if test x`echo $NVERSION|grep ':'` = x ; then 
                    NVERSION=":$NVERSION"
                    # echo no tiene : 1>&2
             fi
             NVERSION=`echo $NVERSION|tr 'M' ':'|cut -d: -f2`
             #echo NVERSION $NVERSION 1>&2
          fi 
	  #let NVERSION=$NVERSION+1
          PRIVERSION=$BVERSION.$NVERSION
          echo $PRIVERSION >./version
     else
         if test x$np = xnp; then
    	  echo "SVN NO conectado" 1>&2;
         fi
fi


if test  -s ./version ; then 
      PRIVERSION=`cat ./version`
    else
      NVERSION=0
      PRIVERSION=$BVERSION.$NVERSION 
fi

PRIRELEASE=
if test  -s ./release ; then 
      PRIRELEASE=`cat ./release`
fi
if test "x$PRIRELEASE" = x ; then
    echo 0 >./release
fi 
printf  $PRIVERSION
