1 |
commit: eb72f866280ce72c25d22963f3ec24d72d60dfa1 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 1 23:53:28 2021 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 1 23:54:01 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eb72f866 |
7 |
|
8 |
sys-power/apcupsd: rev bump |
9 |
|
10 |
- Migrate to EAPI 7 |
11 |
|
12 |
- OpenRC runscript rewritten |
13 |
|
14 |
- Added some patches from Debian/Fedora |
15 |
|
16 |
Package-Manager: Portage-3.0.18, Repoman-3.0.3 |
17 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
18 |
|
19 |
sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild | 149 +++++++++++++++++++++ |
20 |
.../files/apcupsd-3.14.9-close-on-exec.patch | 50 +++++++ |
21 |
.../apcupsd/files/apcupsd-3.14.9-commfailure.patch | 15 +++ |
22 |
.../apcupsd/files/apcupsd-3.14.9-fix-nologin.patch | 15 +++ |
23 |
.../apcupsd/files/apcupsd-3.14.9-gapcmon.patch | 33 +++++ |
24 |
.../files/apcupsd-3.14.9-wall-on-mounted-usr.patch | 20 +++ |
25 |
sys-power/apcupsd/files/apcupsd.init | 28 ++++ |
26 |
7 files changed, 310 insertions(+) |
27 |
|
28 |
diff --git a/sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild b/sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild |
29 |
new file mode 100644 |
30 |
index 00000000000..12e0b16bcc7 |
31 |
--- /dev/null |
32 |
+++ b/sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild |
33 |
@@ -0,0 +1,149 @@ |
34 |
+# Copyright 1999-2021 Gentoo Authors |
35 |
+# Distributed under the terms of the GNU General Public License v2 |
36 |
+ |
37 |
+EAPI="7" |
38 |
+ |
39 |
+inherit linux-info flag-o-matic systemd udev tmpfiles |
40 |
+ |
41 |
+DESCRIPTION="APC UPS daemon with integrated tcp/ip remote shutdown" |
42 |
+HOMEPAGE="http://www.apcupsd.org/" |
43 |
+SRC_URI="mirror://sourceforge/apcupsd/${P}.tar.gz" |
44 |
+ |
45 |
+LICENSE="GPL-2" |
46 |
+SLOT="0" |
47 |
+KEYWORDS="~amd64 ~arm ~ppc ~x86" |
48 |
+IUSE="snmp +usb +modbus cgi gnome kernel_linux" |
49 |
+ |
50 |
+DEPEND=">=sys-apps/util-linux-2.23[tty-helpers(-)] |
51 |
+ cgi? ( >=media-libs/gd-1.8.4 ) |
52 |
+ modbus? ( usb? ( virtual/libusb:0 ) ) |
53 |
+ gnome? ( |
54 |
+ >=x11-libs/gtk+-2.4.0:2 |
55 |
+ dev-libs/glib:2 |
56 |
+ >=gnome-base/gconf-2.0 |
57 |
+ ) |
58 |
+ snmp? ( >=net-analyzer/net-snmp-5.7.2 )" |
59 |
+ |
60 |
+RDEPEND="${DEPEND} |
61 |
+ virtual/mailx" |
62 |
+ |
63 |
+CONFIG_CHECK="~USB_HIDDEV ~HIDRAW" |
64 |
+ERROR_USB_HIDDEV="CONFIG_USB_HIDDEV: needed to access USB-attached UPSes" |
65 |
+ERROR_HIDRAW="CONFIG_HIDRAW: needed to access USB-attached UPSes" |
66 |
+ |
67 |
+DOCS=( ChangeLog ReleaseNotes ) |
68 |
+HTML_DOCS=( doc/manual ) |
69 |
+ |
70 |
+PATCHES=( |
71 |
+ "${FILESDIR}"/${PN}-3.14.9-aliasing.patch |
72 |
+ "${FILESDIR}"/${PN}-3.14.9-close-on-exec.patch |
73 |
+ "${FILESDIR}"/${PN}-3.14.9-commfailure.patch |
74 |
+ "${FILESDIR}"/${PN}-3.14.9-fix-nologin.patch |
75 |
+ "${FILESDIR}"/${PN}-3.14.9-gapcmon.patch |
76 |
+ "${FILESDIR}"/${PN}-3.14.9-wall-on-mounted-usr.patch |
77 |
+) |
78 |
+ |
79 |
+pkg_setup() { |
80 |
+ if use kernel_linux && use usb && linux_config_exists ; then |
81 |
+ check_extra_config |
82 |
+ fi |
83 |
+} |
84 |
+ |
85 |
+src_configure() { |
86 |
+ local myconf |
87 |
+ |
88 |
+ use cgi && myconf="${myconf} --enable-cgi --with-cgi-bin=/usr/libexec/${PN}/cgi-bin" |
89 |
+ |
90 |
+ if use usb ; then |
91 |
+ myconf="${myconf} --with-upstype=usb --with-upscable=usb --enable-usb --with-dev=" |
92 |
+ use modbus && myconf="${myconf} --enable-modbus-usb" |
93 |
+ else |
94 |
+ myconf="${myconf} --with-upstype=apcsmart --with-upscable=smart --disable-usb" |
95 |
+ use modbus || myconf="${myconf} --disable-modbus" |
96 |
+ fi |
97 |
+ |
98 |
+ # We force the DISTNAME to gentoo so it will use gentoo's layout also |
99 |
+ # when installed on non-linux systems. |
100 |
+ econf \ |
101 |
+ --sbindir=/sbin \ |
102 |
+ --sysconfdir=/etc/apcupsd \ |
103 |
+ --with-pwrfail-dir=/etc/apcupsd \ |
104 |
+ --with-lock-dir=/run/apcupsd \ |
105 |
+ --with-pid-dir=/run/apcupsd \ |
106 |
+ --with-log-dir=/var/log \ |
107 |
+ --with-nis-port=3551 \ |
108 |
+ --enable-net --enable-pcnet \ |
109 |
+ --with-distname=gentoo \ |
110 |
+ $(use_enable snmp) \ |
111 |
+ $(use_enable gnome gapcmon) \ |
112 |
+ ${myconf} \ |
113 |
+ APCUPSD_MAIL=$(type -p mail) |
114 |
+} |
115 |
+ |
116 |
+src_compile() { |
117 |
+ # Workaround for bug #280674; upstream should really just provide |
118 |
+ # the text files in the distribution, but I wouldn't count on them |
119 |
+ # doing that anytime soon. |
120 |
+ MANPAGER=$(type -p cat) \ |
121 |
+ emake VERBOSE=2 |
122 |
+} |
123 |
+ |
124 |
+src_install() { |
125 |
+ emake DESTDIR="${D}" VERBOSE=2 install |
126 |
+ rm "${ED}"/etc/init.d/halt || die |
127 |
+ |
128 |
+ insinto /etc/apcupsd |
129 |
+ newins examples/safe.apccontrol safe.apccontrol |
130 |
+ doins "${FILESDIR}"/apcupsd.conf |
131 |
+ |
132 |
+ doman doc/*.8 doc/*.5 |
133 |
+ |
134 |
+ einstalldocs |
135 |
+ |
136 |
+ rm "${ED}"/etc/init.d/apcupsd || die |
137 |
+ newinitd "${FILESDIR}/${PN}.init" "${PN}" |
138 |
+ newinitd "${FILESDIR}/${PN}.powerfail.init" "${PN}".powerfail |
139 |
+ |
140 |
+ systemd_dounit "${FILESDIR}"/${PN}.service |
141 |
+ dotmpfiles "${FILESDIR}"/${PN}-tmpfiles.conf |
142 |
+ |
143 |
+ # remove hal settings, we don't really want to have it still around. |
144 |
+ rm -r "${D}"/usr/share/hal || die |
145 |
+ |
146 |
+ # replace it with our udev rules if we're in Linux |
147 |
+ if use kernel_linux ; then |
148 |
+ udev_newrules "${FILESDIR}"/apcupsd-udev.rules 60-${PN}.rules |
149 |
+ fi |
150 |
+ |
151 |
+} |
152 |
+ |
153 |
+pkg_postinst() { |
154 |
+ tmpfiles_process ${PN}-tmpfiles.conf |
155 |
+ |
156 |
+ if use cgi ; then |
157 |
+ elog "The cgi-bin directory for ${PN} is /usr/libexec/${PN}/cgi-bin." |
158 |
+ elog "Set up your ScriptAlias or symbolic links accordingly." |
159 |
+ fi |
160 |
+ |
161 |
+ elog "" |
162 |
+ elog "Since version 3.14.0 you can use multiple apcupsd instances to" |
163 |
+ elog "control more than one UPS in a single box with openRC." |
164 |
+ elog "To do this, create a link between /etc/init.d/apcupsd to a new" |
165 |
+ elog "/etc/init.d/apcupsd.something, and it will then load the" |
166 |
+ elog "configuration file at /etc/apcupsd/something.conf." |
167 |
+ elog "" |
168 |
+ |
169 |
+ elog 'If you want apcupsd to power off your UPS when it' |
170 |
+ elog 'shuts down your system in a power failure, you must' |
171 |
+ elog 'add apcupsd.powerfail to your shutdown runlevel:' |
172 |
+ elog '' |
173 |
+ elog ' \e[01m rc-update add apcupsd.powerfail shutdown \e[0m' |
174 |
+ elog '' |
175 |
+ |
176 |
+ if use kernel_linux; then |
177 |
+ elog "Starting from version 3.14.9-r1, ${PN} installs udev rules" |
178 |
+ elog "for persistent device naming. If you have multiple UPS" |
179 |
+ elog "connected to the machine, you can point them to the devices" |
180 |
+ elog "in /dev/apcups/by-id directory." |
181 |
+ fi |
182 |
+} |
183 |
|
184 |
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch |
185 |
new file mode 100644 |
186 |
index 00000000000..aeaa78b3542 |
187 |
--- /dev/null |
188 |
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch |
189 |
@@ -0,0 +1,50 @@ |
190 |
+Close the socket on exec - avoid leaked file descriptors, patch from Fedora |
191 |
+ |
192 |
+--- a/src/apcnis.c |
193 |
++++ b/src/apcnis.c |
194 |
+@@ -157,6 +157,9 @@ void do_server(UPSINFO *ups) |
195 |
+ sleep(5 * 60); |
196 |
+ } |
197 |
+ |
198 |
++ /* Close the socket on exec - avoid leaked file descriptors */ |
199 |
++ fcntl(sockfd, F_SETFD, FD_CLOEXEC); |
200 |
++ |
201 |
+ /* Reuse old sockets */ |
202 |
+ #ifndef HAVE_MINGW |
203 |
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&turnon, sizeof(turnon)) < 0) { |
204 |
+--- a/src/apcupsd.c |
205 |
++++ b/src/apcupsd.c |
206 |
+@@ -212,6 +212,9 @@ int main(int argc, char *argv[]) |
207 |
+ if (ups->event_fd < 0) { |
208 |
+ log_event(ups, LOG_WARNING, "Could not open events file %s: %s\n", |
209 |
+ ups->eventfile, strerror(errno)); |
210 |
++ } else { |
211 |
++ /* Close the file on exec - avoid leaked file descriptors */ |
212 |
++ fcntl(ups->event_fd, F_SETFD, FD_CLOEXEC); |
213 |
+ } |
214 |
+ } |
215 |
+ |
216 |
+--- a/src/drivers/usb/linux/linux-usb.c |
217 |
++++ b/src/drivers/usb/linux/linux-usb.c |
218 |
+@@ -246,8 +246,11 @@ bool LinuxUsbUpsDriver::open_usb_device() |
219 |
+ /* Retry 10 times */ |
220 |
+ for (i = 0; i < 10; i++) { |
221 |
+ _fd = open_device(_ups->device); |
222 |
+- if (_fd != -1) |
223 |
++ if (_fd != -1) { |
224 |
++ /* Close the device on exec - avoid leaked file descriptors */ |
225 |
++ fcntl(_fd, F_SETFD, FD_CLOEXEC); |
226 |
+ return true; |
227 |
++ } |
228 |
+ sleep(1); |
229 |
+ } |
230 |
+ |
231 |
+@@ -270,6 +273,7 @@ auto_detect: |
232 |
+ asnprintf(devname, sizeof(devname), "%s%d", hiddev[j], k); |
233 |
+ _fd = open_device(devname); |
234 |
+ if (_fd != -1) { |
235 |
++ fcntl(_fd, F_SETFD, FD_CLOEXEC); |
236 |
+ /* Successful open, save device name and return */ |
237 |
+ strlcpy(_ups->device, devname, sizeof(_ups->device)); |
238 |
+ return true; |
239 |
+ |
240 |
|
241 |
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch |
242 |
new file mode 100644 |
243 |
index 00000000000..49641c06bef |
244 |
--- /dev/null |
245 |
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch |
246 |
@@ -0,0 +1,15 @@ |
247 |
+Author: Tero Janka <tero.janka@×××××.fi> |
248 |
+Description: apcaccess call blocking commfailure mails (Closes: #409734). |
249 |
+ |
250 |
+Index: apcupsd/platforms/etc/commfailure.in |
251 |
+=================================================================== |
252 |
+--- apcupsd.orig/platforms/etc/commfailure.in |
253 |
++++ apcupsd/platforms/etc/commfailure.in |
254 |
+@@ -13,7 +13,5 @@ MSG="$HOSTNAME Communications with UPS $ |
255 |
+ echo "Subject: $MSG" |
256 |
+ echo " " |
257 |
+ echo "$MSG" |
258 |
+- echo " " |
259 |
+- @sbindir@/apcaccess status |
260 |
+ ) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN |
261 |
+ exit 0 |
262 |
|
263 |
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch |
264 |
new file mode 100644 |
265 |
index 00000000000..75f9e4449bf |
266 |
--- /dev/null |
267 |
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch |
268 |
@@ -0,0 +1,15 @@ |
269 |
+Description: only prohibit logins on shutdown if login is allowed at all |
270 |
+Index: apcupsd-3.14.12/src/action.c |
271 |
+=================================================================== |
272 |
+--- apcupsd-3.14.12.orig/src/action.c |
273 |
++++ apcupsd-3.14.12/src/action.c |
274 |
+@@ -208,7 +208,8 @@ static void do_shutdown(UPSINFO *ups, in |
275 |
+ delete_lockfile(ups); |
276 |
+ ups->set_fastpoll(); |
277 |
+ make_file(ups, ups->pwrfailpath); |
278 |
+- prohibit_logins(ups); |
279 |
++ if (ups->nologin.type != NEVER) |
280 |
++ prohibit_logins(ups); |
281 |
+ |
282 |
+ if (!ups->is_slave()) { |
283 |
+ /* |
284 |
|
285 |
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch |
286 |
new file mode 100644 |
287 |
index 00000000000..0dd1cc69aa3 |
288 |
--- /dev/null |
289 |
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch |
290 |
@@ -0,0 +1,33 @@ |
291 |
+Description: take care of some deprecated functions and format issue |
292 |
+Author: Thorsten Alteholz <debian@××××××××.de> |
293 |
+Index: apcupsd-3.14.14/src/gapcmon/gapcmon.c |
294 |
+=================================================================== |
295 |
+--- apcupsd-3.14.14.orig/src/gapcmon/gapcmon.c 2016-07-16 03:04:22.000000000 +0200 |
296 |
++++ apcupsd-3.14.14/src/gapcmon/gapcmon.c 2017-10-06 09:26:40.412004149 +0200 |
297 |
+@@ -1580,7 +1580,7 @@ |
298 |
+ scaled = gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR); |
299 |
+ gtk_image_set_from_pixbuf(GTK_IMAGE(pm->tray_image), scaled); |
300 |
+ gtk_widget_show(pm->tray_image); |
301 |
+- gdk_pixbuf_unref(scaled); |
302 |
++ g_object_unref(scaled); |
303 |
+ } |
304 |
+ |
305 |
+ if (pm->window != NULL) |
306 |
+@@ -2889,7 +2889,7 @@ |
307 |
+ |
308 |
+ pch = g_strdup_printf("%s(%s) emsg=%s", pch_func, pch_topic, pch_emsg); |
309 |
+ |
310 |
+- g_message(pch); |
311 |
++ g_message("%s",pch); |
312 |
+ |
313 |
+ g_free(pch); |
314 |
+ |
315 |
+@@ -4474,7 +4474,7 @@ |
316 |
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image), scaled); |
317 |
+ gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, TRUE, 0); |
318 |
+ gtk_widget_show(image); |
319 |
+- gdk_pixbuf_unref(scaled); |
320 |
++ g_object_unref(scaled); |
321 |
+ |
322 |
+ label = gtk_label_new(about_text); |
323 |
+ gtk_label_set_use_markup(GTK_LABEL(label), TRUE); |
324 |
|
325 |
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch |
326 |
new file mode 100644 |
327 |
index 00000000000..b89a5309e5b |
328 |
--- /dev/null |
329 |
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch |
330 |
@@ -0,0 +1,20 @@ |
331 |
+At halt/killpower time, /usr may already be umounted, and wall |
332 |
+lives in /usr. Avoid failing by using cat if needed. |
333 |
+ |
334 |
+Index: apcupsd/platforms/apccontrol.in |
335 |
+=================================================================== |
336 |
+--- apcupsd.orig/platforms/apccontrol.in |
337 |
++++ apcupsd/platforms/apccontrol.in |
338 |
+@@ -62,10 +62,10 @@ fi |
339 |
+ |
340 |
+ case "$1" in |
341 |
+ killpower) |
342 |
+- echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL} |
343 |
++ echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat) |
344 |
+ sleep 10 |
345 |
+ ${APCUPSD} --killpower |
346 |
+- echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL} |
347 |
++ echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat) |
348 |
+ ;; |
349 |
+ commfailure) |
350 |
+ echo "Warning communications lost with UPS ${2}" | ${WALL} |
351 |
|
352 |
diff --git a/sys-power/apcupsd/files/apcupsd.init b/sys-power/apcupsd/files/apcupsd.init |
353 |
new file mode 100644 |
354 |
index 00000000000..e544fd4f390 |
355 |
--- /dev/null |
356 |
+++ b/sys-power/apcupsd/files/apcupsd.init |
357 |
@@ -0,0 +1,28 @@ |
358 |
+#!/sbin/openrc-run |
359 |
+# Copyright 1999-2021 Gentoo Authors |
360 |
+# Distributed under the terms of the GNU General Public License v2 |
361 |
+ |
362 |
+: ${APCUPSD_CONFIGFILE:=/etc/apcupsd/${SVCNAME#*.}.conf} |
363 |
+: ${APCUPSD_POWERFAILFILE:=/etc/apcupsd/powerfail} |
364 |
+: ${APCUPSD_PIDFILE:=/run/${SVCNAME}.pid} |
365 |
+: ${APCUPSD_SSDARGS:=--wait 1000} |
366 |
+: ${APCUPSD_TERMTIMEOUT:=TERM/60/KILL/5} |
367 |
+ |
368 |
+command="/sbin/apcupsd" |
369 |
+command_args="${APCUPSD_OPTS} --config-file \"${APCUPSD_CONFIGFILE}\" --pid-file \"${APCUPSD_PIDFILE}\"" |
370 |
+pidfile="${APCUPSD_PIDFILE}" |
371 |
+retry="${APCUPSD_TERMTIMEOUT}" |
372 |
+start_stop_daemon_args="${APCUPSD_SSDARGS}" |
373 |
+required_files="${APCUPSD_CONFIGFILE}" |
374 |
+ |
375 |
+depend() { |
376 |
+ use dns |
377 |
+} |
378 |
+ |
379 |
+start_pre() { |
380 |
+ if [ -e "${APCUPSD_POWERFAILFILE}" ] ; then |
381 |
+ ebegin "Removing stale ${APCUPSD_POWERFAILFILE}" |
382 |
+ rm "${APCUPSD_POWERFAILFILE}" |
383 |
+ eend $? |
384 |
+ fi |
385 |
+} |