#!/usr/bin/make -f

#export DH_VERBOSE=1

MODULE		 = someproject
MODSRCPKG	 = $(MODULE)-source

%:
	dh $@

execute_after_dh_install:
# Install the module source.
	dh_installdirs -p$(MODSRCPKG) usr/src/modules/$(MODULE)/debian
	tar c -v --exclude '.git' --exclude '.svn' --exclude 'CVS' --exclude 'debian' . | \
		tar x -C debian/$(MODSRCPKG)/usr/src/modules/$(MODULE)
# Install the debian directory into the module source.
	dh_install -p$(MODSRCPKG) debian/copyright debian/changelog debian/modules/* usr/src/modules/$(MODULE)/debian/
# Pack the module source.
	tar c \
		-C debian/$(MODSRCPKG)/usr/src \
		--numeric-owner --owner=0 --group=0 \
		--mode=a=rX,u+w \
		--sort=name \
		--mtime='@$(SOURCE_DATE_EPOCH)' \
		--clamp-mtime \
		--remove-files \
		modules | xz -T1 -9 > debian/$(MODSRCPKG)/usr/src/$(MODULE).tar.xz
	tar tfv debian/$(MODSRCPKG)/usr/src/$(MODULE).tar.xz
