Gentoo Archives: gentoo-commits

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