#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh $@

override_dh_install:
	# The build of the documentation requires the existence of a basic
	# Django project configuration file which means we need to provide a secret
	# at least.
	cp netbox/netbox/configuration_example.py netbox/netbox/configuration.py
	SECRET=`python3 netbox/generate_secret_key.py` ;\
	    sed -i "s/^SECRET_KEY[[:blank:]]*=[[:blank:]]''/SECRET_KEY = '$${SECRET}'/g" netbox/netbox/configuration.py
	mkdocs -v build
	dh_install
	# Remove the upstream configuration files for NetBox, we ship them as
	# examples through /usr/share/doc/netbox/examples/ and the user can
	# pick the files from there if wanted.
	rm $(CURDIR)/debian/netbox/usr/share/netbox/netbox/netbox/configuration_example.py \
	   $(CURDIR)/debian/netbox/usr/share/netbox/netbox/netbox/configuration_testing.py \
	   $(CURDIR)/debian/netbox/usr/share/netbox/netbox/netbox/configuration.py

override_dh_fixperms:
	dh_fixperms
	for file in `find debian/netbox -type f \
	    \( -name "*.gitignore" -o -name "*.eslint*" -o -name "*.prettier*" -o -name "*.sassrc" -o -name "*yarn.lock" \)`; do \
	    rm -rf $${file} ;\
	done
