* app-crypt/ekeyd: Add
[portage-overlay.git] / app-crypt / ekeyd / ekeyd-1.1.4-r2.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://www.entropykey.co.uk/res/download/${P}.tar.gz"
12
13 LICENSE="MIT GPL-2" # GPL-2 (only) for init script
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="usb kernel_linux munin minimal"
17 REQUIRED_USE="minimal? ( !munin !usb )"
18
19 EKEYD_RDEPEND="dev-lang/lua
20                 usb? ( virtual/libusb:0 )"
21 EKEYD_DEPEND="${EKEYD_RDEPEND}"
22 EKEYD_RDEPEND="${EKEYD_RDEPEND}
23         dev-lua/luasocket
24         kernel_linux? ( virtual/udev )
25         usb? ( !kernel_linux? ( sys-apps/usbutils ) )
26         munin? ( net-analyzer/munin )"
27
28 RDEPEND="!minimal? ( ${EKEYD_RDEPEND} )
29         !app-crypt/ekey-egd-linux
30         sys-apps/openrc"
31 DEPEND="!minimal? ( ${EKEYD_DEPEND} )"
32
33 CONFIG_CHECK="~USB_ACM"
34
35 pkg_setup() {
36         if ! use minimal && use kernel_linux && ! use usb && linux_config_exists; then
37                 check_extra_config
38         fi
39 }
40
41 src_prepare() {
42         epatch "${FILESDIR}"/${P}-gentoo.patch
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=$(use usb && echo yes || echo 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 $(use usb && echo install-ekey-ulusbd)
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 usb && ! use kernel_linux; then
102                 newinitd "${FILESDIR}"/ekey-ulusbd.init.2 ekey-ulusbd
103                 newconfd "${FILESDIR}"/ekey-ulusbd.conf.2 ekey-ulusbd
104         fi
105
106         if use kernel_linux; then
107                 local rules=udev/fedora15/60-entropykey.rules
108                 use usb && rules=udev/fedora15/60-entropykey-uds.rules
109
110                 udev_newrules ${rules} 70-${PN}.rules
111
112                 exeinto "$(udev_get_udevdir)"
113                 doexe udev/entropykey.sh
114         fi
115
116         if use munin; then
117                 exeinto /usr/libexec/munin/plugins
118                 doexe munin/ekeyd_stat_
119
120                 insinto /etc/munin/plugin-conf.d
121                 newins munin/plugin-conf.d_ekeyd ekeyd
122         fi
123 }
124
125 pkg_postinst() {
126         elog "${CATEGORY}/${PN} now install also the EGD client service ekey-egd-linux."
127         elog "To use this service, you need enable EGDTCPSocket for the ekeyd service"
128         elog "managing the key(s)."
129         elog ""
130         elog "The daemon will send more entropy to the kernel once the available pool"
131         elog "falls below the value set in the kernel.random.write_wakeup_threshold"
132         elog "sysctl entry."
133         elog ""
134         ewarn "Since version 1.1.4-r1, ekey-egd-linux will *not* set the watermark for"
135         ewarn "you, instead you'll have to configure the sysctl in /etc/sysctl.conf"
136
137         use minimal && return
138         # from here on, document everything that is not part of the minimal
139         # support.
140
141         elog ""
142         elog "To make use of your EntropyKey, make sure to execute ekey-rekey"
143         elog "the first time, and then start the ekeyd service."
144         elog ""
145         elog "By default ekeyd will feed the entropy directly to the kernel's pool;"
146         elog "if your system has jumps in load average, you might prefer using the"
147         elog "EGD compatibility mode, by enabling EGDTCPSocket for ekeyd and then"
148         elog "starting the ekey-egd-linux service."
149         elog ""
150         elog "The same applies if you intend to provide entropy for multiple hosts"
151         elog "over the network. If you want to have the ekey-egd-linux service on"
152         elog "other hosts, you can enable the 'minimal' USE flag."
153         elog ""
154         elog "The service supports multiplexing if you wish to use multiple"
155         elog "keys, just symlink /etc/init.d/ekeyd → /etc/init.d/ekeyd.identifier"
156         elog "and it'll be looking for /etc/entropykey/identifier.conf"
157         elog ""
158
159         if use usb; then
160                 if use kernel_linux; then
161                         elog "You're going to use the userland USB daemon, the udev rules"
162                         elog "will be used accordingly. If you want to use the CDC driver"
163                         elog "please disable the usb USE flag."
164                 else
165                         elog "You're going to use the userland USB daemon, since your OS"
166                         elog "does not support udev, you should start the ekey-ulusbd"
167                         elog "service before ekeyd."
168                 fi
169
170                 ewarn "The userland USB daemon has multiple known issues. If you can,"
171                 ewarn "please consider disabling the 'usb' USE flag and instead use the"
172                 ewarn "CDC-ACM access method."
173         else
174                 if use kernel_linux; then
175                         elog "Some versions of Linux have a faulty CDC ACM driver that stops"
176                         elog "EntropyKey from working properly; please check the compatibility"
177                         elog "table at http://www.entropykey.co.uk/download/"
178                 else
179                         elog "Make sure your operating system supports the CDC ACM driver"
180                         elog "or otherwise you won't be able to use the EntropyKey."
181                 fi
182                 elog ""
183                 elog "If you're unsure about the working state of the CDC ACM driver"
184                 elog "enable the usb USE flag and use the userland USB daemon"
185         fi
186 }