#!/usr/bin/make -f

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

%:
	dh $@  --with python2

override_dh_auto_install:
	# install horizon and dashboard
	python setup.py install --root=$(CURDIR)/debian/tmp --no-compile -O0 --install-layout=deb
	install -d -m 755 $(CURDIR)/debian/tmp/usr/share/openstack-dashboard
	install -d -m 755 $(CURDIR)/debian/tmp/etc/openstack-dashboard
	install -d -m 755 $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/quantum
	install -d -m 755 $(CURDIR)/debian/tmp/etc/apache2/conf.d
	
	cp -a $(CURDIR)/openstack_dashboard/ $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/
	cp -a $(CURDIR)/openstack_dashboard/settings.py $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/
	
	touch $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/quantum/__init__.py
	touch $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/quantum/client.py
	cp -a $(CURDIR)/debian/openstack-dashboard.conf $(CURDIR)/debian/tmp/etc/apache2/conf.d
	cp $(CURDIR)/openstack_dashboard/local/local_settings.py.example \
		$(CURDIR)/debian/tmp/etc/openstack-dashboard/local_settings.py
	cp $(CURDIR)/manage.py \
		 $(CURDIR)/debian/tmp/usr/share/openstack-dashboard/manage.py
	ln -fs /etc/openstack-dashboard/local_settings.py \
		$(CURDIR)/debian/tmp/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py
	cp $(CURDIR)/debian/theme/juju.png \
		$(CURDIR)/debian/tmp/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/img/juju.png


ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	PYTHONPATH=. bash run_tests.sh -N || true
endif

override_dh_auto_clean:
	dh_clean
	rm -rf $(CURDIR)/horizon/build
	rm -rf $(CURDIR)/horizon/horizon.egg-info
	rm -rf $(CURDIR)/openstack_dashboard/openstack_dashboard.egg-info

get-orig-source:
	uscan --verbose --force-download --rename --destdir=../build-area
