#!/bin/bash
# dobeta
# quick go to create deb package from beta sources
#
#################################################################
#		REPLACE VALUES WITH YOUR OWN			#
# SVN repository full path
BETA_PATH="/home/massimo/sources/uppbeta"
#
# Destination path for generated debian
DEST_PATH="/home/massimo/sources/uppdeb"
#
# Mantainer name and email
export MAINTAINER="Massimo Del Fedele"
#
export EMAIL="max@veneto.com"
#################################################################
#
# checks if beta repo and destination path are ok
if [ ! -d $BETA_PATH/uppsrc ]
then
	echo "ERROR - UPP path not found in '$BETA_PATH'"
	echo "Please modify current script to fit your Upp beta repository path"
	exit 1
fi

if [ ! -d $DEST_PATH ]
then
	echo "ERROR - Invalid destinatio path '$DEST_PATH'"
	echo "Please modify current script to fit your destination path"
	exit 1
fi

#locates 'uppbeta2deb' script - first try on path
uppbeta2deb="`which uppbeta2deb`"
if [ x$uppbeta2deb = x ]
then
	# couldn't find it on path, just try on this script's path
	LSOF=$(lsof -p $$ 2>/dev/null | grep -E "/"$(basename $0)"$")
	uppbeta2deb=$(echo $LSOF | sed -r s/'^([^\/]+)\/'/'\/'/1 2>/dev/null)
	uppbeta2deb=$(dirname $uppbeta2deb)/uppbeta2deb
fi
if [ ! -f $uppbeta2deb ]
then
	echo "ERROR - Could not find 'uppbeta2deb' script"
	echo "Please check if it's on current path"
	exit 1
fi

#just run uppbeta2deb with my params
$uppbeta2deb $BETA_PATH $DEST_PATH

