#!/usr/bin/make -f

UTILS_PRUNE = debuginfo-install find-repos-of-install needs-restarting \
	      package-cleanup show-changed-rco show-installed verifytree \
	      yum-debug-dump yum-debug-restore


%:
	dh $@ --with python2

override_dh_auto_build:
	# Backup a pristine copy of l10n files
	for po in po/*.po po/yum-utils.pot; do cp -p $$po $$po.backup; done
	dh_auto_build

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/yum-utils/etc/NetworkManager
	# Purge man pages for yum plugins, not relevant to Debian
	for plugin in $$(ls plugins); do \
	  rm -f debian/yum-utils/usr/share/man/man*/yum-$$plugin.[0-9]; \
	  rm -f debian/yum-utils/usr/share/man/man*/yum-$$plugin.conf.[0-9]; \
	done
	rm -rf debian/yum-utils/usr/share/man/man5
	# Don't install utils that don't work at all for Debian or that are
	# less useful and have unfortunate or confusing names. These utils
	# are installed as examples instead.
	for n in $(UTILS_PRUNE); do \
	  rm -f debian/yum-utils/usr/bin/$$n; \
	  rm -f debian/yum-utils/usr/share/man/man*/$$n.[0-9]; \
	done

override_dh_auto_clean:
	dh_auto_clean
	$(MAKE) -C po clean
	# Restore pristine l10n files
	for po in po/*.backup; do test ! -e $$po || mv -f $$po $${po%%.backup}; done

override_dh_installexamples:
	dh_installexamples
	chmod +x debian/yum-utils/usr/share/doc/yum-utils/examples/*.py

override_dh_compress:
	dh_compress -Xusr/share/doc/yum-utils/examples/
