From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5EF1F158008 for ; Sat, 17 Jun 2023 03:15:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4BC48E0901; Sat, 17 Jun 2023 03:15:38 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 25A52E0901 for ; Sat, 17 Jun 2023 03:15:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1259634090F for ; Sat, 17 Jun 2023 03:15:37 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A0D35A97 for ; Sat, 17 Jun 2023 03:15:35 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1686971629.aea0f99f970c391e3daf4f98d0b6a2dc58fc039b.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-power/nut/files/, sys-power/nut/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-power/nut/Manifest sys-power/nut/files/nut-2.6.5-init.d-upsmon sys-power/nut/files/nut-2.8.0-fix-man-page-generation.patch sys-power/nut/files/nut-2.8.0-init.d-upsd sys-power/nut/files/nut.powerfail.initd sys-power/nut/files/systemd_notify.path sys-power/nut/metadata.xml sys-power/nut/nut-2.8.0.ebuild sys-power/nut/nut-9999.ebuild X-VCS-Directories: sys-power/nut/ sys-power/nut/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: aea0f99f970c391e3daf4f98d0b6a2dc58fc039b X-VCS-Branch: master Date: Sat, 17 Jun 2023 03:15:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: bbda8589-30ec-4188-a014-d3c425a7a952 X-Archives-Hash: 8ef01768fb0e1609137ad90f1497e89b commit: aea0f99f970c391e3daf4f98d0b6a2dc58fc039b Author: Francisco Javier Félix inode64 com> AuthorDate: Fri Jun 16 16:14:55 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sat Jun 17 03:13:49 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aea0f99f 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 inode64.com> Closes: https://github.com/gentoo/gentoo/pull/31486 Signed-off-by: Sam James gentoo.org> sys-power/nut/Manifest | 1 + sys-power/nut/files/nut-2.6.5-init.d-upsmon | 2 +- .../files/nut-2.8.0-fix-man-page-generation.patch | 64 +++++ ...t-2.6.5-init.d-upsmon => nut-2.8.0-init.d-upsd} | 20 +- sys-power/nut/files/nut.powerfail.initd | 1 - sys-power/nut/files/systemd_notify.path | 50 ++++ sys-power/nut/metadata.xml | 14 +- sys-power/nut/nut-2.8.0.ebuild | 222 +++++++++++++++++ sys-power/nut/nut-9999.ebuild | 266 +++++++++++++++++++++ 9 files changed, 631 insertions(+), 9 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 +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 +--- + 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.6.5-init.d-upsmon b/sys-power/nut/files/nut-2.8.0-init.d-upsd similarity index 58% copy from sys-power/nut/files/nut-2.6.5-init.d-upsmon copy to sys-power/nut/files/nut-2.8.0-init.d-upsd index 3aafe1676d6e..ce09de52d56d 100644 --- a/sys-power/nut/files/nut-2.6.5-init.d-upsmon +++ b/sys-power/nut/files/nut-2.8.0-init.d-upsd @@ -1,29 +1,37 @@ #!/sbin/openrc-run -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2023 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 extra_started_commands="reload" -pidfile=/var/run/upsmon.pid -bin=/usr/sbin/upsmon +pidfile=/run/nut/upsd.pid +bin=/usr/sbin/upsd depend() { use net + before upsmon + after upsdrv } start() { - ebegin "Starting upsmon" + 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 upsmon" + ebegin "Stopping upsd" start-stop-daemon --stop --quiet --pidfile ${pidfile} eend $? } + reload() { - ebegin "Reloading upsmon" + 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 @@ prometheanfire@gentoo.org + + web@inode64.com + Fco. Javier Félix + - Support IPMI-based UPSes. + Includes all UPS drivers that use GPIO. + Includes all UPS drivers that use I2C. + Includes all UPS drivers that use ipmi. + Includes all UPS drivers that use MODBUS. + Add a QT5 gui monitor. + Includes all UPS drivers that use SERIAL. + Includes all UPS drivers that use SNMP. + Includes all UPS drivers that use USB. + Includes all UPS drivers that use XML. Driver for Eltek UPS models with AL175 alarm module Driver for UPSes supporting the serial BCM/XCP protocol Driver for Belkin serial UPS equipment 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 +}