#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_NAME=django-ca
#export PYBUILD_BEFORE_TEST=cp -r {dir}/ca/django_ca/tests/fixtures {build_dir}/django_ca/tests/; ln -s {build_dir}/docs/source/django_ca_sphinx {build_dir}/django_ca_sphinx
#export PYBUILD_AFTER_TEST=rm -rf {build_dir}/django_ca/tests/fixtures {build_dir}/django_ca_sphinx
export PYBUILD_BEFORE_TEST=ln -s {build_dir}/docs/source/django_ca_sphinx {build_dir}/django_ca_sphinx
export PYBUILD_AFTER_TEST=rm -f {build_dir}/django_ca_sphinx
export PYBUILD_TEST_ARGS=--ds=ca.test_settings -k "not test_permission_denied and not test_create_cadir_permission_denied and not test_permission_denied and not Dns01ValidationTestCase and not AcmeValidateDns01ChallengeTestCase" --ignore=django_ca/tests/admin/test_actions.py --ignore=django_ca/tests/admin/test_add_cert.py
export SKIP_SELENIUM_TESTS=y

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

execute_before_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx -b html -d $(CURDIR)/docs/source/.build/.doctrees -N docs/source $(CURDIR)/debian/python-django-ca-doc/usr/share/doc/python-django-ca-doc/html
endif

execute_after_dh_clean:
	rm -rf $(CURDIR)/docs/source/.build

execute_before_dh_fixperms:
	find $(CURDIR)/debian/python3-django-ca -executable -type f -exec chmod a-x {} \;
