#!/bin/sh

rm -rRf debian
tar -xzvf debian.tar.gz
rm debian/patches/*

PKGSPEC=qemu-svn.spec

for i in $(for i in `cat $PKGSPEC | grep -v "#" | grep %patch | sed -e 's/%p/P/' | sed -e 's/-p1//' | sed -e 's/Patch//'` ; do cat $PKGSPEC | grep "Patch$i:" | grep qemu ; done | cut -d":" -f2 | sed -e 's/^ *//' ) ; do cp $i debian/patches/ ; echo $i ; echo $i >> debian/patches/series ; done
rm debian.tar.gz
cp qemu-svn.dsc.changes debian/changelog
tar -czvf debian.tar.gz debian
rm -rRf debian
