#!/bin/sh
# $Id: make-kernel-patch-pkgs,v 1.1 2003/12/21 05:37:17 herbert Exp $

set -e

top=$PWD
version=$(cat version.Debian)
upstream=${version%-*}
kp=kernel-patch-debian-$upstream
kt=kernel-tree-$upstream
pkgs="--package=$kp --package=$kt"
kphome=$top/debian/$kp/usr/src/kernel-patches/all/$upstream

mkdir -p $kphome/apply $kphome/debian $kphome/unpatch

cd debian/patches
awk '!/^#/ && NF > 0 {print $1}' list |
	xargs cp --target-directory=$kphome/debian
bzip2 -9 $kphome/debian/*
cp list $kphome/debian

cd ..
install list-patches $kphome/debian
sed "s/@version@/$version/g" apply > $kphome/apply/debian
sed "s/@version@/$version/g" unpatch > $kphome/unpatch/debian
chmod 755 \
	$kphome/apply/debian \
	$kphome/unpatch/debian

cd ..
dh_installdocs $pkgs
dh_installchangelogs $pkgs
dh_compress $pkgs
dh_fixperms $pkgs
dh_installdeb $pkgs
dh_gencontrol $pkgs -- -Tdebian/substvars
dh_md5sums $pkgs
dh_builddeb $pkgs
