#!/usr/bin/make -f

# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export PYBUILD_TEST_ARGS=-k "not TestGetExploits and not test_update_command and not test_start_and_kill_faraday_server and not test_create_agent_without_name_fails and not test_create_agent_invalid_payload and not test_vuln_filter_exception and not test_vuln_restless_sort_by_ and not test_vuln_web_filter_exception and not test_filter_by_creator_command_id and not test_openapi_format and not test_filter_by_querystring and not test_websocket_BroadcastServerProtocol and not test_vuln_filter and not test_yaml_docs_with_no_doc and not test_yaml_docs_with_defaults and not test_tags_sorted_correctly and not test_export_csv_with_false_argument and not test_export_csv_with_filters and not test_export_csv_from_filters_endpoint"
#export PYBUILD_DISABLE=test

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

override_dh_install:
	dh_install
	# remove unwanted files: .gitignore and useless README
	rm debian/faraday/usr/lib/python3*/dist-packages/faraday/migrations/versions/.gitignore
	rm debian/faraday/usr/lib/python3*/dist-packages/faraday/migrations/README
	# copy vendor to embed sqlalchemy and other Python modules
	cp -r debian/vendor/* debian/faraday/usr/lib/python3*/dist-packages/faraday/vendor
	# install www files in /usr/share instead of /usr/lib/python3
	cp -r debian/faraday/usr/lib/python3*/dist-packages/faraday/server/www debian/faraday/usr/share/faraday/server
	rm -rf debian/faraday/usr/lib/python3*/dist-packages/faraday/server/www

override_dh_installchangelogs:
	dh_installchangelogs RELEASE.md

override_dh_auto_test:
#	export PYTHONPATH=$(CURDIR)/debian/vendor:$(PYTHONPATH) && dh_auto_test
#	skip tests as they fail with python3-flask-login >= 0.6 (see
#	https://github.com/infobyte/faraday/issues/456)
