#!/usr/bin/make -f

export PYBUILD_NAME=magic-wormhole
export PYBUILD_TEST_CUSTOM=1
# copied from tox.ini
export PYBUILD_TEST_ARGS=python3 -m wormhole.test.run_trial wormhole
# this leaves test files lying around, clean them up
export PYBUILD_AFTER_TEST=rm -r {build_dir}/_trial_temp/
# Work around test failures due to ASCII python3 restrictions
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

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

override_dh_installchangelogs:
	dh_installchangelogs NEWS.md

execute_after_dh_install:
        # this should be fixed upstream, but we want to fix a RC bug
	mkdir -p $(CURDIR)/debian/magic-wormhole/usr/share/bash-completion/completions $(CURDIR)/debian/magic-wormhole/usr/share/fish/vendor_completions.d $(CURDIR)/debian/magic-wormhole/usr/share/zsh/vendor-completions
	mv $(CURDIR)/debian/magic-wormhole/usr/wormhole_complete.bash $(CURDIR)/debian/magic-wormhole/usr/share/bash-completion/completions/wormhole
	mv $(CURDIR)/debian/magic-wormhole/usr/wormhole_complete.fish $(CURDIR)/debian/magic-wormhole/usr/share/fish/vendor_completions.d/wormwhole.fish
	mv $(CURDIR)/debian/magic-wormhole/usr/wormhole_complete.zsh $(CURDIR)/debian/magic-wormhole/usr/share/zsh/vendor-completions/_wormhole
