#! /usr/bin/make -f

export PYBUILD_NAME=bernhard
%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	protoc -I=debian --python_out=bernhard debian/riemann.proto
	mv bernhard/riemann_pb2.py bernhard/pb.py
	dh_auto_build

override_dh_gencontrol:
	pbvercur=`dpkg -l python3-protobuf | grep 'ii' | sed -e 's/^.*python3-protobuf[[:space:]]\+\([0-9.]\+\)-[0-9].*/\1/' | cut -d '.' -f 1,2` ; \
	pbvernext=`echo $$pbvercur | awk -F '[.]' '{printf "%d.%d\n", $$1, $$2 + 1}'` ; \
	sed -i "s/python3-protobuf/python3-protobuf (>= $${pbvercur}), python3-protobuf (<< $${pbvernext})/" debian/*substvars
	dh_gencontrol
