summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ee64d05d1369c1ee84e30753c654f0035bb83f46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Maintainer: Einhard Leichtfuß <alguien@respiranto.de>

# README:
#  * Building this package takes very long (a day or so) and consumes quite a
#    lot of RAM (> 7 GiB).
#    * Consider to use the corresponding -bin package instead.

_lang=eng-deu
pkgname="dict-freedict-${_lang}"
_dingver=1.9
_pkgver="${_dingver}-fd1"
pkgver="${_pkgver//-/_}"
pkgrel=1
pkgdesc="English -> German dictionary for dictd et al. from FreeDict.org"
arch=('any')
url="https://freedict.org/"
license=('GPL' 'AGPL3')
optdepends=('dictd: dict client and server')
makedepends=('freedict-tools>=1:0.6.0')
install="${pkgname}.install"
source=("ding-${_dingver}.gz::https://ftp.tu-chemnitz.de/pub/Local/urz/ding/de-en/de-en.txt.gz")
sha512sums=('172b61d4ee52ea14385608cca62891ecab22a4136aa5967654f56b5ef4c77c9f4feeb294396be43b7787133fabdfb2ace8648d2ee4fa877cf21ec566a0ef2b77')


_freedict_tools_dir=/usr/lib/freedict-tools
_ding2tei_dir="${_freedict_tools_dir}/importers/ding2tei"


prepare()
{
	mkdir -p dict/ding
	ln -s "${srcdir}/ding-${_dingver}" dict/ding/de-en.txt

	mkdir -p "dict/tei/${_lang}"
	ln -s "${_ding2tei_dir}/dict/tei/${_lang}/Makefile" "dict/tei/${_lang}/"
}


build()
{
	local _utf8_locale
	if [[ "$LANG" == *.UTF-8 ]]
	then
		_utf8_locale="$LANG"
	else
		_utf8_locale="$(localectl list-locales | grep '\.UTF-8$' | head -n 1)"
		if [[ "$_utf8_locale" == '' ]]
		then
			printf 'No UTF-8 locale available.  Cannot continue.'
			return 1
		fi
	fi

	# Build the TEI XML file.
	#  * ding2tei (incl. the preprocess scripts) needs a UTF-8 locale.
	#    - The tools operating on the built TEI XML should not need this.
	make -C "$_ding2tei_dir" -o ding2tei LC_ALL="$_utf8_locale" \
		dictdir="${srcdir}/dict" "${_lang}"

	# Build the DICT files (this takes very long).
	make -C "dict/tei/${_lang}" FREEDICT_TOOLS="$_freedict_tools_dir" \
		build-dictd
}


package()
{
	make -C "dict/tei/${_lang}" FREEDICT_TOOLS="$_freedict_tools_dir" \
		DESTDIR="$pkgdir" PREFIX=/usr install
}