#!/usr/bin/make -f
share:=usr/share/software-center

#export DH_VERBOSE=1

PY3REQUESTED := $(shell py3versions -r)
PY3DEFAULT := $(shell py3versions -d)
# Run setup.py with the default python3 last so that the scripts use
# #!/usr/bin/python3 and not #!/usr/bin/python3.X.
PY3 := $(filter-out $(PY3DEFAULT),$(PY3REQUESTED)) python3

%:
	dh $@ --with=python2,python3

override_dh_auto_build:
	# this will build py2
	dh_auto_build
	# ... and this py3
	set -ex; for python in $(PY3); do \
		$$python setup.py build; \
	done

override_dh_auto_install:
	# do the py3 dance
	set -ex; for python in $(PY3); do \
		$$python setup.py install --root=$(CURDIR)/debian/software-center-aptdaemon-plugins --install-layout=deb; \
	done
	# run the normal dh_auto_install which will copy the binary
	# ubuntu-license-key-helper into /usr/bin and not mangle it to py3
	dh_auto_install
	# Move the scripts to $(SHARE)
	mv $(CURDIR)/debian/software-center-aptdaemon-plugins/usr/*bin/* debian/software-center-aptdaemon-plugins/$(share)
