#!/usr/bin/make -f
export PYBUILD_NAME := cryptolyzer

export CRYPTOLYZER_TEST_SKIP_LIVE_SERVER := 1
export CRYPTOLYZER_TEST_SKIP_LIVE_DNS := 1

export no_proxy := 127.0.0.1,localhost

# cryptolyzer reads its own distribution metadata on import, so the tests run
# after the installation step rather than in the build directory. That step is not the one
# nocheck turns off, so the profile has to be honoured here.
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
export PYBUILD_AFTER_INSTALL := PYTHONPATH={destdir}/usr/lib/python3/dist-packages {interpreter} -m unittest discover
endif

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

override_dh_auto_test:

# The dependencies are listed in debian/control. Deriving them from the distribution metadata
# as well would turn certvalidator, which this package can run without, into a strict one.
override_dh_python3:
	dh_python3 --no-guessing-deps

override_dh_install:
	mkdir -p debian/cryptolyzer/usr/bin
	mv debian/python3-cryptolyzer/usr/bin/cryptolyze debian/cryptolyzer/usr/bin/
	rmdir --ignore-fail-on-non-empty debian/python3-cryptolyzer/usr/bin
