summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier Félix <web@inode64.com>2023-06-16 18:14:55 +0200
committerSam James <sam@gentoo.org>2023-06-17 04:13:49 +0100
commitaea0f99f970c391e3daf4f98d0b6a2dc58fc039b (patch)
tree6cf0ab1bf2cbb4fdfca502fea8f61931e07a3a55
parentmedia-sound/helm: Fix build on musl (diff)
downloadgentoo-aea0f99f970c391e3daf4f98d0b6a2dc58fc039b.tar.gz
gentoo-aea0f99f970c391e3daf4f98d0b6a2dc58fc039b.tar.bz2
gentoo-aea0f99f970c391e3daf4f98d0b6a2dc58fc039b.zip
sys-power/nut: add 2.8.0, various enhancements
I've recently made a comprehensive update to the ebuild of sys-power/nut: The way drivers are activated has been altered - instead of using a driver list, which can be hard to maintain when new ones are added, we now activate them based on the connection type (serial, USB, XML, IPMI, Modbus, etc). This simplification not only streamlines the installation process but also resolves dependency issues associated with activating a driver and its corresponding unactivated connection. The updates align with the latest Gentoo specifications and are summarized below: Improvements: * Removed unused libnsl * Removed outdated hotplug * Utilized EAPI=8 * Default use of libusb-1 * Added connections for GPIO, i2c, and Modbus * Configuration parameters required per connection type * Fixed the creation of PID in /run/nut * Removed configurations no longer necessary for nut-2.8.0 or newer * Creation of man pages * Added a flag for documentation * Utilized tmpfile for creating temporary directories * Added Q5t5 monitor (nut-9999) * Disabled Python2 * Added Python3 library * Message for the optional function of sys-apps/util-linux[logger, tty-helpers] * Added configuration for Avahi * Added a flag for systemd (nut-9999) TODO: (in next version) * nut-scanner is not working * /etc/init.d/upslog requires parameters of SAI and log file Please note that I have tested different SAI drivers, but only with USB and SNMP connections. Any feedback or further testing on these updates would be highly appreciated. Closes: https://bugs.gentoo.org/836776 Closes: https://bugs.gentoo.org/736804 Closes: https://bugs.gentoo.org/598619 Closes: https://bugs.gentoo.org/636402 Closes: https://bugs.gentoo.org/862543 Closes: https://bugs.gentoo.org/852287 Closes: https://bugs.gentoo.org/676598 Closes: https://bugs.gentoo.org/808675 Closes: https://bugs.gentoo.org/771291 Closes: https://bugs.gentoo.org/714930 Closes: https://bugs.gentoo.org/695148 Closes: https://bugs.gentoo.org/641144 Closes: https://bugs.gentoo.org/670132 Closes: https://bugs.gentoo.org/642618 Closes: https://bugs.gentoo.org/544250 Closes: https://bugs.gentoo.org/526328 Package-Manager: Portage-3.0.45.3, pkgcheck-0.10.24 Signed-off-by: Fco Javier Felix <ffelix@inode64.com> Closes: https://github.com/gentoo/gentoo/pull/31486 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--sys-power/nut/Manifest1
-rw-r--r--sys-power/nut/files/nut-2.6.5-init.d-upsmon2
-rw-r--r--sys-power/nut/files/nut-2.8.0-fix-man-page-generation.patch64
-rw-r--r--sys-power/nut/files/nut-2.8.0-init.d-upsd37
-rw-r--r--sys-power/nut/files/nut.powerfail.initd1
-rw-r--r--sys-power/nut/files/systemd_notify.path50
-rw-r--r--sys-power/nut/metadata.xml14
-rw-r--r--sys-power/nut/nut-2.8.0.ebuild222
-rw-r--r--sys-power/nut/nut-9999.ebuild266
9 files changed, 654 insertions, 3 deletions
diff --git a/sys-power/nut/Manifest b/sys-power/nut/Manifest
index 898249c21a85..20470d95ae84 100644
--- a/sys-power/nut/Manifest
+++ b/sys-power/nut/Manifest
@@ -1 +1,2 @@
DIST nut-2.7.4.tar.gz 2509831 BLAKE2B 367c687efd739150898a14c700d5fddbe22bf926522923e1842011ec49b67d6638620500c4eda50291feb474cc6eef39fff63764cb3e0fad5898abee981f8308 SHA512 320c4aff85d8a370c5eff77d33924fdfc3caf6a250620693cdd5bf3336b3a80d8a207488eee841bcf8b72fbad68fda4c074e63b99c56e7886716fc934122d11a
+DIST nut-2.8.0.tar.gz 3287640 BLAKE2B 6ad87e9c90920d45846d9c1311e8feeb3c36bfa506d62d938940c00d2fc7f7b30632d079a8ee969db624824ae4fd3e14e41e8acd1eda296e26a3aa340f186b94 SHA512 3c413ae54088045a713eb80cf1bdda474f41bb3b67c7c0248aa7a0c4d441dce1ff42627a2735273d7e36892d1f2eeb895220cf28af63fec2fa0c7a267f82d577
diff --git a/sys-power/nut/files/nut-2.6.5-init.d-upsmon b/sys-power/nut/files/nut-2.6.5-init.d-upsmon
index 3aafe1676d6e..729df9c5460b 100644
--- a/sys-power/nut/files/nut-2.6.5-init.d-upsmon
+++ b/sys-power/nut/files/nut-2.6.5-init.d-upsmon
@@ -4,7 +4,7 @@
extra_started_commands="reload"
-pidfile=/var/run/upsmon.pid
+pidfile=/run/nut/upsmon.pid
bin=/usr/sbin/upsmon
depend() {
diff --git a/sys-power/nut/files/nut-2.8.0-fix-man-page-generation.patch b/sys-power/nut/files/nut-2.8.0-fix-man-page-generation.patch
new file mode 100644
index 000000000000..ff224a4774bf
--- /dev/null
+++ b/sys-power/nut/files/nut-2.8.0-fix-man-page-generation.patch
@@ -0,0 +1,64 @@
+From c0d9ce265c6ca627039845d9544ebbdf87a00f7f Mon Sep 17 00:00:00 2001
+From: Timo Kokkonen <timo.t.kokkonen@iki.fi>
+Date: Mon, 11 Jul 2022 20:41:12 +0300
+Subject: [PATCH] docs: man: upsd: Fix driver list when building only some of
+ drivers
+
+There are two issues that come up in man page generation when only
+some of the drivers are built.
+
+First is that during configure phase DRIVER_MAN_LIST is collected by
+searching any .8 files matching the driver names. This does not work
+very well as during the first configure call these files don't exist
+yet as none of them are compiled yet. Searching the .txt files where
+they are built from works better.
+
+Second issue is that SRC_DRIVERS_PAGES list needs to contain the
+source files where the driver list is generated from. If only some
+drivers are built, this needs to be populated from the list of files
+we collected to DRIVER_MAN_LIST during configure phase.
+
+Adding these entries will ensure manpage generation will not fail if
+only some of the drivers are built
+
+Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
+---
+ configure.ac | 4 ++--
+ docs/man/Makefile.am | 6 ++++++
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3aa26c24e..a49ca4417 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1745,8 +1745,8 @@ if test "${WITH_MANS}" = "yes"; then
+ else
+ DRIVER_MAN_LIST=""
+ for i in ${DRIVER_BUILD_LIST}; do
+- if test -f ${srcdir}/docs/man/$i.8; then
+- DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8"
++ if test -f ${srcdir}/docs/man/$i.txt; then
++ DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.txt"
+ fi
+ done
+ AC_MSG_RESULT(${DRIVER_MAN_LIST})
+diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am
+index 0d693a355..a7345264b 100644
+--- a/docs/man/Makefile.am
++++ b/docs/man/Makefile.am
+@@ -695,6 +695,12 @@ SRC_DRIVERS_PAGES = \
+ $(SRC_MODBUS_PAGES) \
+ $(SRC_LINUX_I2C_PAGES)
+
++if SOME_DRIVERS
++SRC_DRIVERS_PAGES += \
++ $(DRIVER_MAN_LIST)
++endif
++
++
+ # distribute everything, even those not installed by default
+ # Note that 'dist' target requires AsciiDoc!
+ SRC_ALL_PAGES = \
+--
+2.35.1
+
diff --git a/sys-power/nut/files/nut-2.8.0-init.d-upsd b/sys-power/nut/files/nut-2.8.0-init.d-upsd
new file mode 100644
index 000000000000..ce09de52d56d
--- /dev/null
+++ b/sys-power/nut/files/nut-2.8.0-init.d-upsd
@@ -0,0 +1,37 @@
+#!/sbin/openrc-run
+# Copyright 1999-2023 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_started_commands="reload"
+
+pidfile=/run/nut/upsd.pid
+bin=/usr/sbin/upsd
+
+depend() {
+ use net
+ before upsmon
+ after upsdrv
+}
+
+start() {
+ ebegin "Starting upsd"
+ # clean up first
+ pkill -u root,nut -x ${bin}
+ sleep 1
+ rm -f ${pidfile}
+ # now start up
+ start-stop-daemon --start --quiet --exec ${bin}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping upsd"
+ start-stop-daemon --stop --quiet --pidfile ${pidfile}
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading upsd"
+ start-stop-daemon --stop --signal HUP --oknodo --quiet --pidfile ${pidfile}
+ eend $?
+}
diff --git a/sys-power/nut/files/nut.powerfail.initd b/sys-power/nut/files/nut.powerfail.initd
index fd26b4f76aec..f81b258a7cdb 100644
--- a/sys-power/nut/files/nut.powerfail.initd
+++ b/sys-power/nut/files/nut.powerfail.initd
@@ -45,4 +45,3 @@ start() {
ewarn "UPS powerfail script scheduled, and flags found, but ${UPS_CTL} missing."
fi
}
-
diff --git a/sys-power/nut/files/systemd_notify.path b/sys-power/nut/files/systemd_notify.path
new file mode 100644
index 000000000000..657e0075420c
--- /dev/null
+++ b/sys-power/nut/files/systemd_notify.path
@@ -0,0 +1,50 @@
+--- old/configure.ac 2023-06-09 00:53:54.121886669 +0200
++++ new/configure.ac 2023-06-09 00:57:13.149792791 +0200
+@@ -3220,45 +3220,8 @@
+ AC_PATH_PROG([SYSTEMD_ANALYZE_PROGRAM], [systemd-analyze], [/usr/bin/systemd-analyze])
+
+ dnl Relevant since 2023: https://github.com/systemd/systemd/pull/25916
+-SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY=no
+-AS_IF([test -x "$SYSTEMD_ANALYZE_PROGRAM"], [
+- AC_MSG_CHECKING([if your systemd version supports Type=notify])
+- myFILE="`mktemp systemd-analyze-XXXXXX.service`"
+- cat > "$myFILE" << EOF
+-@<:@Unit@:>@
+-Description=temp
+-@<:@Service@:>@
+-ExecStart=/bin/true
+-Type=notify
+-EOF
+- if myOUT="`"$SYSTEMD_ANALYZE_PROGRAM" verify "$myFILE" 2>&1`" \
+- && ! (echo "$myOUT" | grep "Failed to parse service type, ignoring") \
+- ; then
+- SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY=yes
+- fi
+- rm -f "$myFILE"
+- AC_MSG_RESULT([${SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY}])
+- ])
+-
+-SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY_RELOAD=no
+-AS_IF([test -x "$SYSTEMD_ANALYZE_PROGRAM"], [
+- AC_MSG_CHECKING([if your systemd version supports Type=notify-reload])
+- myFILE="`mktemp systemd-analyze-XXXXXX.service`"
+- cat > "$myFILE" << EOF
+-@<:@Unit@:>@
+-Description=temp
+-@<:@Service@:>@
+-ExecStart=/bin/true
+-Type=notify-reload
+-EOF
+- if myOUT="`"$SYSTEMD_ANALYZE_PROGRAM" verify "$myFILE" 2>&1`" \
+- && ! (echo "$myOUT" | grep "Failed to parse service type, ignoring") \
+- ; then
+- SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY_RELOAD=yes
+- fi
+- rm -f "$myFILE"
+- AC_MSG_RESULT([${SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY_RELOAD}])
+- ])
++SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY=yes
++SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY_RELOAD=yes
+
+ AS_IF([test x"${with_libsystemd}" = xyes && test x"${SYSTEMD_SUPPORTS_DAEMON_TYPE_NOTIFY}" = xyes], [
+ dnl Built with sd_notify support
diff --git a/sys-power/nut/metadata.xml b/sys-power/nut/metadata.xml
index d310afca661e..1c8e02e16170 100644
--- a/sys-power/nut/metadata.xml
+++ b/sys-power/nut/metadata.xml
@@ -8,8 +8,20 @@
<maintainer type="person">
<email>prometheanfire@gentoo.org</email>
</maintainer>
+ <maintainer type="person" proxied="yes">
+ <email>web@inode64.com</email>
+ <name>Fco. Javier Félix</name>
+ </maintainer>
<use>
- <flag name="ipmi">Support IPMI-based UPSes.</flag>
+ <flag name="gpio">Includes all UPS drivers that use GPIO.</flag>
+ <flag name="i2c">Includes all UPS drivers that use I2C.</flag>
+ <flag name="ipmi">Includes all UPS drivers that use ipmi.</flag>
+ <flag name="modbus">Includes all UPS drivers that use MODBUS.</flag>
+ <flag name="monitor">Add a QT5 gui monitor.</flag>
+ <flag name="serial">Includes all UPS drivers that use SERIAL.</flag>
+ <flag name="snmp">Includes all UPS drivers that use SNMP.</flag>
+ <flag name="usb">Includes all UPS drivers that use USB.</flag>
+ <flag name="xml">Includes all UPS drivers that use XML.</flag>
<flag name="ups_drivers_al175">Driver for Eltek UPS models with AL175 alarm module</flag>
<flag name="ups_drivers_bcmxcp">Driver for UPSes supporting the serial BCM/XCP protocol</flag>
<flag name="ups_drivers_belkin">Driver for Belkin serial UPS equipment</flag>
diff --git a/sys-power/nut/nut-2.8.0.ebuild b/sys-power/nut/nut-2.8.0.ebuild
new file mode 100644
index 000000000000..163885862062
--- /dev/null
+++ b/sys-power/nut/nut-2.8.0.ebuild
@@ -0,0 +1,222 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit bash-completion-r1 flag-o-matic linux-info optfeature systemd tmpfiles toolchain-funcs udev
+
+MY_P=${P/_/-}
+
+DESCRIPTION="Network-UPS Tools"
+HOMEPAGE="https://networkupstools.org/"
+if [[ "${PV}" == *9999 ]] ; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/networkupstools/${PN}.git"
+else
+ SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+
+IUSE="cgi doc ipmi serial i2c +man snmp +usb modbus selinux split-usr ssl tcpd xml zeroconf"
+
+DEPEND="
+ acct-group/nut
+ acct-user/nut
+ cgi? ( >=media-libs/gd-2[png] )
+ dev-libs/libltdl
+ i2c? ( sys-apps/i2c-tools )
+ ipmi? ( sys-libs/freeipmi )
+ modbus? ( dev-libs/libmodbus )
+ snmp? ( net-analyzer/net-snmp:= )
+ ssl? ( >=dev-libs/openssl-1:= )
+ tcpd? ( sys-apps/tcp-wrappers )
+ usb? ( virtual/libusb:1 )
+ virtual/udev
+ xml? ( >=net-libs/neon-0.25.0:= )
+ zeroconf? ( net-dns/avahi )
+"
+
+BDEPEND="
+ man? ( app-text/asciidoc )
+ virtual/pkgconfig
+"
+
+RDEPEND="
+ ${DEPEND}
+ selinux? ( sec-policy/selinux-nut )
+"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-2.6.2-lowspeed-buffer-size.patch"
+)
+
+pkg_pretend() {
+ if use i2c; then
+ CONFIG_CHECK="~I2C_CHARDEV"
+ ERROR_I2C_CHARDEV="You must enable I2C_CHARDEV in your kernel to continue"
+ fi
+ if use usb; then
+ CONFIG_CHECK+=" ~HIDRAW ~USB_HIDDEV"
+ ERROR_HIDRAW="HIDRAW is needed to support USB UPSes"
+ ERROR_I2C_CHARDEV="USB_HIDDEV is needed to support USB UPSes"
+ fi
+ if use serial; then
+ CONFIG_CHECK="~SERIAL_8250"
+ ERROR_SERIAL_8250="SERIAL_8250 is needed to support Serial UPSes"
+ fi
+
+ # Now do the actual checks setup above
+ check_extra_config
+}
+
+src_unpack() {
+ if [[ "${PV}" == *9999 ]] ; then
+ git-r3_src_unpack
+ fi
+ default
+}
+
+src_prepare() {
+ default
+
+ if [[ "${PV}" == *9999 ]] ; then
+ ./autogen.sh
+ fi
+}
+
+src_configure() {
+ local myeconfargs=(
+ --datadir=/usr/share/nut
+ --datarootdir=/usr/share/nut
+ --disable-static
+ --sysconfdir=/etc/nut
+ --with-dev
+ --with-drvpath="/$(get_libdir)/nut"
+ --with-group=nut
+ --with-htmlpath=/usr/share/nut/html
+ --with-logfacility=LOG_DAEMON
+ --with-statepath=/var/lib/nut
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
+ --with-user=nut
+ --without-powerman
+ --without-python
+ --without-python2
+ --without-python3
+ --with-altpidpath=/run/nut
+ --with-pidpath=/run/nut
+ $(use_with i2c linux_i2c)
+ $(use_with ipmi freeipmi)
+ $(use_with ipmi)
+ $(use_with serial)
+ $(use_with snmp)
+ $(use_with ssl)
+ $(use_with tcpd wrap)
+ $(use_with usb)
+ $(use_with xml neon)
+ $(use_with zeroconf avahi)
+ )
+
+ append-flags -fno-lto
+
+ tc-export CC
+ tc-export CXX
+ tc-export AR
+
+ use cgi && myeconfargs+=( --with-cgipath=/usr/share/nut/cgi )
+ use man && myeconfargs+=( --with-doc=man )
+
+ export bashcompdir="$(get_bashcompdir)"
+
+ econf "${myeconfargs[@]}"
+}
+
+src_install() {
+ default
+
+ rm -rf "${D}/etc/hotplug" || die
+
+ find "${D}" -name '*.la' -delete || die
+
+ dodir /sbin
+ use split-usr && dosym ../usr/sbin/upsdrvctl /sbin/upsdrvctl
+
+ if use cgi; then
+ elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
+ elog "copy them to your web server's ScriptPath to activate (this is a"
+ elog "change from the old location)."
+ elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
+ elog
+ elog "Use script aliases according to the web server you use (apache, nginx, lighttpd, etc...)"
+ fi
+
+ # this must be done after all of the install phases
+ for i in "${D}"/etc/nut/*.sample ; do
+ mv "${i}" "${i/.sample/}" || die
+ done
+
+ local DOCS=( AUTHORS MAINTAINERS NEWS README TODO UPGRADING )
+ einstalldocs
+
+ if use doc; then
+ newdoc lib/README README.lib
+ dodoc docs/*.txt
+ docinto cables
+ dodoc docs/cables/*
+ fi
+
+ newinitd "${FILESDIR}"/nut-2.8.0-init.d-upsd upsd
+ newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog
+ newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail
+
+ newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc
+ bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw
+
+ if use zeroconf; then
+ insinto /etc/avahi/services
+ doins scripts/avahi/nut.service
+ fi
+
+ mv "${D}"/usr/lib/tmpfiles.d/nut-common.tmpfiles "${D}"/usr/lib/tmpfiles.d/nut-common-tmpfiles.conf || die
+
+ # Fix double directory
+ sed -i -e 's:/nut/nut:/nut:g' "${D}"/usr/lib/tmpfiles.d/nut-common-tmpfiles.conf || die
+}
+
+pkg_postinst() {
+ elog "Please note that NUT now runs under the 'nut' user."
+ elog "NUT is in the uucp group for access to RS-232 UPS."
+ elog "However if you use a USB UPS you may need to look at the udev or"
+ elog "hotplug rules that are installed, and alter them suitably."
+ elog
+ elog "You are strongly advised to read the UPGRADING file provided by upstream."
+ elog
+ elog "Please note that upsdrv is NOT automatically started by upsd anymore."
+ elog "If you have multiple UPS units, you can use their NUT names to"
+ elog "have a service per UPS:"
+ elog "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
+ elog
+ elog 'If you want apcupsd to power off your UPS when it'
+ elog 'shuts down your system in a power failure, you must'
+ elog 'add nut.powerfail to your shutdown runlevel:'
+ elog
+ elog 'rc-update add nut.powerfail shutdown'
+ elog
+
+ optfeature "all notify events generate a global message (wall) to all users, plus they are logged via the syslog" \
+ sys-apps/util-linu[logger,tty-helpers]
+
+ udev_reload
+
+ tmpfiles_process nut-common-tmpfiles.conf
+}
+
+pkg_postrm() {
+ udev_reload
+}
diff --git a/sys-power/nut/nut-9999.ebuild b/sys-power/nut/nut-9999.ebuild
new file mode 100644
index 000000000000..445fb3b9c78d
--- /dev/null
+++ b/sys-power/nut/nut-9999.ebuild
@@ -0,0 +1,266 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=(python3_{10..12})
+inherit bash-completion-r1 desktop flag-o-matic linux-info optfeature python-single-r1 systemd tmpfiles \
+ toolchain-funcs udev wrapper xdg
+
+MY_P=${P/_/-}
+
+DESCRIPTION="Network-UPS Tools"
+HOMEPAGE="https://networkupstools.org/"
+if [[ "${PV}" == *9999 ]] ; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/networkupstools/${PN}.git"
+else
+ KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
+ SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+
+IUSE="gpio cgi doc ipmi serial i2c +man snmp +usb modbus selinux split-usr ssl tcpd xml zeroconf python monitor systemd"
+
+REQUIRED_USE="
+ monitor? ( python )
+ python? ( ${PYTHON_REQUIRED_USE} )
+ snmp? ( python )
+"
+
+DEPEND="
+ acct-group/nut
+ acct-user/nut
+ cgi? ( >=media-libs/gd-2[png] )
+ dev-libs/libltdl
+ gpio? ( dev-libs/libgpiod )
+ i2c? ( sys-apps/i2c-tools )
+ ipmi? ( sys-libs/freeipmi )
+ modbus? ( dev-libs/libmodbus )
+ python? ( ${PYTHON_DEPS} )
+ snmp? ( net-analyzer/net-snmp:= )
+ ssl? ( >=dev-libs/openssl-1:= )
+ systemd? ( >=sys-apps/systemd-253 )
+ tcpd? ( sys-apps/tcp-wrappers )
+ usb? ( virtual/libusb:1 )
+ virtual/udev
+ xml? ( >=net-libs/neon-0.25.0:= )
+ zeroconf? ( net-dns/avahi )
+"
+# sys-apps/systemd-253 required for Type=notify-reload
+
+BDEPEND="
+ man? ( app-text/asciidoc )
+ virtual/pkgconfig
+"
+
+RDEPEND="
+ ${DEPEND}
+ monitor? ( $(python_gen_cond_dep '
+ dev-python/PyQt5[gui,widgets,${PYTHON_USEDEP}]
+ ')
+ )
+ selinux? ( sec-policy/selinux-nut )
+"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-2.6.2-lowspeed-buffer-size.patch"
+ "${FILESDIR}/systemd_notify.path"
+)
+
+pkg_pretend() {
+ if use i2c; then
+ CONFIG_CHECK="~I2C_CHARDEV"
+ ERROR_I2C_CHARDEV="You must enable I2C_CHARDEV in your kernel to continue"
+ fi
+ if use usb; then
+ CONFIG_CHECK+=" ~HIDRAW ~USB_HIDDEV"
+ ERROR_HIDRAW="HIDRAW is needed to support USB UPSes"
+ ERROR_I2C_CHARDEV="USB_HIDDEV is needed to support USB UPSes"
+ fi
+ if use gpio; then
+ CONFIG_CHECK="~GPIO_CDEV_V1"
+ ERROR_GPIO_CDEV_V1="GPIO_CDEV_V1 is needed to support GPIO UPSes"
+ fi
+ if use serial; then
+ CONFIG_CHECK="~SERIAL_8250"
+ ERROR_SERIAL_8250="SERIAL_8250 is needed to support Serial UPSes"
+ fi
+
+ # Now do the actual checks setup above
+ check_extra_config
+}
+
+src_unpack() {
+ if [[ "${PV}" == *9999 ]] ; then
+ git-r3_src_unpack
+ fi
+ default
+}
+
+pkg_setup() {
+ python-single-r1_pkg_setup
+}
+
+src_prepare() {
+ default
+
+ if [[ "${PV}" == *9999 ]] ; then
+ ./autogen.sh
+ fi
+
+ xdg_environment_reset
+}
+
+src_configure() {
+ local myeconfargs=(
+ --datadir=/usr/share/nut
+ --datarootdir=/usr/share/nut
+ --disable-static
+ --sysconfdir=/etc/nut
+ --with-dev
+ --with-drvpath="/$(get_libdir)/nut"
+ --with-group=nut
+ --with-htmlpath=/usr/share/nut/html
+ --with-logfacility=LOG_DAEMON
+ --with-statepath=/var/lib/nut
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
+ --with-user=nut
+ --without-powerman
+ --without-python
+ --without-python2
+ --with-altpidpath=/run/nut
+ --with-pidpath=/run/nut
+ $(use_with gpio)
+ $(use_with i2c linux_i2c)
+ $(use_with ipmi freeipmi)
+ $(use_with ipmi)
+ $(use_with monitor nut_monitor)
+ $(use_with python pynut)
+ $(use_with serial)
+ $(use_with snmp)
+ $(use_with ssl)
+ $(use_with systemd libsystemd)
+ $(use_with tcpd wrap)
+ $(use_with usb)
+ $(use_with xml neon)
+ $(use_with zeroconf avahi)
+ )
+
+ append-flags -fno-lto
+
+ tc-export CC
+ tc-export CXX
+ tc-export AR
+
+ use cgi && myeconfargs+=( --with-cgipath=/usr/share/nut/cgi )
+ use man && myeconfargs+=( --with-doc=man )
+ use python && myeconfargs+=( --with-python3=/usr/bin/python3 ) || myeconfargs+=( --without-python3 )
+
+ export bashcompdir="$(get_bashcompdir)"
+
+ econf "${myeconfargs[@]}"
+}
+
+src_install() {
+ default
+
+ rm -rf "${D}/etc/hotplug" || die
+
+ find "${D}" -name '*.la' -delete || die
+
+ dodir /sbin
+ use split-usr && dosym ../usr/sbin/upsdrvctl /sbin/upsdrvctl
+
+ if use cgi; then
+ elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
+ elog "copy them to your web server's ScriptPath to activate (this is a"
+ elog "change from the old location)."
+ elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
+ elog
+ elog "Use script aliases according to the web server you use (apache, nginx, lighttpd, etc...)"
+ fi
+
+ # this must be done after all of the install phases
+ for i in "${D}"/etc/nut/*.sample ; do
+ mv "${i}" "${i/.sample/}" || die
+ done
+
+ local DOCS=( AUTHORS MAINTAINERS NEWS README TODO UPGRADING )
+ einstalldocs
+
+ if use doc; then
+ newdoc lib/README README.lib
+ dodoc docs/*.txt
+ docinto cables
+ dodoc docs/cables/*
+ fi
+
+ newinitd "${FILESDIR}"/nut-2.8.0-init.d-upsd upsd
+ newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon
+ newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog
+ newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail
+
+ newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc
+ bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw
+
+ if use zeroconf; then
+ insinto /etc/avahi/services
+ doins scripts/avahi/nut.service
+ fi
+
+ if use monitor; then
+ make_wrapper NUT-Monitor-py3qt5 /usr/share/nut/nut-monitor/app/NUT-Monitor-py3qt5 /usr/share/nut/nut-monitor/app
+
+ # Install desktop shortcut
+ newmenu scripts/python/app/nut-monitor-py3qt5.desktop nut-monitor.desktop
+
+ # Installing Application icons
+ local res
+ for res in 48 64 256; do
+ doicon -s ${res} scripts/python/app/icons/${res}x${res}/nut-monitor.png
+ done
+ doicon -s scalable scripts/python/app/icons/scalable/nut-monitor.svg
+ fi
+
+ use python && python_optimize
+}
+
+pkg_postinst() {
+ elog "Please note that NUT now runs under the 'nut' user."
+ elog "NUT is in the uucp group for access to RS-232 UPS."
+ elog "However if you use a USB UPS you may need to look at the udev or"
+ elog "hotplug rules that are installed, and alter them suitably."
+ elog
+ elog "You are strongly advised to read the UPGRADING file provided by upstream."
+ elog
+ elog "Please note that upsdrv is NOT automatically started by upsd anymore."
+ elog "If you have multiple UPS units, you can use their NUT names to"
+ elog "have a service per UPS:"
+ elog "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
+ elog
+ elog 'If you want apcupsd to power off your UPS when it'
+ elog 'shuts down your system in a power failure, you must'
+ elog 'add nut.powerfail to your shutdown runlevel:'
+ elog
+ elog 'rc-update add nut.powerfail shutdown'
+ elog
+
+ optfeature "all notify events generate a global message (wall) to all users, plus they are logged via the syslog" \
+ sys-apps/util-linu[logger,tty-helpers]
+
+ udev_reload
+
+ tmpfiles_process nut-common-tmpfiles.conf
+ xdg_pkg_postinst
+}
+
+pkg_postrm() {
+ udev_reload
+ xdg_pkg_postrm
+}