#!/usr/bin/make -f

DEB_AUTO_UPDATE_DEBIAN_CONTROL = 1
DEBATHENA_DIVERT_FILES_debathena-nsswitch-config += \
	/etc/nsswitch.conf.debathena
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/debathena-divert.mk

common-build-indep:: debian/nsswitch.conf.debathena

ifneq ($(wildcard /usr/share/base-files/nsswitch.conf),)
    NSSWITCH_CONF = /usr/share/base-files/nsswitch.conf
else
    NSSWITCH_CONF = /etc/nsswitch.conf
endif

debian/nsswitch.conf.debathena: $(NSSWITCH_CONF)
	sed '/^passwd:/ s/$$/ hesiod/; /^group:/ s/$$/ hesiod/' $< > $@

/etc/nsswitch.conf: FORCE
	dpkg-query --showformat='$${Conffiles}\n' --show base-files | \
	    fgrep " $@ " | sed 's/^ \(.*\) \(.*\)$$/\2  \1/' | \
	    md5sum -c  # Check that the file has not been modified.

FORCE:

clean::
	rm -f debian/nsswitch.conf.debathena
