#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

DEB_COMPRESS_EXCLUDE := .py
DEB_INSTALL_CHANGELOGS_ALL := CHANGELOG
PYGLET_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p' | sed -rne 's,\.dfsg.*$\,,p')

get-orig-sources:
	wget http://pyglet.googlecode.com/files/pyglet-$(PYGLET_VERSION).tar.gz
	tar xzf pyglet-$(PYGLET_VERSION).tar.gz
	# Remove examples with unclean licensing.
	#
	# Resources (images, sound files, etc.) needed by these examples
	# have no license attached and thus are non-free.
	rm -rf pyglet-$(PYGLET_VERSION)/examples/astraea/
	rm -rf pyglet-$(PYGLET_VERSION)/examples/noisy/
	rm -f pyglet-$(PYGLET_VERSION)/examples/programming_guide/dinosaur.gif
	rm -f pyglet-$(PYGLET_VERSION)/examples/programming_guide/kitten.jpg

	# Remove doc/ folder completely -- compiled material which might use
	# above non-free content. Present in pyglet-1.1.[24].
	rm -rf pyglet-$(PYGLET_VERSION)/doc

	# Remove included log dumps since we are modifying archive anyways
	rm -f pyglet-$(PYGLET_VERSION)/tests/pyglet.1.log
	rm -f pyglet-$(PYGLET_VERSION)/examples/crashy

	tar czf pyglet_$(PYGLET_VERSION).dfsg.orig.tar.gz pyglet-$(PYGLET_VERSION)
	rm -r pyglet-$(PYGLET_VERSION) pyglet-$(PYGLET_VERSION).tar.gz
