# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=hunspell-en
pkgver=2017.01.22
pkgrel=0
pkgdesc="English hunspell dictionaries"
url="http://wordlist.aspell.net/dicts/"
arch="noarch"
license="LGPL-2.0-or-later scowl"
options="!check" # data only package
source="http://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_US-$pkgver.zip
        http://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_CA-$pkgver.zip
        http://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_GB-large-$pkgver.zip
	"

builddir="$srcdir"/$pkgname-$pkgver

unpack() {
	msg "Unpacking sources..."
	mkdir -p "$builddir"
	cd "$builddir"
	for u in $source; do
		local s="$SRCDEST/$(filename_from_uri $u)"
		unzip $s
	done
}

prepare() {
	cd "$builddir"
	default_prepare
	sed -i "s:SET UTF8:SET UTF-8:g"  *.aff
}

build() {
	:
}

package() {
	cd "$builddir"

	install -dm755 $pkgdir/usr/share/hunspell
	install -m644 en_*.dic en_*.aff $pkgdir/usr/share/hunspell

	local lang
	for lang in en_AG en_AU en_BS en_BW en_BZ en_DK en_GB en_GH en_HK en_IE en_IN en_JM en_NA en_NG en_NZ en_SG en_TT en_ZA en_ZW; do
		ln -svf en_GB-large.aff $pkgdir/usr/share/hunspell/$lang.aff
		ln -svf en_GB-large.dic $pkgdir/usr/share/hunspell/$lang.dic
	done
	for lang in en_PH; do
		ln -svf en_US.aff $pkgdir/usr/share/hunspell/$lang.aff
		ln -svf en_US.dic $pkgdir/usr/share/hunspell/$lang.dic
	done

	# docs
	install -dm755 ${pkgdir}/usr/share/doc/$pkgname
	install -m644 README_en_*.txt $pkgdir/usr/share/doc/$pkgname

	# licenses
	install -D -m644 README_en_US.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_US
	install -D -m644 README_en_CA.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_CA
	install -D -m644 README_en_GB-large.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_GB-large
}

sha512sums="1ac2160136cf914e3838bbe29949bd027276fdc8aa9fd3f79a74e037e9231f4a3ee1cb29b635a331ba7c1bc87d05d9809bbd44b2e82925430e2935a47507e635  hunspell-en_US-2017.01.22.zip
0d99ba9d427d0a7cc4752f0df686bbeac5295a028d03582ab741fd2e8d1691ffc735854a84ebd0f93e6e905d018eeaa540dce64d990a8b8be0135bd75358fdba  hunspell-en_CA-2017.01.22.zip
2200652e57a50e8b84dd2703871b03756b844afe210c7f95013ea07dbc760926e312a7bb5ade43c692025fff56cd11dc20bfd1f83bd492345973427af16a3e04  hunspell-en_GB-large-2017.01.22.zip"
