718e3c416c640aff577d9dbcc05623621bdb4d78
[gentoo.git] / app-text / dictd / dictd-1.12.1-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5 inherit eutils readme.gentoo systemd user
6
7 DESCRIPTION="Dictionary Client/Server for the DICT protocol"
8 HOMEPAGE="http://www.dict.org/ https://sourceforge.net/projects/dict/"
9 SRC_URI="mirror://sourceforge/dict/${P}.tar.gz"
10
11 SLOT="0"
12 # We install rfc so - ISOC-rfc
13 LICENSE="GPL-2 ISOC-rfc"
14 KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris"
15 IUSE="dbi judy minimal"
16
17 # <gawk-3.1.6 makes tests fail.
18 RDEPEND="
19         sys-libs/zlib
20         dev-libs/libmaa
21         dbi? ( dev-db/libdbi )
22         judy? ( dev-libs/judy )
23         >=sys-apps/coreutils-6.10
24 "
25 DEPEND="${RDEPEND}
26         >=sys-apps/gawk-3.1.6
27         virtual/yacc
28 "
29
30 DOC_CONTENTS="
31         To start and use ${PN} you need to emerge at least one dictionary from
32         the app-dicts category with the package name starting with 'dictd-'.
33         To install all available dictionaries, emerge app-dicts/dictd-dicts.
34         ${PN} will NOT start without at least one dictionary.\n
35         \nIf you are running systemd, you will need to review the instructions
36         explained in /etc/dict/dictd.conf comments.
37 "
38
39 pkg_setup() {
40         enewgroup dictd # used in src_test()
41         enewuser dictd -1 -1 -1 dictd
42 }
43
44 src_prepare() {
45         epatch "${FILESDIR}"/dictd-1.10.11-colorit-nopp-fix.patch
46         epatch "${FILESDIR}"/dictd-1.12.0-build.patch
47
48         [[ ${CHOST} == *-darwin* ]] && \
49                 sed -i -e 's:libtool:glibtool:g' Makefile.in
50 }
51
52 src_configure() {
53         econf \
54                 $(use_with dbi plugin-dbi) \
55                 $(use_with judy plugin-judy) \
56                 --sysconfdir="${EPREFIX}"/etc/dict
57 }
58
59 src_compile() {
60         if use minimal; then
61                 emake dictfmt dictzip dictzip
62         else
63                 emake
64         fi
65 }
66
67 src_test() {
68         use minimal && return 0 # All tests are for dictd which we don't build...
69         if [[ ${EUID} -eq 0 ]]; then
70                 # If dictd is run as root user (-userpriv) it drops its privileges to
71                 # dictd user and group. Give dictd group write access to test directory.
72                 chown :dictd "${WORKDIR}" "${S}/test"
73                 chmod 770 "${WORKDIR}" "${S}/test"
74         fi
75         emake test
76 }
77
78 src_install() {
79         if use minimal; then
80                 emake DESTDIR="${D}" install.dictzip install.dict install.dictfmt
81         else
82                 emake DESTDIR="${D}" install
83
84                 dodoc doc/{dicf.ms,rfc.ms,rfc.sh,rfc2229.txt}
85                 dodoc doc/{security.doc,toc.ms}
86                 newdoc examples/dictd1.conf dictd.conf.example
87
88                 # conf files. For dict.conf see below.
89                 insinto /etc/dict
90                 for f in dictd.conf site.info colorit.conf; do
91                         doins "${FILESDIR}/1.10.11/${f}"
92                 done
93
94                 # startups for dictd
95                 newinitd "${FILESDIR}/1.10.11/dictd.initd" dictd
96                 newconfd "${FILESDIR}/1.10.11/dictd.confd" dictd
97                 systemd_dounit "${FILESDIR}"/${PN}.service
98         fi
99
100         insinto /etc/dict
101         doins "${FILESDIR}/1.10.11/dict.conf"
102         # Install docs
103         dodoc README TODO ChangeLog ANNOUNCE NEWS
104
105         readme.gentoo_create_doc
106 }