#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
export DH_VERBOSE = 1

%:
	dh $@

override_dh_auto_test:
	# Skip upstream tests that require a live MySQL/MariaDB client, a
	# systemd/journald environment or specific VM hardware, which are not
	# available in the Debian build environment.
	# unit_release_gen.t is skipped too: it runs build/release_gen.pl and
	# build/genFeatures.pl, which rewrite releases/*.md and FEATURES.md in the
	# source tree. Tests must not mutate the tree (it also stamps the shipped
	# FEATURES.md with the build time), and the test only exercises upstream's
	# release tooling, not runtime behaviour.
	perl build/audit_tests.pl "prove -j4 $(shell ls tests/*.t | grep -vE '(cli_validation|syslog_journal_detection|test_issue_42|test_issue_490|test_issue_896|unit_os_vm|unit_release_gen)\.t$$' | tr '\n' ' ')"

override_dh_auto_build:
	# Use CR (Courier Roman) rather than the Pod::Man default CW; groff no
	# longer accepts CW and lintian then reports groff-message warnings.
	pod2man --fixed=CR mysqltuner.pl > mysqltuner.1

override_dh_auto_install:
	dh_auto_install
	cp mysqltuner.pl debian/mysqltuner/usr/bin/mysqltuner
	sed -i '1s|^#!/usr/bin/env perl|#!/usr/bin/perl|' debian/mysqltuner/usr/bin/mysqltuner

override_dh_auto_clean:
	dh_auto_clean
	rm -f mysqltuner.1

override_dh_fixperms:
	dh_fixperms
	chmod a-x debian/mysqltuner/usr/share/mysqltuner/*	
