#!/bin/bash
# This is how the Debian source tarball was created:

PACKAGE=prboom-plus
VERSION=2.5.1.5~
SVNREV=4462
DFSG=1

pushd ..
svn export -r ${SVNREV} https://svn.prboom.org/repos/branches/${PACKAGE}-24/prboom2/ ${PACKAGE}-${VERSION}svn${SVNREV}
pushd ${PACKAGE}-${VERSION}svn${SVNREV}

# Filter out non-free graphics and sound lumps
BADLUMPS="$(sed -n '/^if NONFREE_GRAPHICS/,/^else\|^endif/p' data/Makefile.am | sed -e '/^if\|^else\|^endif\|^SPRITEP/d' | cut -d '=' -f 2)"
for l in ${BADLUMPS}
do
	rm data/$l
done

# Remove embedded library copies and tests
rm -rf src/MUSIC/dll src/MUSIC/include src/MUSIC/lib src/PCRELIB tests

popd
mv ${PACKAGE}-${VERSION}svn${SVNREV} ${PACKAGE}-${VERSION}svn${SVNREV}+dfsg${DFSG}

tar cJfv ${PACKAGE}_${VERSION}svn${SVNREV}+dfsg${DFSG}.orig.tar.xz ${PACKAGE}-${VERSION}svn${SVNREV}+dfsg${DFSG}
popd
