#!/usr/bin/make -f

# redirect module to correct dist-packages dir
export PYBUILD_INSTALL_ARGS=--install-lib=/usr/lib/python3/dist-packages

override_dh_installinit:
	dh_installinit --name=oscapd --restart-after-upgrade
	dh_installinit --remaining

override_dh_install:
	dh_install -O--buildsystem=pybuild
	rm -rf $(CURDIR)/debian/openscap-daemon/usr/lib/python3/dist-packages/openscap_daemon/__pycache__
	rm -rf $(CURDIR)/debian/openscap-daemon/usr/lib/python3/dist-packages/openscap_daemon/cve_scanner/__pycache__

override_dh_gencontrol:
	dh_gencontrol -- \
		-Vlib:Depends=$(shell dpkg-query -W -f '$${Depends}' libopenscap-dev \
		| sed -E 's/.*(libopenscap[[:alnum:].-]+).*/\1/')

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

# get back current tag release notes from GitHub
mkrelease:
	quilt push changelog.patch
	debian/lib/release.py
	dos2unix changelog
	quilt refresh
	quilt pop -a
	@echo
	@echo This target is made to fail intentionally, to make sure
	@echo that it is NEVER run during the automated build. Please
	@echo ignore the following error, the changelog file has been
	@echo generated SUCCESSFULLY.
	@echo
	exit 1

