#!/usr/bin/make -f

export HOME=$(CURDIR)/debian/fake-home
export XDG_STATE_HOME =  $(HOME)/.local/state

%:
	dh $@ --with python3,bash-completion --buildsystem=pybuild

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_clean:
	# Exclude testsuite data
	dh_clean --exclude=foo.orig

execute_after_dh_auto_build:
	for d in .pybuild/*/build; do ln -sr doc $$d; done
	# build man page
	PYTHONPATH=. argparse-manpage \
		--output=osc.1 \
		--format=single-commands-section \
		--module=osc.commandline \
		--function=get_parser \
		--project-name=osc \
		--prog=osc \
		--description="openSUSE build service command-line tool" \
		--author="Contributors to the osc project." \
		--url="https://github.com/openSUSE/osc/"

ifneq ($(FAKEROOTKEY),)
override_dh_auto_test:
	mkdir -p $(XDG_STATE_HOME)
	LD_PRELOAD= dh_auto_test
endif

override_dh_auto_install:
	dh_auto_install
	# Give the binary sane name
	# mv $(CURDIR)/debian/osc/usr/bin/osc-wrapper.py $(CURDIR)/debian/osc/usr/bin/osc
