#!/usr/bin/make -f
%:
	dh $@ --with xul-ext --buildsystem=xul_ext

override_dh_auto_build:
	mv $(CURDIR)/chrome/wot.jar\!/content/libs/jquery.js $(CURDIR)/debian/jquery.js.bkp
	uglifyjs -o $(CURDIR)/chrome/wot.jar\!/content/libs/jquery.js \
		$(CURDIR)/chrome/wot.jar\!/content/libs/jquery-ui-1.9.2.custom.js
	dh_auto_build -O--buildsystem=xul_ext
	mv $(CURDIR)/debian/jquery.js.bkp $(CURDIR)/chrome/wot.jar\!/content/libs/jquery.js

override_dh_auto_install:
	install-xpi --remove-license-files xul-ext-wot.xpi
	rm -r $(CURDIR)/debian/xul-ext-wot/usr/share/xul-ext/wot/META-INF

override_dh_installchangelogs:
	dh_installchangelogs $(CURDIR)/debian/upstream-changelog

get-orig-source:
	wget https://www.mywot.com/files/downloads/wot-latest.xpi
	mv wot-latest.xpi ..
	VERSION=$$(unzip -c ../wot-latest.xpi install.rdf|sed -nr 's,.*<em:version>(.+)</em:version>.*,\1,p') && \
		xpi-repack --upstream-version=$$VERSION ../wot-latest.xpi && \
		echo Upstream version $$VERSION downloaded
