#!/bin/sh

# Copyright 2011-2012, gregor herrmann <gregoa@debian.org>
# Copyright 2015, Salvatore Bonaccorso <carnil@debian.org>
# Released under the WTFPL

# "main build script", either calls (svn|git)-buildpackage
# which then use buildpackage-pdebuild
# or calls buildpackage-pdebuild itself

BUILDER=buildpackage-pdebuild
BUILDERSUBCMD=

dh_testdir >/dev/null 2>&1 || { echo "Not a source package ..." ; exit 1; }

[ -d .svn ] && BUILDER=svn-buildpackage
[ -d .git ] && BUILDER=gbp BUILDERSUBCMD=buildpackage

[ -x "$(command -v $BUILDER)" ] || { echo "BUILDER $BUILDER doesn't exist or is not executable ..." ; exit 1; }

exec $BUILDER $BUILDERSUBCMD "$@"
