#!/usr/bin/make -f

# DH_VERBOSE := 1
export LC_ALL=C.UTF-8
export RACHISTEST=1

include /usr/share/dpkg/default.mk
VERSION_UPSTREAM=$(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/\(20[0-9][0-9]\.[0-9]\+\)\..*/\1/')

# Run the upstream test suite with pybuild for every supported Python
# version.  Tests that need the installed CLI or a live network are skipped
# via debian/patches and validated in the autopkgtest instead.
export PYBUILD_TEST_PYTEST=1

%:
	dh $@ --buildsystem=pybuild

debian/control: debian/control.in
	echo "# This file is autogenerated from control.in to update versioned dependencies" > $@
	sed -e"s/@DEB_VERSION_UPSTREAM@/$(VERSION_UPSTREAM)/g" $< >> $@

override_dh_install:
	dh_install
	mkdir -p debian/$(DEB_SOURCE)/usr/share/bash-completion/completions
	mv debian/$(DEB_SOURCE)/usr/bin/tab-rachis debian/$(DEB_SOURCE)/usr/share/bash-completion/completions/rachis
	chmod -x debian/$(DEB_SOURCE)/usr/share/bash-completion/completions/rachis
	find debian/$(DEB_SOURCE) -type f -name parsl.log -delete
