#!/usr/bin/make -f

include /usr/share/openstack-pkg-tools/pkgos.make

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

override_dh_auto_clean:
	set -e ; cd ivulncheck-api && python3 setup.py clean && rm -rf .stestr/ build/ ivulncheck_*.egg-info
	set -e ; cd ivulncheck-client && python3 setup.py clean && rm -rf .stestr/ build/ ivulncheck_*.egg-info
	set -e ; cd ivulncheck-web && python3 setup.py clean && rm -rf .stestr/ build/ ivulncheck_*.egg-info

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_test:
	echo "Disabled tests..."
	#pkgos-dh_auto_test --no-py2

override_dh_install:
	echo "Do nothing..."

override_dh_auto_install:
	dh_install
	set -e ; cd ivulncheck-api && python3 setup.py install --install-layout=deb --root $(CURDIR)/debian/ivulncheck-api
	set -e ; cd ivulncheck-client && python3 setup.py install --install-layout=deb --root $(CURDIR)/debian/ivulncheck-client
	set -e ; cd ivulncheck-web && python3 setup.py install --install-layout=deb --root $(CURDIR)/debian/ivulncheck-web
	set -e ; find $(CURDIR)/debian/ivulncheck-web/usr/lib -iname '(bootstrap|d3|jquery).(css|js|css.map)' -delete
	set -e ; rm $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/*/vendors/*
	set -e ; ln -s ../../../../../javascript/bootstrap/js/bootstrap.js $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/js/vendors/bootstrap.js
	set -e ; ln -s ../../../../../javascript/d3/d3.js $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/js/vendors/d3.js
	set -e ; ln -s ../../../../../javascript/jquery/jquery.js $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/js/vendors/jquery.js
	set -e ; ln -s ../../../../../javascript/bootstrap/css/bootstrap.css $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/css/vendors/bootstrap.css
	set -e ; ln -s ../../../../../javascript/bootstrap/css/bootstrap.css.map $(CURDIR)/debian/ivulncheck-web/usr/share/ivulncheck-web/web/static/css/vendors/bootstrap.css.map
	
override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
	dh_python3 /usr/share

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	python3 -m sphinx -b html doc/source $(CURDIR)/debian/ivulncheck-doc/usr/share/doc/ivulncheck-doc/html
	dh_sphinxdoc
endif
