#!/usr/bin/make -f

DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
UPSTREAM_VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[~-].*//')

%:
	dh $@ --builddirectory=.

override_dh_auto_build:
	gzip < postbooks_demo-$(UPSTREAM_VERSION).sql > postbooks_demo-$(UPSTREAM_VERSION).sql.gz
	gzip < postbooks_empty-$(UPSTREAM_VERSION).sql > postbooks_empty-$(UPSTREAM_VERSION).sql.gz
	gzip < postbooks_quickstart-$(UPSTREAM_VERSION).sql > postbooks_quickstart-$(UPSTREAM_VERSION).sql.gz
	

# convenience target for maintainer to update the source package:
unpack_pgdump:
	pg_restore -f postbooks_demo-$(UPSTREAM_VERSION).sql postbooks_demo-$(UPSTREAM_VERSION).backup
	pg_restore -f postbooks_empty-$(UPSTREAM_VERSION).sql postbooks_empty-$(UPSTREAM_VERSION).backup
	pg_restore -f postbooks_quickstart-$(UPSTREAM_VERSION).sql postbooks_quickstart-$(UPSTREAM_VERSION).backup

