#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Portions Copyright © 2008-2010 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for sugar-firefox-activity
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.

DEB_PYTHON_SYSTEM = pycentral

include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk

# We support all branches, but default to 0.88.
CDBS_DEPENDS = python, python-sugar-0.88 | python-sugar, python-sugar-toolkit-0.88 | python-sugar-toolkit

# Well, we exec Firefox so we sort of need it installed
CDBS_DEPENDS += , firefox

DEBIAN_DIR := $(shell echo ${MAKEFILE_LIST} | awk '{print $$1}' | xargs dirname )
UPSTREAM_VERSION ?=$(shell uscan --dehs | sed -n 's/.*<upstream-version>\(.*\)<\/upstream-version>.*/\1/p')
PACKAGE := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
CURRENT_VERSION ?=$(shell dpkg-parsechangelog | sed -n 's/^Version: \(.*\)+dfsg.*/\1/p')

get-orig-source:
	cd ${DEBIAN_DIR}/.. && uscan --force-download --upstream-version $(CURRENT_VERSION)
	tar xf ../Firefox-${UPSTREAM_VERSION}.tar.bz2
	rm -rf ${CURDIR}/Firefox-${UPSTREAM_VERSION}/firefox*.tar.bz2
	tar cf ${CURDIR}/${DEB_SOURCE_PACKAGE}_${UPSTREAM_VERSION}+dfsg.orig.tar Firefox-${UPSTREAM_VERSION}/
	bzip2 ${CURDIR}/${DEB_SOURCE_PACKAGE}_${UPSTREAM_VERSION}+dfsg.orig.tar

clean::
	find -name *.mo -delete
	find -name *.linfo -delete
	rm -rf Firefox-${UPSTREAM_VERSION}
