#!/usr/bin/make -f

#export DH_VERBOSE = 1

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=tpm2_pytss
export PYBUILD_OPTION="--test-pytest"

# Disable test_encrypted_key because it requires user input of a password
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018159
export PYBUILD_TEST_ARGS=-k 'not test_encrypted_key and not test_provision_ok and not test_provision_fail and not test_get_random and not test_get_random_zero and not test_get_random_large and not test_get_random_negative and not test_get_info and not test_list and not test_list_search_path and not test_list_bad_search_path and not test_create_key and not test_create_key_double_ok and not test_create_key_double_fail and not test_get_esys_blob_contextload and not test_get_esys_blob_bad and not test_get_esys_blob_deserialize and not test_verify and not test_verify_fail and not test_import_key_double_ok and not test_import_key_double_fail and not test_import_policy_double_ok and not test_import_policy_double_fail and not test_import_exported_key and not test_export_imported_policy and not test_create_seal and not test_create_seal_double_ok and not test_create_seal_double_fail and not test_create_seal_random and not test_create_seal_both_data_and_size_fail and not test_create_seal_neither_data_nor_size_fail and not test_unseal and not test_quote_verify and not test_export_key and not test_delete_key and not test_set_get_description and not test_get_empty_description and not test_set_get_app_data and not test_get_no_app_data and not test_set_get_certificate and not test_get_empty_certificate and not test_get_empty_platform_certificates_ok and not test_get_empty_platform_certificates_fail and not test_pcr_read and not test_pcr_extend_read and not test_nv_write_read and not test_nv_increment and not test_nv_pcr and not test_nv_set_bits and not test_set_auth_callback and not test_unset_auth_callback and not test_write_authorize_nv and not test_authorize_policy and not test_policy_signed and not test_policy_branched and not test_policy_action and not test_sign and not test_get_tpm_blobs and not test_provision_ok and not test_provision_fail and not test_get_random and not test_get_random_zero and not test_get_random_large and not test_get_random_negative and not test_get_info and not test_list and not test_list_search_path and not test_list_bad_search_path and not test_create_key and not test_create_key_double_ok and not test_create_key_double_fail and not test_get_esys_blob_contextload and not test_get_esys_blob_bad and not test_get_esys_blob_deserialize and not test_verify and not test_verify_fail and not test_import_key_double_ok and not test_import_key_double_fail and not test_import_policy_double_ok and not test_import_policy_double_fail and not test_import_exported_key and not test_export_imported_policy and not test_create_seal and not test_create_seal_double_ok and not test_create_seal_double_fail and not test_create_seal_random and not test_create_seal_both_data_and_size_fail and not test_create_seal_neither_data_nor_size_fail and not test_unseal and not test_quote_verify and not test_export_key and not test_delete_key and not test_set_get_description and not test_get_empty_description and not test_set_get_app_data and not test_get_no_app_data and not test_set_get_certificate and not test_get_empty_certificate and not test_get_empty_platform_certificates_ok and not test_get_empty_platform_certificates_fail and not test_pcr_read and not test_pcr_extend_read and not test_nv_write_read and not test_nv_increment and not test_nv_pcr and not test_nv_set_bits and not test_set_auth_callback and not test_unset_auth_callback and not test_write_authorize_nv and not test_authorize_policy and not test_policy_signed and not test_policy_branched and not test_policy_action and not test_sign and not test_get_tpm_blobs and not test_encrypt_decrypt' test

# Building package outside scm repo fails, so set the version explicitly:
export SETUPTOOLS_SCM_PRETEND_VERSION=$(DEB_VERSION_UPSTREAM)

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

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=./src python3 -m sphinx -b html -N docs/ \
		$(CURDIR)/debian/python-tpm2-pytss-doc/usr/share/doc/python-tpm2-pytss-doc/html
	rm $(CURDIR)/debian/python-tpm2-pytss-doc/usr/share/doc/python-tpm2-pytss-doc/html/.nojekyll
	dh_sphinxdoc
endif
