#!/bin/sh

set -e

#stem=${DEBIAN_STEM:-kernel}
stem=xen
version=${DEBIAN_UPSTREAM_VERSION}
pkg=$stem-headers-$version$debnum

arch=$DEB_HOST_ARCH
case $arch in
amd64)
	arch=x86_64
	;;
hppa)
	arch=parisc
	;;
esac

cd "$DEBIAN_SRCTOP"
home="$OLDPWD"
{
	find . \
		-path './Documentation/*' -prune -o \
		-path './debian/*' -prune -o \
		-type f \( \
			-name 'Makefile*' -o -name 'Kconfig*' \
		\) -print
	echo arch/$arch/kernel/asm-offsets.s
} | cpio -pd --preserve-modification-time "$home"
cd "$home"
> scripts/Makefile

find scripts -type f | xargs touch -t 9511212200

cd "$DEBIAN_SRCTOP"
dh_strip --package=$pkg --tmpdir=debian/tmp-headers
find "$home/scripts" -type f | xargs touch -t 9511212200
dh_fixperms --package=$pkg --tmpdir=debian/tmp-headers
