#!/usr/bin/make -f

PYTHON3S:=$(shell py3versions -vr)
export PYBUILD_INSTALL_ARGS=--init-system=systemd,sysvinit_deb

%:
	dh $@ --with python3 --buildsystem pybuild

clean:
	debconf-updatepo
	dh $@ --with python3 --buildsystem pybuild

override_dh_auto_test:
	set -e && set -x && for pyvers in $(PYTHON3S); do \
		PYMAJOR=`echo $$pyvers | cut -d'.' -f1` ; \
		echo "===> Testing with python$$pyvers (python$$PYMAJOR)" ; \
		PYTHON=python$$pyvers PYTHONPATH=. python$$pyvers -m nose -v tests/unittests ; \
	done

override_dh_installinit:
	dh_installinit --onlyscripts --no-start --no-restart-on-upgrade --name cloud-init-local
	dh_installinit --onlyscripts --no-start --no-restart-on-upgrade
	dh_installinit --onlyscripts --no-start --no-restart-on-upgrade --name cloud-config
	dh_installinit --onlyscripts --no-start --no-restart-on-upgrade --name cloud-final

override_dh_systemd_start:
	dh_systemd_start --no-restart-on-upgrade --no-start
