Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-power/nut/
Date: Wed, 19 Feb 2020 18:24:50
Message-Id: 1582136660.f6b905dd92ecedf91f6fe02956124e05d7acbb0e.robbat2@gentoo
1 commit: f6b905dd92ecedf91f6fe02956124e05d7acbb0e
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Feb 19 18:24:20 2020 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 19 18:24:20 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f6b905dd
7
8 sys-power/nut: drop USE=gui due to python2-only
9
10 Fixes: https://bugs.gentoo.org/710160
11 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
12
13 sys-power/nut/nut-2.7.4-r5.ebuild | 271 ++++++++++++++++++++++++++++++++++++++
14 1 file changed, 271 insertions(+)
15
16 diff --git a/sys-power/nut/nut-2.7.4-r5.ebuild b/sys-power/nut/nut-2.7.4-r5.ebuild
17 new file mode 100644
18 index 00000000000..3570688276d
19 --- /dev/null
20 +++ b/sys-power/nut/nut-2.7.4-r5.ebuild
21 @@ -0,0 +1,271 @@
22 +# Copyright 1999-2020 Gentoo Authors
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +EAPI=7
26 +
27 +inherit autotools bash-completion-r1 desktop fixheadtails flag-o-matic systemd toolchain-funcs user
28 +
29 +MY_P=${P/_/-}
30 +
31 +DESCRIPTION="Network-UPS Tools"
32 +HOMEPAGE="https://www.networkupstools.org/"
33 +SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
34 +LICENSE="GPL-2"
35 +SLOT="0"
36 +KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86"
37 +
38 +IUSE="cgi ipmi snmp +usb selinux split-usr ssl tcpd xml zeroconf"
39 +
40 +DEPEND="
41 + dev-libs/libltdl:*
42 + net-libs/libnsl
43 + virtual/udev
44 + cgi? ( >=media-libs/gd-2[png] )
45 + ipmi? ( sys-libs/freeipmi )
46 + snmp? ( net-analyzer/net-snmp )
47 + ssl? ( >=dev-libs/openssl-1:= )
48 + tcpd? ( sys-apps/tcp-wrappers )
49 + usb? ( virtual/libusb:0= )
50 + xml? ( >=net-libs/neon-0.25.0 )
51 + zeroconf? ( net-dns/avahi )"
52 +
53 +BDEPEND="
54 + virtual/pkgconfig"
55 +
56 +RDEPEND="${DEPEND}
57 + selinux? ( sec-policy/selinux-nut )"
58 +
59 +S="${WORKDIR}/${MY_P}"
60 +
61 +# Bug #480664 requested UPS_DRIVERS_IUSE for more flexibility in building this package
62 +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"
63 +SNMP_DRIVERLIST="snmp-ups"
64 +USB_LIBUSB_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb richcomm_usb riello_usb nutdrv_qx"
65 +USB_DRIVERLIST=${USB_LIBUSB_DRIVERLIST}
66 +#HAL_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb riello_usb nutdrv_qx"
67 +NEONXML_DRIVERLIST="netxml-ups"
68 +IPMI_DRIVERLIST="nut-ipmipsu"
69 +# Now we build from it:
70 +for name in ${SERIAL_DRIVERLIST} ; do
71 + IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
72 +done
73 +for name in ${USB_DRIVERLIST} ; do
74 + IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
75 + REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( usb )"
76 +done
77 +for name in ${NEONXML_DRIVERLIST}; do
78 + IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
79 + REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( xml )"
80 +done
81 +for name in ${SNMP_DRIVERLIST} ; do
82 + IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
83 + REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( snmp )"
84 +done
85 +for name in ${IPMI_DRIVERLIST} ; do
86 + IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
87 + REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( ipmi )"
88 +done
89 +IUSE="${IUSE} ${IUSE_UPS_DRIVERS}"
90 +
91 +# public files should be 644 root:root
92 +NUT_PUBLIC_FILES="/etc/nut/{ups,upssched}.conf"
93 +# private files should be 640 root:nut - readable by nut, writeable by root,
94 +NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
95 +# public files should be 644 root:root, only installed if USE=cgi
96 +NUT_CGI_FILES="/etc/nut/{{hosts,upsset}.conf,upsstats{,-single}.html}"
97 +
98 +PATCHES=(
99 + "${FILESDIR}"/${PN}-2.7.2-no-libdummy.patch
100 + "${FILESDIR}"/${PN}-2.7.1-snmpusb-order.patch
101 + "${FILESDIR}"/${PN}-2.6.2-lowspeed-buffer-size.patch
102 + "${FILESDIR}"/nut-openssl-1.1-support.patch
103 +)
104 +
105 +pkg_setup() {
106 + enewgroup nut 84
107 + enewuser nut 84 -1 /var/lib/nut nut,uucp
108 + # As of udev-104, NUT must be in uucp and NOT in tty.
109 + gpasswd -d nut tty 2>/dev/null
110 + gpasswd -a nut uucp 2>/dev/null
111 + # in some cases on old systems it wasn't in the nut group either!
112 + gpasswd -a nut nut 2>/dev/null
113 + warningmsg ewarn
114 +}
115 +
116 +src_prepare() {
117 + default
118 +
119 + sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
120 + -e '/systemdsystemunitdir=.*echo.*sed.*libdir/s,^,#,g' \
121 + -i configure.ac || die
122 +
123 + sed -e "s:52.nut-usbups.rules:70-nut-usbups.rules:" \
124 + -i scripts/udev/Makefile.am || die
125 +
126 + rm ltmain.sh m4/lt* m4/libtool.m4 || die
127 +
128 + sed -e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \
129 + -i lib/libupsclient{.pc,-config}.in || die #361685
130 +
131 + eautoreconf
132 +}
133 +
134 +src_configure() {
135 + local myconf
136 + append-flags -fno-lto
137 + tc-export CC
138 + tc-export CXX
139 + tc-export AR
140 +
141 + local UPS_DRIVERS=""
142 + for u in $USE ; do
143 + u2=${u#ups_drivers_}
144 + [[ "${u}" != "${u2}" ]] && UPS_DRIVERS="${UPS_DRIVERS} ${u2}"
145 + done
146 + UPS_DRIVERS="${UPS_DRIVERS# }" UPS_DRIVERS="${UPS_DRIVERS% }"
147 + myconf="${myconf} --with-drivers=${UPS_DRIVERS// /,}"
148 +
149 + use cgi && myconf="${myconf} --with-cgipath=/usr/share/nut/cgi"
150 +
151 + # TODO: USE flag for sys-power/powerman
152 + econf \
153 + --sysconfdir=/etc/nut \
154 + --datarootdir=/usr/share/nut \
155 + --datadir=/usr/share/nut \
156 + --disable-static \
157 + --with-statepath=/var/lib/nut \
158 + --with-drvpath=/$(get_libdir)/nut \
159 + --with-htmlpath=/usr/share/nut/html \
160 + --with-user=nut \
161 + --with-group=nut \
162 + --with-logfacility=LOG_DAEMON \
163 + --with-dev \
164 + --with-serial \
165 + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
166 + --without-powerman \
167 + $(use_with cgi) \
168 + $(use_with ipmi) \
169 + $(use_with ipmi freeipmi) \
170 + $(use_with snmp) \
171 + $(use_with ssl) \
172 + $(use_with tcpd wrap) \
173 + $(use_with usb) \
174 + $(use_with xml neon) \
175 + $(use_with zeroconf avahi) \
176 + ${myconf}
177 +}
178 +
179 +src_install() {
180 + emake DESTDIR="${D}" install
181 +
182 + find "${D}" -name '*.la' -delete || die
183 +
184 + dodir /sbin
185 + use split-usr && dosym ../usr/sbin/upsdrvctl /sbin/upsdrvctl
186 +
187 + if use cgi; then
188 + elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
189 + elog "copy them to your web server's ScriptPath to activate (this is a"
190 + elog "change from the old location)."
191 + elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
192 + fi
193 +
194 + # this must be done after all of the install phases
195 + for i in "${D}"/etc/nut/*.sample ; do
196 + mv "${i}" "${i/.sample/}" || die
197 + done
198 +
199 + local DOCS=( AUTHORS ChangeLog docs/*.txt MAINTAINERS NEWS README TODO UPGRADING )
200 + einstalldocs
201 +
202 + newdoc lib/README README.lib
203 + newdoc "${FILESDIR}"/lighttpd_nut.conf-2.2.0 lighttpd_nut.conf
204 +
205 + docinto cables
206 + dodoc docs/cables/*
207 +
208 + newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsd upsd
209 + newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv
210 + newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon
211 + newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog
212 + newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail
213 +
214 + keepdir /var/lib/nut
215 +
216 + einfo "Setting up permissions on files and directories"
217 + fperms 0700 /var/lib/nut
218 + fowners nut:nut /var/lib/nut
219 +
220 + # Do not remove eval here, because the variables contain shell expansions.
221 + eval fperms 0640 ${NUT_PRIVATE_FILES}
222 + eval fowners root:nut ${NUT_PRIVATE_FILES}
223 +
224 + # Do not remove eval here, because the variables contain shell expansions.
225 + eval fperms 0644 ${NUT_PUBLIC_FILES}
226 + eval fowners root:root ${NUT_PUBLIC_FILES}
227 +
228 + # Do not remove eval here, because the variables contain shell expansions.
229 + if use cgi; then
230 + eval fperms 0644 ${NUT_CGI_FILES}
231 + eval fowners root:root ${NUT_CGI_FILES}
232 + fi
233 +
234 + # this is installed for 2.4 and fbsd guys
235 + if ! has_version virtual/udev; then
236 + einfo "Installing non-udev hotplug support"
237 + insinto /etc/hotplug/usb
238 + insopts -m 755
239 + doins scripts/hotplug/nut-usbups.hotplug
240 + fi
241 +
242 + newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc
243 + bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw
244 +}
245 +
246 +pkg_postinst() {
247 + # this is to ensure that everybody that installed old versions still has
248 + # correct permissions
249 +
250 + chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null
251 + chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null
252 +
253 + # Do not remove eval here, because the variables contain shell expansions.
254 + eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
255 + eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
256 +
257 + # Do not remove eval here, because the variables contain shell expansions.
258 + eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
259 + eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
260 +
261 + # Do not remove eval here, because the variables contain shell expansions.
262 + if use cgi; then
263 + eval chown root:root "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
264 + eval chmod 0644 "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
265 + fi
266 +
267 + warningmsg elog
268 +}
269 +
270 +warningmsg() {
271 + msgfunc="$1"
272 + [ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!"
273 + ${msgfunc} "Please note that NUT now runs under the 'nut' user."
274 + ${msgfunc} "NUT is in the uucp group for access to RS-232 UPS."
275 + ${msgfunc} "However if you use a USB UPS you may need to look at the udev or"
276 + ${msgfunc} "hotplug rules that are installed, and alter them suitably."
277 + ${msgfunc} ''
278 + ${msgfunc} "You are strongly advised to read the UPGRADING file provided by upstream."
279 + ${msgfunc} ''
280 + ${msgfunc} "Please note that upsdrv is NOT automatically started by upsd anymore."
281 + ${msgfunc} "If you have multiple UPS units, you can use their NUT names to"
282 + ${msgfunc} "have a service per UPS:"
283 + ${msgfunc} "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
284 + ${msgfunc} ''
285 + ${msgfunc} 'If you want apcupsd to power off your UPS when it'
286 + ${msgfunc} 'shuts down your system in a power failure, you must'
287 + ${msgfunc} 'add nut.powerfail to your shutdown runlevel:'
288 + ${msgfunc} ''
289 + ${msgfunc} 'rc-update add nut.powerfail shutdown'
290 + ${msgfunc} ''
291 +
292 +}