#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_NAME=tomahawk
export PYBUILD_BEFORE_TEST=cp -r {dir}/tests {build_dir};touch {build_dir}/tests/__init__.py; touch {build_dir}/tests/internal/__init__.py; cd {build_dir}
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS={build_dir}/tests/internal

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

override_dh_python3:
	dh_python3
	mv -f $(CURDIR)/debian/python3-tomahawk/usr/bin/tomahawk $(CURDIR)/debian/python3-tomahawk/usr/bin/tomahawk3
	mv -f $(CURDIR)/debian/python3-tomahawk/usr/bin/tomahawk-rsync $(CURDIR)/debian/python3-tomahawk/usr/bin/tomahawk-rsync3
	find $(CURDIR)/debian -name tests | xargs rm -rf

override_dh_clean:
	dh_clean
	rm -f $(CURDIR)/requirements*.txt

convert_manpage_tomahawk3:
	sed 's/\"tomahawk\"/\"tomahawk3\"/g' $(CURDIR)/man/man1/tomahawk.1 > $(CURDIR)/debian/tomahawk3.1
	sed -i 's/\"TOMAHAWK\"/\"TOMAHAWK3\"/g' $(CURDIR)/debian/tomahawk3.1
	sed -i 's/tomahawk /tomahawk3 /g' $(CURDIR)/debian/tomahawk3.1
	sed -i 's/\\fBtomahawk/\\fBtomahawk3/g' $(CURDIR)/debian/tomahawk3.1
	sed -i 's/\\fItomahawk\\f/\\fItomahawk3\\f/g' $(CURDIR)/debian/tomahawk3.1
	sed -i 's/\\fItomahawk\\-rsync/\\fItomahawk\\-rsync3/g' $(CURDIR)/debian/tomahawk3.1
	sed 's/\"tomahawk\"/\"tomahawk3\"/g' $(CURDIR)/man/man1/tomahawk-rsync.1 > $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/\"TOMAHAWK-RSYNC\"/\"TOMAHAWK-RSYNC3\"/g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/tomahawk-rsync /tomahawk-rsync3 /g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/tomahawk\\-rsync /tomahawk\\-rsync3 /g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/\\fBtomahawk\\-rsync/\\fBtomahawk\\-rsync3/g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/\\fItomahawk(1)\\f/\\fItomahawk3(1)\\f/g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/\\fItomahawk\\f/\\fItomahawk3\\f/g' $(CURDIR)/debian/tomahawk-rsync3.1
	sed -i 's/\\fItomahawk\\-rsync/\\fItomahawk\\-rsync3/g' $(CURDIR)/debian/tomahawk-rsync3.1
