1 |
commit: 68314d83425089bd375fc5c539a72ba40f12b044 |
2 |
Author: Matthew Thode <prometheanfire <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 27 17:15:28 2019 +0000 |
4 |
Commit: Matthew Thode <prometheanfire <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 27 17:15:41 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68314d83 |
7 |
|
8 |
sys-power/nut: 2.7.4-r3 for openssl-1.1 support |
9 |
|
10 |
Package-Manager: Portage-2.3.66, Repoman-2.3.16 |
11 |
Signed-off-by: Matthew Thode <prometheanfire <AT> gentoo.org> |
12 |
|
13 |
sys-power/nut/files/nut-openssl-1.1-support.patch | 333 ++++++++++++++++++++++ |
14 |
sys-power/nut/nut-2.7.4-r3.ebuild | 297 +++++++++++++++++++ |
15 |
2 files changed, 630 insertions(+) |
16 |
|
17 |
diff --git a/sys-power/nut/files/nut-openssl-1.1-support.patch b/sys-power/nut/files/nut-openssl-1.1-support.patch |
18 |
new file mode 100644 |
19 |
index 00000000000..71e1bf47f1b |
20 |
--- /dev/null |
21 |
+++ b/sys-power/nut/files/nut-openssl-1.1-support.patch |
22 |
@@ -0,0 +1,333 @@ |
23 |
+From da1f5aa699f54e0f6977ab64a3bc2f90a51c3104 Mon Sep 17 00:00:00 2001 |
24 |
+From: Arjen de Korte <build+lede@××××××××.org> |
25 |
+Date: Mon, 27 Nov 2017 21:10:13 +0100 |
26 |
+Subject: [PATCH 1/7] Add support for openssl-1.1.0 |
27 |
+ |
28 |
+--- |
29 |
+ clients/upsclient.c | 4 ++++ |
30 |
+ m4/nut_check_libopenssl.m4 | 5 +++-- |
31 |
+ server/netssl.c | 4 ++++ |
32 |
+ 3 files changed, 11 insertions(+), 2 deletions(-) |
33 |
+ |
34 |
+diff --git a/clients/upsclient.c b/clients/upsclient.c |
35 |
+index b90587b00..fc5e7523c 100644 |
36 |
+--- a/clients/upsclient.c |
37 |
++++ b/clients/upsclient.c |
38 |
+@@ -316,7 +316,11 @@ int upscli_init(int certverify, const char *certpath, |
39 |
+ |
40 |
+ #ifdef WITH_OPENSSL |
41 |
+ |
42 |
++#if OPENSSL_VERSION_NUMBER < 0x10100000L |
43 |
+ SSL_library_init(); |
44 |
++#else |
45 |
++ OPENSSL_init_ssl(0, NULL); |
46 |
++#endif |
47 |
+ SSL_load_error_strings(); |
48 |
+ |
49 |
+ ssl_method = TLSv1_client_method(); |
50 |
+diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 |
51 |
+index 1b875077b..5f29f4a38 100644 |
52 |
+--- a/m4/nut_check_libopenssl.m4 |
53 |
++++ b/m4/nut_check_libopenssl.m4 |
54 |
+@@ -57,8 +57,9 @@ if test -z "${nut_have_libopenssl_seen}"; then |
55 |
+ AC_MSG_RESULT([${LIBS}]) |
56 |
+ |
57 |
+ dnl check if openssl is usable |
58 |
+- AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) |
59 |
+- AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no]) |
60 |
++ AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) |
61 |
++ AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) |
62 |
++ AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) |
63 |
+ |
64 |
+ if test "${nut_have_openssl}" = "yes"; then |
65 |
+ nut_with_ssl="yes" |
66 |
+diff --git a/server/netssl.c b/server/netssl.c |
67 |
+index c2f409899..0f9a70acf 100644 |
68 |
+--- a/server/netssl.c |
69 |
++++ b/server/netssl.c |
70 |
+@@ -388,7 +388,11 @@ void ssl_init(void) |
71 |
+ #ifdef WITH_OPENSSL |
72 |
+ |
73 |
+ SSL_load_error_strings(); |
74 |
++#if OPENSSL_VERSION_NUMBER < 0x10100000L |
75 |
+ SSL_library_init(); |
76 |
++#else |
77 |
++ OPENSSL_init_ssl(0, NULL); |
78 |
++#endif |
79 |
+ |
80 |
+ if ((ssl_method = TLSv1_server_method()) == NULL) { |
81 |
+ ssl_debug(); |
82 |
+ |
83 |
+From b15656efb2575647ca0e0b6439b6380373767b8f Mon Sep 17 00:00:00 2001 |
84 |
+From: Arjen de Korte <build+lede@××××××××.org> |
85 |
+Date: Tue, 28 Nov 2017 20:00:52 +0100 |
86 |
+Subject: [PATCH 2/7] Allow TLSv1 and higher (not just TLSv1) |
87 |
+ |
88 |
+--- |
89 |
+ clients/upsclient.c | 30 +++++++++++++++++------------- |
90 |
+ server/netssl.c | 26 +++++++++++++++----------- |
91 |
+ 2 files changed, 32 insertions(+), 24 deletions(-) |
92 |
+ |
93 |
+diff --git a/clients/upsclient.c b/clients/upsclient.c |
94 |
+index fc5e7523c..bd951e854 100644 |
95 |
+--- a/clients/upsclient.c |
96 |
++++ b/clients/upsclient.c |
97 |
+@@ -299,11 +299,6 @@ int upscli_init(int certverify, const char *certpath, |
98 |
+ { |
99 |
+ #ifdef WITH_OPENSSL |
100 |
+ int ret, ssl_mode = SSL_VERIFY_NONE; |
101 |
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L |
102 |
+- const SSL_METHOD *ssl_method; |
103 |
+-#else |
104 |
+- SSL_METHOD *ssl_method; |
105 |
+-#endif |
106 |
+ #elif defined(WITH_NSS) /* WITH_OPENSSL */ |
107 |
+ SECStatus status; |
108 |
+ #endif /* WITH_OPENSSL | WITH_NSS */ |
109 |
+@@ -315,26 +310,35 @@ int upscli_init(int certverify, const char *certpath, |
110 |
+ } |
111 |
+ |
112 |
+ #ifdef WITH_OPENSSL |
113 |
++ |
114 |
++ SSL_load_error_strings(); |
115 |
+ |
116 |
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L |
117 |
+ SSL_library_init(); |
118 |
++ |
119 |
++ ssl_ctx = SSL_CTX_new(SSLv23_client_method()); |
120 |
+ #else |
121 |
+ OPENSSL_init_ssl(0, NULL); |
122 |
+-#endif |
123 |
+- SSL_load_error_strings(); |
124 |
+ |
125 |
+- ssl_method = TLSv1_client_method(); |
126 |
+- |
127 |
+- if (!ssl_method) { |
128 |
+- return 0; |
129 |
+- } |
130 |
++ ssl_ctx = SSL_CTX_new(TLS_client_method()); |
131 |
++#endif |
132 |
+ |
133 |
+- ssl_ctx = SSL_CTX_new(ssl_method); |
134 |
+ if (!ssl_ctx) { |
135 |
+ upslogx(LOG_ERR, "Can not initialize SSL context"); |
136 |
+ return -1; |
137 |
+ } |
138 |
+ |
139 |
++#if OPENSSL_VERSION_NUMBER < 0x10100000L |
140 |
++ /* set minimum protocol TLSv1 */ |
141 |
++ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); |
142 |
++#else |
143 |
++ ret = SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION); |
144 |
++ if (ret != 1) { |
145 |
++ upslogx(LOG_ERR, "Can not set minimum protocol to TLSv1"); |
146 |
++ return -1; |
147 |
++ } |
148 |
++#endif |
149 |
++ |
150 |
+ if (!certpath) { |
151 |
+ if (certverify == 1) { |
152 |
+ upslogx(LOG_ERR, "Can not verify certificate if any is specified"); |
153 |
+diff --git a/server/netssl.c b/server/netssl.c |
154 |
+index 0f9a70acf..98680d25e 100644 |
155 |
+--- a/server/netssl.c |
156 |
++++ b/server/netssl.c |
157 |
+@@ -371,13 +371,7 @@ void ssl_init(void) |
158 |
+ { |
159 |
+ #ifdef WITH_NSS |
160 |
+ SECStatus status; |
161 |
+-#elif defined(WITH_OPENSSL) |
162 |
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L |
163 |
+- const SSL_METHOD *ssl_method; |
164 |
+-#else |
165 |
+- SSL_METHOD *ssl_method; |
166 |
+-#endif |
167 |
+-#endif /* WITH_NSS|WITH_OPENSSL */ |
168 |
++#endif /* WITH_NSS */ |
169 |
+ |
170 |
+ if (!certfile) { |
171 |
+ return; |
172 |
+@@ -388,21 +382,31 @@ void ssl_init(void) |
173 |
+ #ifdef WITH_OPENSSL |
174 |
+ |
175 |
+ SSL_load_error_strings(); |
176 |
++ |
177 |
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L |
178 |
+ SSL_library_init(); |
179 |
++ |
180 |
++ ssl_ctx = SSL_CTX_new(SSLv23_server_method()); |
181 |
+ #else |
182 |
+ OPENSSL_init_ssl(0, NULL); |
183 |
++ |
184 |
++ ssl_ctx = SSL_CTX_new(TLS_server_method()); |
185 |
+ #endif |
186 |
+ |
187 |
+- if ((ssl_method = TLSv1_server_method()) == NULL) { |
188 |
++ if (!ssl_ctx) { |
189 |
+ ssl_debug(); |
190 |
+- fatalx(EXIT_FAILURE, "TLSv1_server_method failed"); |
191 |
++ fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); |
192 |
+ } |
193 |
+ |
194 |
+- if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) { |
195 |
++#if OPENSSL_VERSION_NUMBER < 0x10100000L |
196 |
++ /* set minimum protocol TLSv1 */ |
197 |
++ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); |
198 |
++#else |
199 |
++ if (SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION) != 1) { |
200 |
+ ssl_debug(); |
201 |
+- fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); |
202 |
++ fatalx(EXIT_FAILURE, "SSL_CTX_set_min_proto_version(TLS1_VERSION)"); |
203 |
+ } |
204 |
++#endif |
205 |
+ |
206 |
+ if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certfile) != 1) { |
207 |
+ ssl_debug(); |
208 |
+ |
209 |
+From 5a8308aef9884017754fb70620c8ded34fa44290 Mon Sep 17 00:00:00 2001 |
210 |
+From: Arjen de Korte <build+lede@××××××××.org> |
211 |
+Date: Tue, 28 Nov 2017 22:01:41 +0100 |
212 |
+Subject: [PATCH 3/7] Fix check for empty string |
213 |
+ |
214 |
+--- |
215 |
+ clients/upssched.c | 2 +- |
216 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
217 |
+ |
218 |
+diff --git a/clients/upssched.c b/clients/upssched.c |
219 |
+index 97b3ed42d..3fdf118ed 100644 |
220 |
+--- a/clients/upssched.c |
221 |
++++ b/clients/upssched.c |
222 |
+@@ -794,7 +794,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, |
223 |
+ } |
224 |
+ |
225 |
+ if (!strcmp(cmd, "EXECUTE")) { |
226 |
+- if (ca1 == '\0') { |
227 |
++ if (ca1[0] == '\0') { |
228 |
+ upslogx(LOG_ERR, "Empty EXECUTE command argument"); |
229 |
+ return; |
230 |
+ } |
231 |
+ |
232 |
+From 5ecfb0ffe3d89a5116dd287ff2c3f60de67ecbb9 Mon Sep 17 00:00:00 2001 |
233 |
+From: Arjen de Korte <build+github@××××××××.org> |
234 |
+Date: Fri, 1 Dec 2017 12:24:00 +0100 |
235 |
+Subject: [PATCH 4/7] Report TLS handshake in debug mode |
236 |
+ |
237 |
+--- |
238 |
+ clients/upsclient.c | 2 +- |
239 |
+ server/netssl.c | 2 +- |
240 |
+ 2 files changed, 2 insertions(+), 2 deletions(-) |
241 |
+ |
242 |
+diff --git a/clients/upsclient.c b/clients/upsclient.c |
243 |
+index bd951e854..b7dd8f424 100644 |
244 |
+--- a/clients/upsclient.c |
245 |
++++ b/clients/upsclient.c |
246 |
+@@ -745,7 +745,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) |
247 |
+ switch(res) |
248 |
+ { |
249 |
+ case 1: |
250 |
+- upsdebugx(3, "SSL connected"); |
251 |
++ upsdebugx(3, "SSL connected (%s)", SSL_get_version(ups->ssl)); |
252 |
+ break; |
253 |
+ case 0: |
254 |
+ upslog_with_errno(1, "SSL_connect do not accept handshake."); |
255 |
+diff --git a/server/netssl.c b/server/netssl.c |
256 |
+index 98680d25e..6ae13e8d3 100644 |
257 |
+--- a/server/netssl.c |
258 |
++++ b/server/netssl.c |
259 |
+@@ -275,7 +275,7 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) |
260 |
+ { |
261 |
+ case 1: |
262 |
+ client->ssl_connected = 1; |
263 |
+- upsdebugx(3, "SSL connected"); |
264 |
++ upsdebugx(3, "SSL connected (%s)", SSL_get_version(client->ssl)); |
265 |
+ break; |
266 |
+ |
267 |
+ case 0: |
268 |
+ |
269 |
+From ab0c8b41c0530d3706e4997257939026cfd29ccc Mon Sep 17 00:00:00 2001 |
270 |
+From: Arjen de Korte <build+github@××××××××.org> |
271 |
+Date: Sun, 24 Feb 2019 18:31:21 +0100 |
272 |
+Subject: [PATCH 5/7] Update nut_check_libopenssl.m4 |
273 |
+ |
274 |
+--- |
275 |
+ m4/nut_check_libopenssl.m4 | 5 ++--- |
276 |
+ 1 file changed, 2 insertions(+), 3 deletions(-) |
277 |
+ |
278 |
+diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 |
279 |
+index 5f29f4a38..7eb401cd9 100644 |
280 |
+--- a/m4/nut_check_libopenssl.m4 |
281 |
++++ b/m4/nut_check_libopenssl.m4 |
282 |
+@@ -57,9 +57,8 @@ if test -z "${nut_have_libopenssl_seen}"; then |
283 |
+ AC_MSG_RESULT([${LIBS}]) |
284 |
+ |
285 |
+ dnl check if openssl is usable |
286 |
+- AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) |
287 |
+- AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) |
288 |
+- AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) |
289 |
++ AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) |
290 |
++ AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no]) |
291 |
+ |
292 |
+ if test "${nut_have_openssl}" = "yes"; then |
293 |
+ nut_with_ssl="yes" |
294 |
+ |
295 |
+From 1dc34a5da7308f0f85537a6761fefb3ff3098863 Mon Sep 17 00:00:00 2001 |
296 |
+From: Arjen de Korte <build+github@××××××××.org> |
297 |
+Date: Sun, 24 Feb 2019 18:34:53 +0100 |
298 |
+Subject: [PATCH 6/7] Update upsclient.c |
299 |
+ |
300 |
+--- |
301 |
+ clients/upsclient.c | 5 +---- |
302 |
+ 1 file changed, 1 insertion(+), 4 deletions(-) |
303 |
+ |
304 |
+diff --git a/clients/upsclient.c b/clients/upsclient.c |
305 |
+index b7dd8f424..541664f36 100644 |
306 |
+--- a/clients/upsclient.c |
307 |
++++ b/clients/upsclient.c |
308 |
+@@ -311,15 +311,12 @@ int upscli_init(int certverify, const char *certpath, |
309 |
+ |
310 |
+ #ifdef WITH_OPENSSL |
311 |
+ |
312 |
+- SSL_load_error_strings(); |
313 |
+- |
314 |
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L |
315 |
++ SSL_load_error_strings(); |
316 |
+ SSL_library_init(); |
317 |
+ |
318 |
+ ssl_ctx = SSL_CTX_new(SSLv23_client_method()); |
319 |
+ #else |
320 |
+- OPENSSL_init_ssl(0, NULL); |
321 |
+- |
322 |
+ ssl_ctx = SSL_CTX_new(TLS_client_method()); |
323 |
+ #endif |
324 |
+ |
325 |
+ |
326 |
+From 108c31c9b170da2ee34a25fd373d21837d4d10a3 Mon Sep 17 00:00:00 2001 |
327 |
+From: Arjen de Korte <build+github@××××××××.org> |
328 |
+Date: Sun, 24 Feb 2019 18:37:42 +0100 |
329 |
+Subject: [PATCH 7/7] Update netssl.c |
330 |
+ |
331 |
+--- |
332 |
+ server/netssl.c | 5 +---- |
333 |
+ 1 file changed, 1 insertion(+), 4 deletions(-) |
334 |
+ |
335 |
+diff --git a/server/netssl.c b/server/netssl.c |
336 |
+index 6ae13e8d3..cf9419edf 100644 |
337 |
+--- a/server/netssl.c |
338 |
++++ b/server/netssl.c |
339 |
+@@ -381,15 +381,12 @@ void ssl_init(void) |
340 |
+ |
341 |
+ #ifdef WITH_OPENSSL |
342 |
+ |
343 |
+- SSL_load_error_strings(); |
344 |
+- |
345 |
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L |
346 |
++ SSL_load_error_strings(); |
347 |
+ SSL_library_init(); |
348 |
+ |
349 |
+ ssl_ctx = SSL_CTX_new(SSLv23_server_method()); |
350 |
+ #else |
351 |
+- OPENSSL_init_ssl(0, NULL); |
352 |
+- |
353 |
+ ssl_ctx = SSL_CTX_new(TLS_server_method()); |
354 |
+ #endif |
355 |
+ |
356 |
|
357 |
diff --git a/sys-power/nut/nut-2.7.4-r3.ebuild b/sys-power/nut/nut-2.7.4-r3.ebuild |
358 |
new file mode 100644 |
359 |
index 00000000000..5364ad86e5c |
360 |
--- /dev/null |
361 |
+++ b/sys-power/nut/nut-2.7.4-r3.ebuild |
362 |
@@ -0,0 +1,297 @@ |
363 |
+# Copyright 1999-2019 Gentoo Authors |
364 |
+# Distributed under the terms of the GNU General Public License v2 |
365 |
+ |
366 |
+EAPI=7 |
367 |
+ |
368 |
+PYTHON_COMPAT=( python2_7 ) |
369 |
+inherit autotools bash-completion-r1 desktop fixheadtails flag-o-matic python-single-r1 systemd toolchain-funcs user |
370 |
+ |
371 |
+MY_P=${P/_/-} |
372 |
+ |
373 |
+DESCRIPTION="Network-UPS Tools" |
374 |
+HOMEPAGE="https://www.networkupstools.org/" |
375 |
+SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz" |
376 |
+LICENSE="GPL-2" |
377 |
+SLOT="0" |
378 |
+KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd" |
379 |
+ |
380 |
+IUSE="cgi gui ipmi snmp +usb selinux ssl tcpd xml zeroconf" |
381 |
+REQUIRED_USE="gui? ( ${PYTHON_REQUIRED_USE} )" |
382 |
+ |
383 |
+DEPEND=" |
384 |
+ dev-libs/libltdl:* |
385 |
+ net-libs/libnsl |
386 |
+ virtual/udev |
387 |
+ cgi? ( >=media-libs/gd-2[png] ) |
388 |
+ gui? ( dev-python/pygtk[${PYTHON_USEDEP}] ) |
389 |
+ ipmi? ( sys-libs/freeipmi ) |
390 |
+ snmp? ( net-analyzer/net-snmp ) |
391 |
+ ssl? ( >=dev-libs/openssl-1:= ) |
392 |
+ tcpd? ( sys-apps/tcp-wrappers ) |
393 |
+ usb? ( virtual/libusb:0= ) |
394 |
+ xml? ( >=net-libs/neon-0.25.0 ) |
395 |
+ zeroconf? ( net-dns/avahi )" |
396 |
+ |
397 |
+BDEPEND=" |
398 |
+ virtual/pkgconfig |
399 |
+ >=sys-apps/sed-4" |
400 |
+ |
401 |
+RDEPEND="${DEPEND} |
402 |
+ selinux? ( sec-policy/selinux-nut )" |
403 |
+ |
404 |
+S="${WORKDIR}/${MY_P}" |
405 |
+ |
406 |
+# Bug #480664 requested UPS_DRIVERS_IUSE for more flexibility in building this package |
407 |
+SERIAL_DRIVERLIST="al175 bcmxcp belkin belkinunv bestfcom bestfortress bestuferrups bestups dummy-ups etapro everups gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino safenet solis tripplite tripplitesu upscode2 victronups powerpanel blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser nutdrv_qx" |
408 |
+SNMP_DRIVERLIST="snmp-ups" |
409 |
+USB_LIBUSB_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb richcomm_usb riello_usb nutdrv_qx" |
410 |
+USB_DRIVERLIST=${USB_LIBUSB_DRIVERLIST} |
411 |
+#HAL_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb riello_usb nutdrv_qx" |
412 |
+NEONXML_DRIVERLIST="netxml-ups" |
413 |
+IPMI_DRIVERLIST="nut-ipmipsu" |
414 |
+# Now we build from it: |
415 |
+for name in ${SERIAL_DRIVERLIST} ; do |
416 |
+ IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}" |
417 |
+done |
418 |
+for name in ${USB_DRIVERLIST} ; do |
419 |
+ IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}" |
420 |
+ REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( usb )" |
421 |
+done |
422 |
+for name in ${NEONXML_DRIVERLIST}; do |
423 |
+ IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}" |
424 |
+ REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( xml )" |
425 |
+done |
426 |
+for name in ${SNMP_DRIVERLIST} ; do |
427 |
+ IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}" |
428 |
+ REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( snmp )" |
429 |
+done |
430 |
+for name in ${IPMI_DRIVERLIST} ; do |
431 |
+ IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}" |
432 |
+ REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( ipmi )" |
433 |
+done |
434 |
+IUSE="${IUSE} ${IUSE_UPS_DRIVERS}" |
435 |
+ |
436 |
+# public files should be 644 root:root |
437 |
+NUT_PUBLIC_FILES="/etc/nut/{ups,upssched}.conf" |
438 |
+# private files should be 640 root:nut - readable by nut, writeable by root, |
439 |
+NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}" |
440 |
+# public files should be 644 root:root, only installed if USE=cgi |
441 |
+NUT_CGI_FILES="/etc/nut/{{hosts,upsset}.conf,upsstats{,-single}.html}" |
442 |
+ |
443 |
+PATCHES=( |
444 |
+ "${FILESDIR}/${PN}-2.7.2-no-libdummy.patch" |
445 |
+ "${FILESDIR}/${PN}-2.7.1-snmpusb-order.patch" |
446 |
+ "${FILESDIR}/${PN}-2.6.2-lowspeed-buffer-size.patch" |
447 |
+ "${FILESDIR}/nut-openssl-1.1-support.patch" |
448 |
+) |
449 |
+ |
450 |
+pkg_setup() { |
451 |
+ enewgroup nut 84 |
452 |
+ enewuser nut 84 -1 /var/lib/nut nut,uucp |
453 |
+ # As of udev-104, NUT must be in uucp and NOT in tty. |
454 |
+ gpasswd -d nut tty 2>/dev/null |
455 |
+ gpasswd -a nut uucp 2>/dev/null |
456 |
+ # in some cases on old systems it wasn't in the nut group either! |
457 |
+ gpasswd -a nut nut 2>/dev/null |
458 |
+ warningmsg ewarn |
459 |
+ use gui && python-single-r1_pkg_setup |
460 |
+} |
461 |
+ |
462 |
+src_prepare() { |
463 |
+ default |
464 |
+ |
465 |
+ sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \ |
466 |
+ -e '/systemdsystemunitdir=.*echo.*sed.*libdir/s,^,#,g' \ |
467 |
+ -i configure.ac || die |
468 |
+ |
469 |
+ sed -e "s:52.nut-usbups.rules:70-nut-usbups.rules:" \ |
470 |
+ -i scripts/udev/Makefile.am || die |
471 |
+ |
472 |
+ rm ltmain.sh m4/lt* m4/libtool.m4 || die |
473 |
+ |
474 |
+ sed -e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \ |
475 |
+ -i lib/libupsclient{.pc,-config}.in || die #361685 |
476 |
+ |
477 |
+ use gui && eapply "${FILESDIR}"/NUT-Monitor-1.3-paths.patch |
478 |
+ |
479 |
+ eautoreconf |
480 |
+} |
481 |
+ |
482 |
+src_configure() { |
483 |
+ local myconf |
484 |
+ append-flags -fno-lto |
485 |
+ tc-export CC |
486 |
+ tc-export CXX |
487 |
+ tc-export AR |
488 |
+ |
489 |
+ local UPS_DRIVERS="" |
490 |
+ for u in $USE ; do |
491 |
+ u2=${u#ups_drivers_} |
492 |
+ [[ "${u}" != "${u2}" ]] && UPS_DRIVERS="${UPS_DRIVERS} ${u2}" |
493 |
+ done |
494 |
+ UPS_DRIVERS="${UPS_DRIVERS# }" UPS_DRIVERS="${UPS_DRIVERS% }" |
495 |
+ myconf="${myconf} --with-drivers=${UPS_DRIVERS// /,}" |
496 |
+ |
497 |
+ use cgi && myconf="${myconf} --with-cgipath=/usr/share/nut/cgi" |
498 |
+ |
499 |
+ # TODO: USE flag for sys-power/powerman |
500 |
+ econf \ |
501 |
+ --sysconfdir=/etc/nut \ |
502 |
+ --datarootdir=/usr/share/nut \ |
503 |
+ --datadir=/usr/share/nut \ |
504 |
+ --disable-static \ |
505 |
+ --with-statepath=/var/lib/nut \ |
506 |
+ --with-drvpath=/$(get_libdir)/nut \ |
507 |
+ --with-htmlpath=/usr/share/nut/html \ |
508 |
+ --with-user=nut \ |
509 |
+ --with-group=nut \ |
510 |
+ --with-logfacility=LOG_DAEMON \ |
511 |
+ --with-dev \ |
512 |
+ --with-serial \ |
513 |
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \ |
514 |
+ --without-powerman \ |
515 |
+ $(use_with cgi) \ |
516 |
+ $(use_with ipmi) \ |
517 |
+ $(use_with ipmi freeipmi) \ |
518 |
+ $(use_with snmp) \ |
519 |
+ $(use_with ssl) \ |
520 |
+ $(use_with tcpd wrap) \ |
521 |
+ $(use_with usb) \ |
522 |
+ $(use_with xml neon) \ |
523 |
+ $(use_with zeroconf avahi) \ |
524 |
+ ${myconf} |
525 |
+} |
526 |
+ |
527 |
+src_install() { |
528 |
+ emake DESTDIR="${D}" install |
529 |
+ |
530 |
+ find "${D}" -name '*.la' -delete || die |
531 |
+ |
532 |
+ dodir /sbin |
533 |
+ dosym ../usr/sbin/upsdrvctl /sbin/upsdrvctl |
534 |
+ |
535 |
+ if use cgi; then |
536 |
+ elog "CGI monitoring scripts are installed in /usr/share/nut/cgi." |
537 |
+ elog "copy them to your web server's ScriptPath to activate (this is a" |
538 |
+ elog "change from the old location)." |
539 |
+ elog "If you use lighttpd, see lighttpd_nut.conf in the documentation." |
540 |
+ fi |
541 |
+ |
542 |
+ if use gui; then |
543 |
+ python_fix_shebang scripts/python/app |
544 |
+ python_domodule scripts/python/module/PyNUT.py |
545 |
+ python_doscript scripts/python/app/NUT-Monitor |
546 |
+ |
547 |
+ insinto /usr/share/nut |
548 |
+ doins scripts/python/app/gui-1.3.glade |
549 |
+ |
550 |
+ dodir /usr/share/nut/pixmaps |
551 |
+ insinto /usr/share/nut/pixmaps |
552 |
+ doins scripts/python/app/pixmaps/* |
553 |
+ |
554 |
+ sed -i -e 's/nut-monitor.png/nut-monitor/' -e 's/Application;//' \ |
555 |
+ scripts/python/app/${PN}-monitor.desktop || die |
556 |
+ |
557 |
+ doicon scripts/python/app/${PN}-monitor.png |
558 |
+ domenu scripts/python/app/${PN}-monitor.desktop |
559 |
+ fi |
560 |
+ |
561 |
+ # this must be done after all of the install phases |
562 |
+ for i in "${D}"/etc/nut/*.sample ; do |
563 |
+ mv "${i}" "${i/.sample/}" || die |
564 |
+ done |
565 |
+ |
566 |
+ local DOCS=( AUTHORS ChangeLog docs/*.txt MAINTAINERS NEWS README TODO UPGRADING ) |
567 |
+ einstalldocs |
568 |
+ |
569 |
+ newdoc lib/README README.lib |
570 |
+ newdoc "${FILESDIR}"/lighttpd_nut.conf-2.2.0 lighttpd_nut.conf |
571 |
+ |
572 |
+ docinto cables |
573 |
+ dodoc docs/cables/* |
574 |
+ |
575 |
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsd upsd |
576 |
+ newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv |
577 |
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon |
578 |
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog |
579 |
+ newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail |
580 |
+ |
581 |
+ keepdir /var/lib/nut |
582 |
+ |
583 |
+ einfo "Setting up permissions on files and directories" |
584 |
+ fperms 0700 /var/lib/nut |
585 |
+ fowners nut:nut /var/lib/nut |
586 |
+ |
587 |
+ # Do not remove eval here, because the variables contain shell expansions. |
588 |
+ eval fperms 0640 ${NUT_PRIVATE_FILES} |
589 |
+ eval fowners root:nut ${NUT_PRIVATE_FILES} |
590 |
+ |
591 |
+ # Do not remove eval here, because the variables contain shell expansions. |
592 |
+ eval fperms 0644 ${NUT_PUBLIC_FILES} |
593 |
+ eval fowners root:root ${NUT_PUBLIC_FILES} |
594 |
+ |
595 |
+ # Do not remove eval here, because the variables contain shell expansions. |
596 |
+ if use cgi; then |
597 |
+ eval fperms 0644 ${NUT_CGI_FILES} |
598 |
+ eval fowners root:root ${NUT_CGI_FILES} |
599 |
+ fi |
600 |
+ |
601 |
+ # this is installed for 2.4 and fbsd guys |
602 |
+ if ! has_version virtual/udev; then |
603 |
+ einfo "Installing non-udev hotplug support" |
604 |
+ insinto /etc/hotplug/usb |
605 |
+ insopts -m 755 |
606 |
+ doins scripts/hotplug/nut-usbups.hotplug |
607 |
+ fi |
608 |
+ |
609 |
+ newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc |
610 |
+ bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw |
611 |
+} |
612 |
+ |
613 |
+pkg_postinst() { |
614 |
+ # this is to ensure that everybody that installed old versions still has |
615 |
+ # correct permissions |
616 |
+ |
617 |
+ chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null |
618 |
+ chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null |
619 |
+ |
620 |
+ # Do not remove eval here, because the variables contain shell expansions. |
621 |
+ eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null |
622 |
+ eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null |
623 |
+ |
624 |
+ # Do not remove eval here, because the variables contain shell expansions. |
625 |
+ eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null |
626 |
+ eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null |
627 |
+ |
628 |
+ # Do not remove eval here, because the variables contain shell expansions. |
629 |
+ if use cgi; then |
630 |
+ eval chown root:root "${ROOT}"${NUT_CGI_FILES} 2>/dev/null |
631 |
+ eval chmod 0644 "${ROOT}"${NUT_CGI_FILES} 2>/dev/null |
632 |
+ fi |
633 |
+ |
634 |
+ warningmsg elog |
635 |
+} |
636 |
+ |
637 |
+warningmsg() { |
638 |
+ msgfunc="$1" |
639 |
+ [ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!" |
640 |
+ ${msgfunc} "Please note that NUT now runs under the 'nut' user." |
641 |
+ ${msgfunc} "NUT is in the uucp group for access to RS-232 UPS." |
642 |
+ ${msgfunc} "However if you use a USB UPS you may need to look at the udev or" |
643 |
+ ${msgfunc} "hotplug rules that are installed, and alter them suitably." |
644 |
+ ${msgfunc} '' |
645 |
+ ${msgfunc} "You are strongly advised to read the UPGRADING file provided by upstream." |
646 |
+ ${msgfunc} '' |
647 |
+ ${msgfunc} "Please note that upsdrv is NOT automatically started by upsd anymore." |
648 |
+ ${msgfunc} "If you have multiple UPS units, you can use their NUT names to" |
649 |
+ ${msgfunc} "have a service per UPS:" |
650 |
+ ${msgfunc} "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME" |
651 |
+ ${msgfunc} '' |
652 |
+ ${msgfunc} 'If you want apcupsd to power off your UPS when it' |
653 |
+ ${msgfunc} 'shuts down your system in a power failure, you must' |
654 |
+ ${msgfunc} 'add nut.powerfail to your shutdown runlevel:' |
655 |
+ ${msgfunc} '' |
656 |
+ ${msgfunc} 'rc-update add nut.powerfail shutdown' |
657 |
+ ${msgfunc} '' |
658 |
+ |
659 |
+} |