#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PACKAGES        = $(shell dh_listpackages -s)
UDEB_DIRS	= lib/debian-installer-startup.d \
		  usr/lib/base-installer.d \
		  usr/lib/finish-install.d

%:
	dh $@

override_dh_auto_install:
	dh_install

	# Install the following "manually" as they need a rename
	$(foreach PACKAGE, $(PACKAGES), \
		install -m0644 debian/configs/* \
			debian/$(PACKAGE)/etc/qcontrol; )
	install -m0755 qcontrol-static \
		debian/qcontrol-udeb/usr/sbin/qcontrol
	install -m0755 debian/initramfs/hook \
		debian/qcontrol/usr/share/initramfs-tools/hooks/qcontrol
	install -m0755 debian/initramfs/init-bottom \
		debian/qcontrol/usr/share/initramfs-tools/scripts/init-bottom/qcontrol
	# Install the following "manually" as they need permissions set
	install -m0755 debian/udeb/qcommand \
		debian/qcontrol-udeb/usr/sbin/
	$(foreach UDEB_DIR, $(UDEB_DIRS), \
		install -m0755 debian/udeb/$$(basename $(UDEB_DIR))/* \
			debian/qcontrol-udeb/$(UDEB_DIR); )

override_dh_installinit:
	dh_installinit --name=qcontrold
	# This initscript just changes the LEDs and sounds the buzzer. No need
	# to do this on install or upgrade.
	dh_installinit --no-start --no-restart-on-upgrade

