e84927de941151f93fad077d185afa6dd3ecf2ca
[portage-overlay.git] / app-crypt / ekeyd / ekeyd-1.1.5.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/app-crypt/ekeyd/ekeyd-1.1.4-r2.ebuild,v 1.5 2012/12/11 08:42:46 ssuominen Exp $
4
5 EAPI=4
6
7 inherit eutils multilib linux-info toolchain-funcs udev
8
9 DESCRIPTION="Entropy Key userspace daemon"
10 HOMEPAGE="http://www.entropykey.co.uk/"
11 SRC_URI="http://archive.ubuntu.com/ubuntu/pool/universe/e/ekeyd/ekeyd_${PV}.orig.tar.gz"
12
13 LICENSE="MIT GPL-2" # GPL-2 (only) for init script
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="kernel_linux munin minimal"
17 REQUIRED_USE="minimal? ( !munin )"
18
19 EKEYD_RDEPEND="dev-lang/lua"
20 EKEYD_DEPEND="${EKEYD_RDEPEND}"
21 EKEYD_RDEPEND="${EKEYD_RDEPEND}
22         dev-lua/luasocket
23         kernel_linux? ( virtual/udev )
24         munin? ( net-analyzer/munin )"
25
26 RDEPEND="!minimal? ( ${EKEYD_RDEPEND} )
27         !app-crypt/ekey-egd-linux
28         sys-apps/openrc"
29 DEPEND="!minimal? ( ${EKEYD_DEPEND} )"
30
31 CONFIG_CHECK="~USB_ACM"
32
33 pkg_setup() {
34         if ! use minimal && use kernel_linux && ! use usb && linux_config_exists; then
35                 check_extra_config
36         fi
37 }
38
39 src_prepare() {
40         for i in `seq 1 6`; do
41                 epatch "${FILESDIR}/ekeyd-$i.patch";
42         done;
43 }
44
45 src_compile() {
46         local osname
47
48         # Override automatic detection: upstream provides this with uname,
49         # we don't like using uname.
50         case ${CHOST} in
51                 *-linux-*)
52                         osname=linux;;
53                 *-freebsd*)
54                         osname=freebsd;;
55                 *-kfrebsd-gnu)
56                         osname=gnukfreebsd;;
57                 *-openbsd*)
58                         osname=openbsd;;
59                 *)
60                         die "Unsupported operating system!"
61                         ;;
62         esac
63
64         # We don't slot LUA so we don't really need to have the variables
65         # set at all.
66         emake -C host \
67                 CC="$(tc-getCC)" \
68                 LUA_V= LUA_INC= \
69                 OSNAME=${osname} \
70                 OPT="${CFLAGS}" \
71                 BUILD_ULUSBD=no \
72                 $(use minimal && echo egd-linux)
73 }
74
75 src_install() {
76         exeinto /usr/libexec
77         newexe host/egd-linux   ekey-egd-linux
78         newman host/egd-linux.8 ekey-egd-linux.8
79
80         newconfd "${FILESDIR}"/ekey-egd-linux.conf.2 ekey-egd-linux
81         newinitd "${FILESDIR}"/ekey-egd-linux.init.2 ekey-egd-linux
82
83         dodoc doc/* AUTHORS ChangeLog THANKS
84
85         use minimal && return
86         # from here on, install everything that is not part of the minimal
87         # support.
88
89         emake -C host \
90                 DESTDIR="${D}" \
91                 MANZCMD=cat MANZEXT= \
92                 install-ekeyd
93
94         # We move the daemons around to avoid polluting the available
95         # commands.
96         dodir /usr/libexec
97         mv "${D}"/usr/sbin/ekey*d "${D}"/usr/libexec
98
99         newinitd "${FILESDIR}"/${PN}.init.2 ${PN}
100
101         if use kernel_linux; then
102                 local rules="${FILESDIR}/90-ekeyd.rules"
103                 udev_newrules ${rules} 90-${PN}.rules
104         fi
105
106         if use munin; then
107                 exeinto /usr/libexec/munin/plugins
108                 doexe munin/ekeyd_stat_
109
110                 insinto /etc/munin/plugin-conf.d
111                 newins munin/plugin-conf.d_ekeyd ekeyd
112         fi
113 }
114
115 pkg_postinst() {
116         elog "${CATEGORY}/${PN} now install also the EGD client service ekey-egd-linux."
117         elog "To use this service, you need enable EGDTCPSocket for the ekeyd service"
118         elog "managing the key(s)."
119         elog ""
120         elog "The daemon will send more entropy to the kernel once the available pool"
121         elog "falls below the value set in the kernel.random.write_wakeup_threshold"
122         elog "sysctl entry."
123         elog ""
124         ewarn "Since version 1.1.4-r1, ekey-egd-linux will *not* set the watermark for"
125         ewarn "you, instead you'll have to configure the sysctl in /etc/sysctl.conf"
126
127         use minimal && return
128         # from here on, document everything that is not part of the minimal
129         # support.
130
131         elog ""
132         elog "To make use of your EntropyKey, make sure to execute ekey-rekey"
133         elog "the first time, and then start the ekeyd service."
134         elog ""
135         elog "By default ekeyd will feed the entropy directly to the kernel's pool;"
136         elog "if your system has jumps in load average, you might prefer using the"
137         elog "EGD compatibility mode, by enabling EGDTCPSocket for ekeyd and then"
138         elog "starting the ekey-egd-linux service."
139         elog ""
140         elog "The same applies if you intend to provide entropy for multiple hosts"
141         elog "over the network. If you want to have the ekey-egd-linux service on"
142         elog "other hosts, you can enable the 'minimal' USE flag."
143         elog ""
144         elog "The service supports multiplexing if you wish to use multiple"
145         elog "keys, just symlink /etc/init.d/ekeyd → /etc/init.d/ekeyd.identifier"
146         elog "and it'll be looking for /etc/entropykey/identifier.conf"
147         elog ""
148
149                 if use kernel_linux; then
150                         elog "Some versions of Linux have a faulty CDC ACM driver that stops"
151                         elog "EntropyKey from working properly; please check the compatibility"
152                         elog "table at http://www.entropykey.co.uk/download/"
153                 else
154                         elog "Make sure your operating system supports the CDC ACM driver"
155                         elog "or otherwise you won't be able to use the EntropyKey."
156                 fi
157                 elog ""
158                 elog "If you're unsure about the working state of the CDC ACM driver"
159                 elog "enable the usb USE flag and use the userland USB daemon"
160 }