#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# This file is public domain software, originally written by Joey Hess.
#
# This version is for packages that are architecture independent.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

p := mozilla-thunderbird-locale-ko
UID := {972ce4c6-7e08-4474-a285-3208198ce6fd}

build: build-stamp
build-stamp:
	dh_testdir
	mkdir -p build
	unzip *.xpi -d build
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	-rm -rf build debian/$(p)
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k

	# test UID
	#if [ "$(UID)" != "$(shell grep '<Description about=\"urn:mozilla:install-manifest\"' -A10 build/install.rdf | grep 'em:id=' | sed s/'^.*em:id=\"\(.*\)\"'/'\1'/)" ]; then \
	#	echo "Bad uid"; \
	#	exit 1; \
	#fi
	
	# extension
	dh_installdirs -p$(p) usr/lib/mozilla-thunderbird/extensions/$(UID)/chrome/
	dh_install -p$(p) build/chrome/*.jar usr/lib/mozilla-thunderbird/extensions/$(UID)/chrome/
	dh_install -p$(p) build/install.rdf usr/lib/mozilla-thunderbird/extensions/$(UID)/
	dh_install -p$(p) build/defaults usr/lib/mozilla-thunderbird/extensions/$(UID)/
	
	# uninstall
	dh_installdirs -p$(p) usr/lib/mozilla-thunderbird/extensions/$(UID)/uninstall
	echo "" > debian/$(p)/usr/lib/mozilla-thunderbird/extensions/$(UID)/uninstall/Uninstall
	
	# extensions.d
	dh_installdirs -p$(p) var/lib/mozilla-thunderbird/extensions.d
	echo "extension,$(UID)" > debian/$(p)/var/lib/mozilla-thunderbird/extensions.d/50locale-ko-KR.txt
	
	# locales.d
	dh_installdirs -p$(p) var/lib/mozilla-thunderbird/locales.d
	echo "ko:KR" > debian/$(p)/var/lib/mozilla-thunderbird/locales.d/50locale-ko-KR.txt

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
