#!/usr/bin/make -f
DEB_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
ORIG_SRC=https://github.com/WindowsAzure/WALinuxAgent

get-packaged-orig-source:
	git clone --separate-git-dir=walinuxagent.checkout \
		$(ORIG_SRC) orig_source
	git checkout -b tags/v$(DEB_VERSION)
	git archive --format=tar.gz v$(DEB_VERSION) \
		-o walinuxagent_$(DEB_VERSION).orig.tar.gz
	rm -rf walinuxagent.checkout
	rm -rf orig_source

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

execute_before_dh_installman:
	go-md2man -in=README.md -out=debian/walinuxagent.1

override_dh_installsystemd:
	# remove service placed in the wrong path by upstream install
	rm -f debian/walinuxagent/lib/systemd/system/walinuxagent.service
	dh_installsystemd --name walinuxagent --no-stop-on-upgrade walinuxagent.service
	dh_installsystemd --name walinuxagent --no-stop-on-upgrade ephemeral-disk-warning.service

override_dh_python3:
	dh_python3 -O--buildsystem=pybuild --shebang "/usr/bin/env python3"

override_dh_auto_test:
	pytest --ignore-glob '*/test_cgroupconfigurator_sudo.py' --verbose tests
