#!/usr/bin/make -f

BUILDHOME = $(CURDIR)/debian/build

%:
	dh $@

override_dh_clean:
	dh_clean
	rm -rf $(BUILDHOME)

override_dh_auto_test:
	mkdir -p $(BUILDHOME)

	# workaround for #752930
	# 0) create ~/.cpan/CPAN/MyConfig.pm ourselves before EU::AutoInstall
	#    tries to do it and fails horribly in a loop in the install_help
	#    question
	# 1) "preseed" exactly this install_help question, otherwise the default
	#    'local::lib' is chosen and CPAN.pm goes out hunting
	# 2) "preseed" urllist as well, otherwise CPAN.pm from 5.18 asks for it
	#     and tries to download a mirror list. in 5.20 it contains
	#     www.cpan.org already.
	HOME=$(BUILDHOME) perl -MCPAN -e '$$CPAN::Config = {"install_help" => q[manual], "urllist" => [q[http://www.cpan.org/]]}; CPAN::Shell->mkmyconfig;'

	HOME=$(BUILDHOME) dh_auto_test
