#!/usr/bin/make -f
#export DH_VERBOSE=1
#
# Uncomment to ignore all test failures (but the tests will run anyway)
#export DH_RUBY_IGNORE_TESTS=all
#
# Uncomment to ignore some test failures (but the tests will run anyway).
# Valid values:
#export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems
#
# If you need to specify the .gemspec (eg there is more than one)
export DH_RUBY_GEMSPEC=debian/ticgit-ng.gemspec

%:
	dh $@ --buildsystem=ruby --with ruby,bash-completion

override_dh_auto_build:
	dh_auto_build
	docbook-to-man debian/ti.sgml >debian/ti.1
	docbook-to-man debian/ticgitweb.sgml >debian/ticgitweb.1

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/ticgitweb/usr/bin
	mv debian/ticgit/usr/bin/ticgitweb debian/ticgitweb/usr/bin/ticgitweb

override_dh_auto_clean:
	# create a static gemspec
	PKG_VERSION=`dpkg-parsechangelog | grep '^Version:' | \
		    sed -e 's/Version:\s*\(.*\)-.*$$/\1/'` && \
		    sed -n -e "/Gem::Spec/,$$ { s/TicGitNG::VERSION/\"$$PKG_VERSION\"/; p }" ticgit-ng.gemspec > debian/ticgit-ng.gemspec
	dh_auto_clean
	rm -rf debian/html build-stamp debian/ti.1 debian/ticgitweb.1

UPSTREAM_COMMIT_ID=32d1d8471275a25ba73aef86db1ea5f4009d3b1e
UPSTREAM_TAR_NAME=ticgit.tar.gz

get-orig-source:
	wget http://github.com/jeffWelling/ticgit/tarball/$(UPSTREAM_COMMIT_ID)/$(UPSTREAM_TAR_NAME)
