#!/bin/sh

set -e

kbpkg=@kbpkg@

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

remove=
cd include
for i in asm-*; do
	case ${i#asm-} in
	generic | x86_64)
		;;
	*)
		remove="$remove $i"
		;;
	esac
done
${remove:+rm -r $remove}
