#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@ 

CURVER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-(+dfsg)]+).*,\1,p')
FULLVER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')

PACKAGE_NAME=camo
TARBALL=$(PACKAGE_NAME)_$(FULLVER).orig.tar.gz
ORIG_TARBALL=v$(CURVER).tar

get-orig-source:
	wget https://github.com/atmos/camo/archive/$(ORIG_TARBALL).gz
	gunzip $(ORIG_TARBALL).gz
	tar --delete -f $(ORIG_TARBALL) camo-$(CURVER)/server.js
	gzip $(ORIG_TARBALL)
	mv $(ORIG_TARBALL).gz $(TARBALL)

override_dh_auto_build:
	rake --trace build
override_dh_auto_test:
	nodejs server.js &
	rake --trace test
	pkill -KILL -xf "nodejs server.js"

override_dh_auto_clean:
	rm -f tmp/camo.pid server.js
