4d3a433d0079b1d855b9d9d14dd58959ad5135e9
[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="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         for i in `seq 1 6`; do
43                 epatch "${FILESDIR}/ekeyd-$i.patch";
44         done;
45 }
46
47 src_compile() {
48         local osname
49
50         # Override automatic detection: upstream provides this with uname,
51         # we don't like using uname.
52         case ${CHOST} in
53                 *-linux-*)
54                         osname=linux;;
55                 *-freebsd*)
56                         osname=freebsd;;
57                 *-kfrebsd-gnu)
58                         osname=gnukfreebsd;;
59                 *-openbsd*)
60                         osname=openbsd;;
61                 *)
62                         die "Unsupported operating system!"
63                         ;;
64         esac
65
66         # We don't slot LUA so we don't really need to have the variables
67         # set at all.
68         emake -C host \
69                 CC="$(tc-getCC)" \
70                 LUA_V= LUA_INC= \
71                 OSNAME=${osname} \
72                 OPT="${CFLAGS}" \
73                 BUILD_ULUSBD=$(use usb && echo yes || echo no) \
74                 $(use minimal && echo egd-linux)
75 }
76
77 src_install() {
78         exeinto /usr/libexec
79         newexe host/egd-linux   ekey-egd-linux
80         newman host/egd-linux.8 ekey-egd-linux.8
81
82         newconfd "${FILESDIR}"/ekey-egd-linux.conf.2 ekey-egd-linux
83         newinitd "${FILESDIR}"/ekey-egd-linux.init.2 ekey-egd-linux
84
85         dodoc doc/* AUTHORS ChangeLog THANKS
86
87         use minimal && return
88         # from here on, install everything that is not part of the minimal
89         # support.
90
91         emake -C host \
92                 DESTDIR="${D}" \
93                 MANZCMD=cat MANZEXT= \
94                 install-ekeyd $(use usb && echo install-ekey-ulusbd)
95
96         # We move the daemons around to avoid polluting the available
97         # commands.
98         dodir /usr/libexec
99         mv "${D}"/usr/sbin/ekey*d "${D}"/usr/libexec
100
101         newinitd "${FILESDIR}"/${PN}.init.2 ${PN}
102
103         if use usb && ! use kernel_linux; then
104                 newinitd "${FILESDIR}"/ekey-ulusbd.init.2 ekey-ulusbd
105                 newconfd "${FILESDIR}"/ekey-ulusbd.conf.2 ekey-ulusbd
106         fi
107
108         if use kernel_linux; then
109                 local rules="${FILESDIR}/90-ekeyd.rules"
110
111                 udev_newrules ${rules} 90-${PN}.rules
112         fi
113
114         if use munin; then
115                 exeinto /usr/libexec/munin/plugins
116                 doexe munin/ekeyd_stat_
117
118                 insinto /etc/munin/plugin-conf.d
119                 newins munin/plugin-conf.d_ekeyd ekeyd
120         fi
121 }
122
123 pkg_postinst() {
124         elog "${CATEGORY}/${PN} now install also the EGD client service ekey-egd-linux."
125         elog "To use this service, you need enable EGDTCPSocket for the ekeyd service"
126         elog "managing the key(s)."
127         elog ""
128         elog "The daemon will send more entropy to the kernel once the available pool"
129         elog "falls below the value set in the kernel.random.write_wakeup_threshold"
130         elog "sysctl entry."
131         elog ""
132         ewarn "Since version 1.1.4-r1, ekey-egd-linux will *not* set the watermark for"
133         ewarn "you, instead you'll have to configure the sysctl in /etc/sysctl.conf"
134
135         use minimal && return
136         # from here on, document everything that is not part of the minimal
137         # support.
138
139         elog ""
140         elog "To make use of your EntropyKey, make sure to execute ekey-rekey"
141         elog "the first time, and then start the ekeyd service."
142         elog ""
143         elog "By default ekeyd will feed the entropy directly to the kernel's pool;"
144         elog "if your system has jumps in load average, you might prefer using the"
145         elog "EGD compatibility mode, by enabling EGDTCPSocket for ekeyd and then"
146         elog "starting the ekey-egd-linux service."
147         elog ""
148         elog "The same applies if you intend to provide entropy for multiple hosts"
149         elog "over the network. If you want to have the ekey-egd-linux service on"
150         elog "other hosts, you can enable the 'minimal' USE flag."
151         elog ""
152         elog "The service supports multiplexing if you wish to use multiple"
153         elog "keys, just symlink /etc/init.d/ekeyd → /etc/init.d/ekeyd.identifier"
154         elog "and it'll be looking for /etc/entropykey/identifier.conf"
155         elog ""
156
157         if use usb; then
158                 if use kernel_linux; then
159                         elog "You're going to use the userland USB daemon, the udev rules"
160                         elog "will be used accordingly. If you want to use the CDC driver"
161                         elog "please disable the usb USE flag."
162                 else
163                         elog "You're going to use the userland USB daemon, since your OS"
164                         elog "does not support udev, you should start the ekey-ulusbd"
165                         elog "service before ekeyd."
166                 fi
167
168                 ewarn "The userland USB daemon has multiple known issues. If you can,"
169                 ewarn "please consider disabling the 'usb' USE flag and instead use the"
170                 ewarn "CDC-ACM access method."
171         else
172                 if use kernel_linux; then
173                         elog "Some versions of Linux have a faulty CDC ACM driver that stops"
174                         elog "EntropyKey from working properly; please check the compatibility"
175                         elog "table at http://www.entropykey.co.uk/download/"
176                 else
177                         elog "Make sure your operating system supports the CDC ACM driver"
178                         elog "or otherwise you won't be able to use the EntropyKey."
179                 fi
180                 elog ""
181                 elog "If you're unsure about the working state of the CDC ACM driver"
182                 elog "enable the usb USE flag and use the userland USB daemon"
183         fi
184 }