#!/bin/bash
# dodev
# quick go to create deb package from my dev repo
#

#################################################################
#		REPLACE VALUES WITH YOUR OWN			#
# SVN repository full path
DEV_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 dev repo and destination path are ok
if [ ! -d $DEV_PATH/uppsrc ]
then
	echo "ERROR - UPP path not found in '$DEV_PATH'"
	echo "Please modify current script to fit your Upp development 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 'uppdev2deb' script - first try on path
uppdev2deb="`which uppdev2deb`"
if [ x$uppdev2deb = 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)"$")
	uppdev2deb=$(echo $LSOF | sed -r s/'^([^\/]+)\/'/'\/'/1 2>/dev/null)
	uppdev2deb=$(dirname $uppdev2deb)/uppdev2deb
fi
if [ ! -f $uppdev2deb ]
then
	echo "ERROR - Could not find 'uppdev2deb' script"
	echo "Please check if it's on current path"
	exit 1
fi

#just run uppdev2deb with my params
$uppdev2deb $DEV_PATH $DEST_PATH

