#!/usr/bin/make -f

uversion=$(shell uscan --report | grep Newer -A1 | grep [/][0-9.]+[/] -Eo | grep [0-9.]+ -Eo)
orig=../firefox-l10n-xpi_$(uversion)~mozillabinaries.orig.tar.xz
dst=firefox-l10n-xpi-$(uversion)~mozillabinaries

%:
	dh $@


override_dh_makeshlibs:
	

override_dh_strip:
	

override_dh_shlibdeps:
	

override_dh_auto_clean:
	rm -rf debian/firefox*
	dh_auto_clean

override_dh_install:
ifeq ($(DEB_HOST_ARCH), i386)
	bash debian/copy-l10n i386
else
	bash debian/copy-l10n amd64
endif

override_dh_builddeb:
	dh_builddeb -- -Z xz
	
get-orig-source:
	@test "$(uversion)" = "" && \
	    echo "There is no new upstream source file." && exit 1 || true 
	rm -f $(orig)
	echo creating firefox-l10n-xpi_$(uversion)~mozillabinaries.orig.tar.xz
	mkdir -p $(dst)/amd64
	mkdir -p $(dst)/i386
	bash debian/download-l10n $(dst) $(uversion)
	tar cJf $(orig) $(dst)
	rm -rf $(dst)
	@echo "Successfully created new upstream source file: $(orig)"
