#!/bin/sh

if [ "${PBLD_COMPVER}" = "" ]; then
	new_main=$2
else
 	new_main=${PBLD_COMPVER}
fi

cur_ver=$(apt-cache policy ${1}|grep "Candidate:.*${new_main}-"|awk -F "-" '{print $NF}')
if [ "${cur_ver}" = "" ]; then
	new_ver=${new_main}-1
else
	new_ver=${new_main}-$(($(echo ${cur_ver})+1))
fi
echo ${new_ver}

