pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ups-nut: Add draft for upcoming nut release



Module Name:	pkgsrc-wip
Committed By:	Greg Troxel <gdt%lexort.com@localhost>
Pushed By:	gdt
Date:		Tue Jan 10 07:27:58 2023 -0500
Changeset:	d62e5f93ad737232fd22879460b5b1e1dab2d6b4

Modified Files:
	Makefile
Added Files:
	ups-nut/DESCR
	ups-nut/Makefile
	ups-nut/Makefile.common
	ups-nut/PLIST
	ups-nut/PLIST.SunOS
	ups-nut/buildlink3.mk
	ups-nut/distinfo
	ups-nut/files/ups.sh
	ups-nut/files/upsd.sh
	ups-nut/files/upsdriver.sh
	ups-nut/files/upskillpower.sh
	ups-nut/files/upslog.sh
	ups-nut/files/upsmon.sh
	ups-nut/options.mk
	ups-nut/patches/patch-aa
	ups-nut/patches/patch-clients_upsclient.c
	ups-nut/patches/patch-drivers_libhid.c
	ups-nut/patches/patch-drivers_libusb0.c
	ups-nut/patches/patch-drivers_libusb1.c
	ups-nut/patches/patch-drivers_usbhid-ups.c

Log Message:
ups-nut: Add draft for upcoming nut release

(TODO: publish the self-generated distfile, or switch to git and autogen.)

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d62e5f93ad737232fd22879460b5b1e1dab2d6b4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                   |   1 +
 ups-nut/DESCR                              |   5 +
 ups-nut/Makefile                           |  83 +++++++++
 ups-nut/Makefile.common                    |  50 ++++++
 ups-nut/PLIST                              | 264 +++++++++++++++++++++++++++++
 ups-nut/PLIST.SunOS                        |  11 ++
 ups-nut/buildlink3.mk                      |  24 +++
 ups-nut/distinfo                           |  11 ++
 ups-nut/files/ups.sh                       |  51 ++++++
 ups-nut/files/upsd.sh                      |  25 +++
 ups-nut/files/upsdriver.sh                 |  40 +++++
 ups-nut/files/upskillpower.sh              |  37 ++++
 ups-nut/files/upslog.sh                    |  34 ++++
 ups-nut/files/upsmon.sh                    |  26 +++
 ups-nut/options.mk                         |  18 ++
 ups-nut/patches/patch-aa                   |  15 ++
 ups-nut/patches/patch-clients_upsclient.c  |  14 ++
 ups-nut/patches/patch-drivers_libhid.c     |  35 ++++
 ups-nut/patches/patch-drivers_libusb0.c    |  12 ++
 ups-nut/patches/patch-drivers_libusb1.c    |  12 ++
 ups-nut/patches/patch-drivers_usbhid-ups.c |  28 +++
 21 files changed, 796 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 68dcbf43bd..cbce698e8b 100644
--- a/Makefile
+++ b/Makefile
@@ -5846,6 +5846,7 @@ SUBDIR+=	upmendex
 SUBDIR+=	upower
 SUBDIR+=	uprof
 SUBDIR+=	ups-monitor
+SUBDIR+=	ups-nut
 SUBDIR+=	uptimed
 SUBDIR+=	uqwk
 SUBDIR+=	urlwatch
diff --git a/ups-nut/DESCR b/ups-nut/DESCR
new file mode 100644
index 0000000000..a83a7e2eaa
--- /dev/null
+++ b/ups-nut/DESCR
@@ -0,0 +1,5 @@
+This is a developing project to monitor a large assortment of UPS hardware.
+Network communications are used so that multiple systems can monitor a
+single physical UPS and shut down together if necessary without any
+special "sharing hardware" on the UPS itself. CGI scripts are in the
+ups-nut-cgi package.
diff --git a/ups-nut/Makefile b/ups-nut/Makefile
new file mode 100644
index 0000000000..b29cf40b71
--- /dev/null
+++ b/ups-nut/Makefile
@@ -0,0 +1,83 @@
+# $NetBSD: Makefile,v 1.70 2023/01/08 01:32:54 gdt Exp $
+
+.include "Makefile.common"
+
+PKGNAME=		ups-${DISTNAME}
+COMMENT=		Network UPS Tools
+
+SUBST_CLASSES+=		man-so
+SUBST_MESSAGE.man-so=	Fixing manpage .so references.
+SUBST_STAGE.man-so=	pre-build
+SUBST_FILES.man-so=	docs/man/*.[0-9]
+SUBST_SED.man-so=	-e 's,^\.so \([^/]*\)\.\([0-9]\)$$,.so man\2/\1.\2,'
+SUBST_NOOP_OK.man-so=	yes
+
+# Don't regenerate any files in tools/.
+TOOLS_SCRIPT.perl=	exit 1
+
+CONFIGURE_ARGS+=	--with-docs=man
+CONFIGURE_ARGS+=	--with-drvpath=${NUT_DRVDIR:Q}
+CONFIGURE_ARGS+=	--with-altpidpath=${NUT_STATEDIR:Q}
+CONFIGURE_ARGS+=	--with-pidpath=${NUT_STATEDIR:Q}
+CONFIGURE_ARGS+=	--with-dev
+# \todo Consider split package or option.
+CONFIGURE_ARGS+=	--with-python=${PYTHONBIN}
+CONFIGURE_ARGS+=	--without-snmp		# provided by sysutils/ups-nut-snmp
+CONFIGURE_ARGS+=	--without-nut_monitor	# not packaged
+
+PKG_GROUPS_VARS+=	NUT_GROUP
+PKG_USERS_VARS+=	NUT_USER
+BUILD_DEFS+=		NUT_STATEDIR VARBASE
+
+FILES_SUBST+=		NUT_CONFDIR=${NUT_CONFDIR:Q}
+FILES_SUBST+=		NUT_STATEDIR=${NUT_STATEDIR:Q}
+
+PKG_GROUPS=		${NUT_GROUP}
+PKG_USERS=		${NUT_USER}:${NUT_GROUP}
+PKG_GECOS.${NUT_USER}=	Network UPS Tools
+PKG_HOME.${NUT_USER}=	${NUT_STATEDIR}
+PKG_SHELL.${NUT_USER}=	${SH}
+
+CONF_FILES=		${NUT_EGDIR}/nut.conf.sample ${NUT_CONFDIR}/nut.conf
+CONF_FILES+=		${NUT_EGDIR}/ups.conf.sample ${NUT_CONFDIR}/ups.conf
+CONF_FILES+=		${NUT_EGDIR}/upssched.conf.sample 		\
+			${NUT_CONFDIR}/upssched.conf
+
+CONF_FILES_PERMS=	${NUT_EGDIR}/upsd.conf.sample			\
+			${NUT_CONFDIR}/upsd.conf			\
+			${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0600
+CONF_FILES_PERMS+=	${NUT_EGDIR}/upsd.users.sample			\
+			${NUT_CONFDIR}/upsd.users			\
+			${NUT_USER} ${NUT_GROUP} 0600
+CONF_FILES_PERMS+=	${NUT_EGDIR}/upsmon.conf.sample			\
+			${NUT_CONFDIR}/upsmon.conf			\
+			${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0600
+RCD_SCRIPTS=		ups upskillpower upsdriver upsd upsmon upslog
+
+PY_PATCHPLIST=		yes
+
+OWN_DIRS=		${NUT_CONFDIR}
+OWN_DIRS_PERMS=		${NUT_STATEDIR} ${NUT_USER} ${NUT_GROUP} 0770
+
+INSTALLATION_DIRS+=	${NUT_EGDIR} ${NUT_DOCDIR}/cables ${NUT_DOCDIR}/drivers
+
+CHECK_INTERPRETER_SKIP+=	share/nut/solaris-init/nut
+
+post-install:
+	${INSTALL_DATA_DIR} ${DESTDIR}${NUT_EGDIR}
+	${MV} ${DESTDIR}${NUT_CONFDIR}/*.sample ${DESTDIR}${NUT_EGDIR}
+	${INSTALL_DATA_DIR} ${DESTDIR}${NUT_DOCDIR}
+	for f in COPYING CREDITS ChangeLog NEWS README INSTALL UPGRADING; do \
+		${INSTALL_DATA} ${WRKSRC}/$$f ${DESTDIR}${NUT_DOCDIR}; \
+	done
+	for f in ${WRKSRC}/docs/*.txt; do \
+		${INSTALL_DATA} $$f ${DESTDIR}${NUT_DOCDIR}; \
+	done
+	for f in ${WRKSRC}/docs/cables/*.txt; do \
+		${INSTALL_DATA} $$f ${DESTDIR}${NUT_DOCDIR}/cables/; \
+	done
+
+# nut-scanner needs libltdl, but this is not documented
+.include "../../devel/libltdl/buildlink3.mk"
+.include "../../lang/python/extension.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/ups-nut/Makefile.common b/ups-nut/Makefile.common
new file mode 100644
index 0000000000..5d2af4d8e5
--- /dev/null
+++ b/ups-nut/Makefile.common
@@ -0,0 +1,50 @@
+# $NetBSD: Makefile.common,v 1.12 2022/04/26 23:28:25 gdt Exp $
+# used by sysutils/ups-nut/Makefile
+# used by sysutils/ups-nut-cgi/Makefile
+# used by sysutils/ups-nut-snmp/Makefile
+# used by sysutils/ups-nut-usb/Makefile
+# used by sysutils/p5-UPS-Nut/Makefile
+
+DISTNAME=		nut-2.8.0.1
+CATEGORIES=		sysutils
+MASTER_SITES=		http://www.networkupstools.org/source/${PKGVERSION_NOREV:R}/
+
+MAINTAINER?=		gdt%NetBSD.org@localhost
+HOMEPAGE=		http://www.networkupstools.org/
+
+LICENSE=		gnu-gpl-v2 OR gnu-gpl-v3
+
+NUT_USER?=		nut
+NUT_GROUP?=		nut
+
+DISTINFO_FILE=		${.CURDIR}/../../sysutils/ups-nut/distinfo
+PATCHDIR=		${.CURDIR}/../../sysutils/ups-nut/patches
+
+USE_TOOLS=		pkg-config
+USE_LIBTOOL=		yes
+USE_LANGUAGES=		c c++
+GNU_CONFIGURE=		yes
+CONFIGURE_ARGS+=	--sysconfdir=${NUT_CONFDIR:Q}
+CONFIGURE_ARGS+=	--datadir=${NUT_DATADIR:Q}
+CONFIGURE_ARGS+=	--localstatedir=${NUT_STATEDIR:Q}
+CONFIGURE_ARGS+=	--with-statepath=${NUT_STATEDIR:Q}
+CONFIGURE_ARGS+=	--with-htmlpath=${PREFIX:Q}/share/nut/html
+CONFIGURE_ARGS+=	--with-user=${NUT_USER}
+CONFIGURE_ARGS+=	--with-group=${NUT_GROUP}
+
+CHECK_PORTABILITY_SKIP=	packaging/*
+
+.include "../../mk/bsd.prefs.mk"
+.include "options.mk"
+
+BUILD_DEFS+=		VARBASE
+
+PKG_SYSCONFSUBDIR?=	nut
+NUT_CONFDIR=		${PKG_SYSCONFDIR}
+NUT_DATADIR=		${PREFIX}/share/nut
+NUT_DOCDIR=		${PREFIX}/share/doc/nut
+NUT_DRVDIR=		${PREFIX}/libexec/nut
+NUT_EGDIR=		${PREFIX}/share/examples/nut
+# Should be run
+NUT_STATEDIR?=		${VARBASE}/db/nut
+NUT_CGIDIR=		${PREFIX}/libexec/cgi-bin
diff --git a/ups-nut/PLIST b/ups-nut/PLIST
new file mode 100644
index 0000000000..acf845d853
--- /dev/null
+++ b/ups-nut/PLIST
@@ -0,0 +1,264 @@
+@comment $NetBSD: PLIST,v 1.30 2022/08/11 16:00:17 gdt Exp $
+bin/nut-scanner
+bin/upsc
+bin/upscmd
+bin/upslog
+bin/upsrw
+bin/upssched-cmd
+include/nut-scan.h
+include/nutclient.h
+include/nutclientmem.h
+include/nutscan-device.h
+include/nutscan-init.h
+include/nutscan-ip.h
+include/nutscan-serial.h
+include/parseconf.h
+include/upsclient.h
+lib/libnutclient.la
+lib/libnutclientstub.la
+lib/libnutscan.la
+lib/libupsclient.la
+lib/pkgconfig/libnutclient.pc
+lib/pkgconfig/libnutclientstub.pc
+lib/pkgconfig/libnutscan.pc
+lib/pkgconfig/libupsclient.pc
+${PYSITELIB}/PyNUT.py
+${PYSITELIB}/test_nutclient.py
+libexec/nut/al175
+libexec/nut/apcsmart
+libexec/nut/apcsmart-old
+libexec/nut/apcupsd-ups
+libexec/nut/bcmxcp
+libexec/nut/belkin
+libexec/nut/belkinunv
+libexec/nut/bestfcom
+libexec/nut/bestfortress
+libexec/nut/bestuferrups
+libexec/nut/bestups
+libexec/nut/blazer_ser
+libexec/nut/clone
+libexec/nut/clone-outlet
+libexec/nut/dummy-ups
+libexec/nut/etapro
+libexec/nut/everups
+libexec/nut/gamatronic
+libexec/nut/genericups
+libexec/nut/isbmex
+libexec/nut/ivtscd
+libexec/nut/liebert
+libexec/nut/liebert-esp2
+libexec/nut/masterguard
+libexec/nut/metasys
+libexec/nut/mge-shut
+libexec/nut/mge-utalk
+libexec/nut/microdowell
+libexec/nut/microsol-apc
+libexec/nut/nutdrv_qx
+libexec/nut/nutdrv_siemens-sitop
+libexec/nut/oneac
+libexec/nut/optiups
+libexec/nut/powercom
+libexec/nut/powerpanel
+libexec/nut/rhino
+libexec/nut/riello_ser
+libexec/nut/safenet
+libexec/nut/skel
+libexec/nut/solis
+libexec/nut/tripplite
+libexec/nut/tripplitesu
+libexec/nut/upscode2
+libexec/nut/victronups
+man/man3/libnutclient.3
+man/man3/libnutclient_commands.3
+man/man3/libnutclient_devices.3
+man/man3/libnutclient_general.3
+man/man3/libnutclient_misc.3
+man/man3/libnutclient_tcp.3
+man/man3/libnutclient_variables.3
+man/man3/nutclient_authenticate.3
+man/man3/nutclient_destroy.3
+man/man3/nutclient_device_forced_shutdown.3
+man/man3/nutclient_device_login.3
+man/man3/nutclient_device_master.3
+man/man3/nutclient_execute_device_command.3
+man/man3/nutclient_get_device_command_description.3
+man/man3/nutclient_get_device_commands.3
+man/man3/nutclient_get_device_description.3
+man/man3/nutclient_get_device_num_logins.3
+man/man3/nutclient_get_device_rw_variables.3
+man/man3/nutclient_get_device_variable_description.3
+man/man3/nutclient_get_device_variable_values.3
+man/man3/nutclient_get_device_variables.3
+man/man3/nutclient_get_devices.3
+man/man3/nutclient_has_device.3
+man/man3/nutclient_has_device_command.3
+man/man3/nutclient_has_device_variable.3
+man/man3/nutclient_logout.3
+man/man3/nutclient_set_device_variable_value.3
+man/man3/nutclient_set_device_variable_values.3
+man/man3/nutclient_tcp_create_client.3
+man/man3/nutclient_tcp_disconnect.3
+man/man3/nutclient_tcp_get_timeout.3
+man/man3/nutclient_tcp_is_connected.3
+man/man3/nutclient_tcp_reconnect.3
+man/man3/nutclient_tcp_set_timeout.3
+man/man3/nutscan.3
+man/man3/nutscan_add_device_to_device.3
+man/man3/nutscan_add_option_to_device.3
+man/man3/nutscan_cidr_to_ip.3
+man/man3/nutscan_display_parsable.3
+man/man3/nutscan_display_ups_conf.3
+man/man3/nutscan_free_device.3
+man/man3/nutscan_get_serial_ports_list.3
+man/man3/nutscan_init.3
+man/man3/nutscan_new_device.3
+man/man3/nutscan_scan_avahi.3
+man/man3/nutscan_scan_eaton_serial.3
+man/man3/nutscan_scan_ipmi.3
+man/man3/nutscan_scan_nut.3
+man/man3/nutscan_scan_snmp.3
+man/man3/nutscan_scan_usb.3
+man/man3/nutscan_scan_xml_http_range.3
+man/man3/upscli_add_host_cert.3
+man/man3/upscli_cleanup.3
+man/man3/upscli_connect.3
+man/man3/upscli_disconnect.3
+man/man3/upscli_fd.3
+man/man3/upscli_get.3
+man/man3/upscli_init.3
+man/man3/upscli_list_next.3
+man/man3/upscli_list_start.3
+man/man3/upscli_readline.3
+man/man3/upscli_readline_timeout.3
+man/man3/upscli_sendline.3
+man/man3/upscli_sendline_timeout.3
+man/man3/upscli_splitaddr.3
+man/man3/upscli_splitname.3
+man/man3/upscli_ssl.3
+man/man3/upscli_strerror.3
+man/man3/upscli_upserror.3
+man/man3/upsclient.3
+man/man5/nut.conf.5
+man/man5/ups.conf.5
+man/man5/upsd.conf.5
+man/man5/upsd.users.5
+man/man5/upsmon.conf.5
+man/man5/upssched.conf.5
+man/man8/al175.8
+man/man8/apcsmart-old.8
+man/man8/apcsmart.8
+man/man8/apcupsd-ups.8
+man/man8/bcmxcp.8
+man/man8/belkin.8
+man/man8/belkinunv.8
+man/man8/bestfcom.8
+man/man8/bestfortress.8
+man/man8/bestuferrups.8
+man/man8/bestups.8
+man/man8/blazer_ser.8
+man/man8/clone.8
+man/man8/dummy-ups.8
+man/man8/etapro.8
+man/man8/everups.8
+man/man8/gamatronic.8
+man/man8/genericups.8
+man/man8/isbmex.8
+man/man8/ivtscd.8
+man/man8/liebert-esp2.8
+man/man8/liebert.8
+man/man8/masterguard.8
+man/man8/metasys.8
+man/man8/mge-shut.8
+man/man8/mge-utalk.8
+man/man8/microdowell.8
+man/man8/microsol-apc.8
+man/man8/nut-driver-enumerator.8
+man/man8/nut-recorder.8
+man/man8/nut-scanner.8
+man/man8/nutdrv_qx.8
+man/man8/nutdrv_siemens_sitop.8
+man/man8/nutupsdrv.8
+man/man8/oneac.8
+man/man8/optiups.8
+man/man8/powercom.8
+man/man8/powerpanel.8
+man/man8/rhino.8
+man/man8/riello_ser.8
+man/man8/safenet.8
+man/man8/solis.8
+man/man8/tripplite.8
+man/man8/tripplitesu.8
+man/man8/upsc.8
+man/man8/upscmd.8
+man/man8/upscode2.8
+man/man8/upsd.8
+man/man8/upsdrvctl.8
+man/man8/upsdrvsvcctl.8
+man/man8/upslog.8
+man/man8/upsmon.8
+man/man8/upsrw.8
+man/man8/upssched.8
+man/man8/victronups.8
+sbin/upsd
+sbin/upsdrvctl
+sbin/upsmon
+sbin/upssched
+share/doc/nut/COPYING
+share/doc/nut/ChangeLog
+share/doc/nut/FAQ.txt
+share/doc/nut/INSTALL
+share/doc/nut/NEWS
+share/doc/nut/README
+share/doc/nut/UPGRADING
+share/doc/nut/acknowledgements.txt
+share/doc/nut/asciidoc.txt
+share/doc/nut/cables.txt
+share/doc/nut/cables/apc-rs500-serial.txt
+share/doc/nut/cables/apc.txt
+share/doc/nut/cables/ge-imv-victron.txt
+share/doc/nut/cables/imv.txt
+share/doc/nut/cables/mgeups.txt
+share/doc/nut/cables/powerware.txt
+share/doc/nut/cables/repotec.txt
+share/doc/nut/cables/sms.txt
+share/doc/nut/ci-farm-lxc-setup.txt
+share/doc/nut/config-notes.txt
+share/doc/nut/config-prereqs.txt
+share/doc/nut/configure.txt
+share/doc/nut/contact-closure.txt
+share/doc/nut/daisychain.txt
+share/doc/nut/design.txt
+share/doc/nut/developer-guide.txt
+share/doc/nut/developers.txt
+share/doc/nut/documentation.txt
+share/doc/nut/download.txt
+share/doc/nut/features.txt
+share/doc/nut/hid-subdrivers.txt
+share/doc/nut/history.txt
+share/doc/nut/macros.txt
+share/doc/nut/net-protocol.txt
+share/doc/nut/new-clients.txt
+share/doc/nut/new-drivers.txt
+share/doc/nut/nut-names.txt
+share/doc/nut/nut-qa.txt
+share/doc/nut/nutdrv_qx-subdrivers.txt
+share/doc/nut/outlets.txt
+share/doc/nut/packager-guide.txt
+share/doc/nut/scheduling.txt
+share/doc/nut/security.txt
+share/doc/nut/snmp-subdrivers.txt
+share/doc/nut/snmp.txt
+share/doc/nut/sock-protocol.txt
+share/doc/nut/solaris-usb.txt
+share/doc/nut/support.txt
+share/doc/nut/user-manual.txt
+share/examples/nut/nut.conf.sample
+share/examples/nut/ups.conf.sample
+share/examples/nut/upsd.conf.sample
+share/examples/nut/upsd.users.sample
+share/examples/nut/upsmon.conf.sample
+share/examples/nut/upssched.conf.sample
+share/nut/cmdvartab
+share/nut/driver.list
+@pkgdir share/doc/nut/drivers
+@pkgdir etc/nut
diff --git a/ups-nut/PLIST.SunOS b/ups-nut/PLIST.SunOS
new file mode 100644
index 0000000000..380fa5f581
--- /dev/null
+++ b/ups-nut/PLIST.SunOS
@@ -0,0 +1,11 @@
+@comment $NetBSD: PLIST.SunOS,v 1.1 2022/04/29 08:41:00 jperkin Exp $
+libexec/nut-driver-enumerator.sh
+sbin/upsdrvsvcctl
+share/nut/solaris-init/nut
+share/nut/solaris-smf/manifest/nut-driver-enumerator.xml
+share/nut/solaris-smf/manifest/nut-driver.xml
+share/nut/solaris-smf/manifest/nut-monitor.xml
+share/nut/solaris-smf/manifest/nut-server.xml
+share/nut/solaris-smf/manifest/nut.xml
+share/nut/solaris-smf/method/svc-nut-monitor
+share/nut/solaris-smf/method/svc-nut-server
diff --git a/ups-nut/buildlink3.mk b/ups-nut/buildlink3.mk
new file mode 100644
index 0000000000..8421b92af8
--- /dev/null
+++ b/ups-nut/buildlink3.mk
@@ -0,0 +1,24 @@
+# $NetBSD: buildlink3.mk,v 1.6 2022/06/28 11:36:06 wiz Exp $
+
+BUILDLINK_TREE+=	ups-nut
+
+.if !defined(UPS_NUT_BUILDLINK3_MK)
+UPS_NUT_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.ups-nut+=	ups-nut>=2.7.4
+BUILDLINK_ABI_DEPENDS.ups-nut?=	ups-nut>=2.8.0nb1
+BUILDLINK_PKGSRCDIR.ups-nut?=	../../wip/ups-nut
+
+pkgbase:= ups-nut
+.include "../../mk/pkg-build-options.mk"
+
+.if ${PKG_BUILD_OPTIONS.ups-nut:Mnss}
+.  include "../../devel/nss/buildlink3.mk"
+.elif ${PKG_BUILD_OPTIONS.ups-nut:Mopenssl}
+.  include "../../security/openssl/buildlink3.mk"
+.endif
+
+.include "../../mk/pthread.buildlink3.mk"
+.endif	# UPS_NUT_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-ups-nut
diff --git a/ups-nut/distinfo b/ups-nut/distinfo
new file mode 100644
index 0000000000..1dcf1efb36
--- /dev/null
+++ b/ups-nut/distinfo
@@ -0,0 +1,11 @@
+$NetBSD: distinfo,v 1.40 2022/11/26 14:45:47 gdt Exp $
+
+BLAKE2s (nut-2.8.0.1.tar.gz) = a179c68bf5214f1ae5d7756c2279137218abc9bc0a004bca1ebf327f49a930b9
+SHA512 (nut-2.8.0.1.tar.gz) = 055a9823392b16366391a2f108269f272465bdd43742d0778f9e520dc2b185fa47b4d4d8489e30b133cc8e6441033594441a1a8796a9cf5bc32a55e80a60eb5f
+Size (nut-2.8.0.1.tar.gz) = 3690667 bytes
+SHA1 (patch-aa) = a471517e5e05f92b1eb904b227dbf1b0decec848
+SHA1 (patch-clients_upsclient.c) = 50633e97a747b61dfed155b96414992040e6386f
+SHA1 (patch-drivers_libhid.c) = 8b4f773d9b32e4c43f7045a4a83854382b08cb5b
+SHA1 (patch-drivers_libusb0.c) = 71719f12cd8a8efd93d07b6b2d50d8334df7daab
+SHA1 (patch-drivers_libusb1.c) = 58d8ffe9507399802ad885c2e2627641978e5438
+SHA1 (patch-drivers_usbhid-ups.c) = 9be263163c338f17413df99e20b41185564568d5
diff --git a/ups-nut/files/ups.sh b/ups-nut/files/ups.sh
new file mode 100644
index 0000000000..16c4cbd725
--- /dev/null
+++ b/ups-nut/files/ups.sh
@@ -0,0 +1,51 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: ups.sh,v 1.11 2023/01/07 16:16:10 gdt Exp $
+#
+# KEYWORD: nostart
+
+# NB: This file is not intended to be run automaticlally at boot.  It
+# is a convenience script for humans to start or stop all 4 nut-ups
+# daemons as a group.
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+rcd_dir=`@DIRNAME@ $0`
+
+# NOTE: run_rc_command sets $rc_arg
+#
+forward_commands()
+{
+	for file in $COMMAND_LIST; do
+		$rcd_dir/$file $rc_arg
+	done
+}
+
+reverse_commands()
+{
+	REVCOMMAND_LIST=
+	for file in $COMMAND_LIST; do
+		REVCOMMAND_LIST="$file $REVCOMMAND_LIST"
+	done
+	for file in $REVCOMMAND_LIST; do
+		$rcd_dir/$file $rc_arg
+	done
+}
+
+COMMAND_LIST="upsdriver upsd upsmon upslog"
+
+name="ups"
+start_cmd="forward_commands"
+stop_cmd="reverse_commands"
+status_cmd="forward_commands"
+extra_commands="status"
+
+if [ -f /etc/rc.subr ]; then
+        run_rc_command "$1"
+else
+        @ECHO@ -n " ${name}"
+	rc_arg="$1"
+	${start_cmd}
+fi
diff --git a/ups-nut/files/upsd.sh b/ups-nut/files/upsd.sh
new file mode 100644
index 0000000000..be64a177f0
--- /dev/null
+++ b/ups-nut/files/upsd.sh
@@ -0,0 +1,25 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upsd.sh,v 1.9 2023/01/08 01:14:23 gdt Exp $
+#
+# PROVIDE: upsd
+# REQUIRE: upsdriver
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="upsd"
+rcvar=$name
+command="@PREFIX@/sbin/${name}"
+required_files="@NUT_CONFDIR@/${name}.conf"
+pidfile="@NUT_STATEDIR@/${name}.pid"
+
+if [ -f /etc/rc.subr ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	@ECHO@ -n " ${name}"
+	${command} ${upsd_flags} ${command_args}
+fi
diff --git a/ups-nut/files/upsdriver.sh b/ups-nut/files/upsdriver.sh
new file mode 100644
index 0000000000..6117077852
--- /dev/null
+++ b/ups-nut/files/upsdriver.sh
@@ -0,0 +1,40 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upsdriver.sh,v 1.12 2023/01/08 01:32:55 gdt Exp $
+#
+# PROVIDE: upsdriver
+# REQUIRE: NETWORK syslogd mountcritremote
+# KEYWORD: shutdown
+#
+# This script calls upsdrvctl to start and stop the driver(s).  (Note
+# that a system might have more than one UPS, and upsdrvctl should
+# support this.)  See nutupsdrv(8), but upsdrvctl will invoke the
+# driver properly.
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="upsdriver"
+rcvar=$name
+
+if [ -f /etc/rc.subr ]; then
+	load_rc_config $name
+fi
+
+ctl_command="@PREFIX@/sbin/upsdrvctl"
+required_files="@NUT_CONFDIR@/ups.conf"
+start_cmd="${ctl_command} start"
+stop_cmd="${ctl_command} stop"
+# XXX implement status after upsdrvctl does
+
+if [ -f /etc/rc.subr ]; then
+	run_rc_command "$1"
+else
+	@ECHO@ -n " ${name}"
+	if [ -n "${start_cmd}" ]; then
+		${start_cmd}
+	else
+		${command} ${upsdriver_flags} ${command_args}
+	fi
+fi
diff --git a/ups-nut/files/upskillpower.sh b/ups-nut/files/upskillpower.sh
new file mode 100644
index 0000000000..7860e47672
--- /dev/null
+++ b/ups-nut/files/upskillpower.sh
@@ -0,0 +1,37 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upskillpower.sh,v 1.1 2023/01/08 01:14:23 gdt Exp $
+#
+# PROVIDE: upskillpower
+# REQUIRE: mountcritremote
+# BEFORE: upsdriver altq downinterfaces 
+# KEYWORD: shutdown
+
+# This script shuts off power, if upsmon has decided to shutdown
+# because of low battery/runtime.  This is logically part of upsmon
+# but should run later in shutdown.
+
+. /etc/rc.subr
+
+name="upskillpower"
+rcvar=upsmon
+
+start_empty()
+{
+    # This is a shutdown-only file.
+    true
+}
+
+killpower()
+{
+    if @PREFIX@/sbin/upsmon -K; then
+	echo "upskillpower: POWER OFF commanded"
+	echo TEST ONLY @PREFIX@/sbin/upsdrvctl shutdown
+    fi
+}
+
+start_cmd="start_empty"
+stop_cmd="killpower"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/ups-nut/files/upslog.sh b/ups-nut/files/upslog.sh
new file mode 100644
index 0000000000..54a7210a35
--- /dev/null
+++ b/ups-nut/files/upslog.sh
@@ -0,0 +1,34 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upslog.sh,v 1.8 2023/01/08 01:14:23 gdt Exp $
+#
+# PROVIDE: upslog
+# REQUIRE: upsd DAEMON
+# BEFORE: LOGIN
+# KEYWORD: shutdown
+#
+# You will need to set some variables in /etc/rc.conf to start upslog
+# properly, e.g.
+#
+# upslog=YES
+# upslog_flags="smartups@localhost /var/log/ups 60"
+#
+# Please refer to upslog(8) for more information about the arguments to pass
+# to upslog.
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="upslog"
+rcvar="${name}"
+command="@PREFIX@/bin/${name}"
+pidfile="@NUT_STATEDIR@/${name}.pid"
+
+if [ -f /etc/rc.subr ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	@ECHO@ -n " ${name}"
+	${command} ${upslog_flags} ${command_args}
+fi
diff --git a/ups-nut/files/upsmon.sh b/ups-nut/files/upsmon.sh
new file mode 100644
index 0000000000..0ea58a0f1a
--- /dev/null
+++ b/ups-nut/files/upsmon.sh
@@ -0,0 +1,26 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upsmon.sh,v 1.9 2023/01/08 01:14:23 gdt Exp $
+#
+# PROVIDE: upsmon
+# REQUIRE: upsd
+# BEFORE: SERVERS
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="upsmon"
+rcvar="${name}"
+command="@PREFIX@/sbin/${name}"
+pidfile="@NUT_STATEDIR@/${name}.pid"
+required_files="@NUT_CONFDIR@/${name}.conf"
+
+if [ -f /etc/rc.subr ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	@ECHO@ -n " ${name}"
+	${command} ${upsmon_flags} ${command_args}
+fi
diff --git a/ups-nut/options.mk b/ups-nut/options.mk
new file mode 100644
index 0000000000..574db3462a
--- /dev/null
+++ b/ups-nut/options.mk
@@ -0,0 +1,18 @@
+# $NetBSD: options.mk,v 1.2 2021/03/24 11:01:55 wiz Exp $
+
+PKG_OPTIONS_VAR=		PKG_OPTIONS.ups-nut
+PKG_OPTIONS_OPTIONAL_GROUPS=	ssl
+PKG_OPTIONS_GROUP.ssl=		nss openssl
+PKG_SUGGESTED_OPTIONS=		openssl
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Mnss)
+CONFIGURE_ARGS+=	--with-ssl=nss --with-nss --without-openssl
+.  include "../../devel/nss/buildlink3.mk"
+.elif !empty(PKG_OPTIONS:Mopenssl)
+CONFIGURE_ARGS+=	--with-ssl=openssl --without-nss --with-openssl
+.  include "../../security/openssl/buildlink3.mk"
+.else
+CONFIGURE_ARGS+=	--without-ssl
+.endif
diff --git a/ups-nut/patches/patch-aa b/ups-nut/patches/patch-aa
new file mode 100644
index 0000000000..9b275e782a
--- /dev/null
+++ b/ups-nut/patches/patch-aa
@@ -0,0 +1,15 @@
+$NetBSD: patch-aa,v 1.13 2022/04/26 23:28:25 gdt Exp $
+
+Default conf files go to example dir.
+
+--- conf/Makefile.in.orig	2022-04-01 00:42:19.000000000 +0000
++++ conf/Makefile.in
+@@ -207,7 +207,7 @@ BINDIR = @BINDIR@
+ CC = @CC@
+ CCDEPMODE = @CCDEPMODE@
+ CFLAGS = @CFLAGS@
+-CONFPATH = @CONFPATH@
++CONFPATH = $(DESTDIR)@prefix@/share/examples/nut
+ CPP = @CPP@
+ CPPCHECK = @CPPCHECK@
+ CPPFLAGS = @CPPFLAGS@
diff --git a/ups-nut/patches/patch-clients_upsclient.c b/ups-nut/patches/patch-clients_upsclient.c
new file mode 100644
index 0000000000..d98a783b23
--- /dev/null
+++ b/ups-nut/patches/patch-clients_upsclient.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-clients_upsclient.c,v 1.2 2018/09/21 00:59:53 jym Exp $
+
+Add missing header for timeval(3) functions.
+
+--- clients/upsclient.c.orig	2022-11-26 14:02:03.000000000 +0000
++++ clients/upsclient.c
+@@ -38,6 +38,7 @@
+ #ifndef WIN32
+ # include <netdb.h>
+ # include <sys/socket.h>
++# include <sys/time.h>
+ # include <netinet/in.h>
+ # include <arpa/inet.h>
+ # include <fcntl.h>
diff --git a/ups-nut/patches/patch-drivers_libhid.c b/ups-nut/patches/patch-drivers_libhid.c
new file mode 100644
index 0000000000..9d5311eb86
--- /dev/null
+++ b/ups-nut/patches/patch-drivers_libhid.c
@@ -0,0 +1,35 @@
+$NetBSD: patch-drivers_libhid.c,v 1.2 2022/04/26 23:28:25 gdt Exp $
+
+As comm_driver->get_interrupt() can return larger than the buffer size,
+limit the future accesses by this amount.  Bump the size of the buffer
+here as returns as high as 3500 have been seen.
+
+Not yet filed upstream.
+\todo Test with 2.8.0 release and drop or file upstream.
+
+--- drivers/libhid.c.orig	2022-04-04 12:00:53.000000000 +0000
++++ drivers/libhid.c
+@@ -686,7 +686,7 @@ bool_t HIDSetItemValue(hid_dev_handle_t 
+  */
+ int HIDGetEvents(hid_dev_handle_t udev, HIDData_t **event, int eventsize)
+ {
+-	unsigned char	buf[SMALLBUF];
++	unsigned char	buf[SMALLBUF * 16]; /* XXXMRG: seen at least 8x */
+ 	int		itemCount = 0;
+ 	int		buflen, ret;
+ 	size_t	i, r;
+@@ -758,6 +758,14 @@ int HIDGetEvents(hid_dev_handle_t udev, 
+ 		return buflen;	/* propagate "error" or "no event" code */
+ 	}
+ 
++	/*
++	 * XXXMRG: Avoid accessing beyond the buffer, no idea what sort of
++	 * failure mode this is.
++	 */
++	if ((size_t)buflen > sizeof buf) {
++		buflen = sizeof buf;
++	}
++
+ 	ret = file_report_buffer(reportbuf, buf, (size_t)buflen);
+ 	if (ret < 0) {
+ 		upsdebug_with_errno(1, "%s: failed to buffer report", __func__);
diff --git a/ups-nut/patches/patch-drivers_libusb0.c b/ups-nut/patches/patch-drivers_libusb0.c
new file mode 100644
index 0000000000..c27ae18d96
--- /dev/null
+++ b/ups-nut/patches/patch-drivers_libusb0.c
@@ -0,0 +1,12 @@
+$NetBSD: patch-drivers_libusb0.c,v 1.1 2022/04/26 23:28:25 gdt Exp $
+
+--- drivers/libusb0.c.orig	2022-03-27 12:59:49.000000000 +0000
++++ drivers/libusb0.c
+@@ -532,6 +532,7 @@ static int libusb_open(usb_dev_handle **
+  */
+ static int libusb_strerror(const int ret, const char *desc)
+ {
++	/* \todo: Possibly change to >= */
+ 	if (ret > 0) {
+ 		return ret;
+ 	}
diff --git a/ups-nut/patches/patch-drivers_libusb1.c b/ups-nut/patches/patch-drivers_libusb1.c
new file mode 100644
index 0000000000..f09307a2e7
--- /dev/null
+++ b/ups-nut/patches/patch-drivers_libusb1.c
@@ -0,0 +1,12 @@
+$NetBSD: patch-drivers_libusb1.c,v 1.1 2022/04/26 23:28:25 gdt Exp $
+
+--- drivers/libusb1.c.orig	2022-03-27 12:59:49.000000000 +0000
++++ drivers/libusb1.c
+@@ -599,6 +599,7 @@ static int nut_libusb_open(libusb_device
+  */
+ static int nut_libusb_strerror(const int ret, const char *desc)
+ {
++	/* \todo: Possibly change to >= */
+ 	if (ret > 0) {
+ 		return ret;
+ 	}
diff --git a/ups-nut/patches/patch-drivers_usbhid-ups.c b/ups-nut/patches/patch-drivers_usbhid-ups.c
new file mode 100644
index 0000000000..2597e30f1e
--- /dev/null
+++ b/ups-nut/patches/patch-drivers_usbhid-ups.c
@@ -0,0 +1,28 @@
+$NetBSD: patch-drivers_usbhid-ups.c,v 1.2 2022/11/26 14:45:47 gdt Exp $
+
+Avoid re-closing a udev that already was closed.  Avoids a double-close
+that triggers a SEGV in a list-delete operation.
+
+This may actually be the real bug for this code in libusb1.c:
+
+static int nut_libusb_open(libusb_device_handle **udevp,
+[ ... ]
+#ifndef __linux__ /* SUN_LIBUSB (confirmed to work on Solaris and FreeBSD) */
+	/* Causes a double free corruption in linux if device is detached! */
+
+as the same double-free list issue occurs here.
+
+
+Fixed upstream slightly differently, but essentially the same, in:
+https://github.com/networkupstools/nut/commit/89dbdd1e60
+
+--- drivers/usbhid-ups.c.orig	2022-11-26 14:02:03.000000000 +0000
++++ drivers/usbhid-ups.c
+@@ -1160,6 +1160,7 @@ void upsdrv_cleanup(void)
+ 	upsdebugx(1, "upsdrv_cleanup...");
+ 
+ 	comm_driver->close_dev(udev);
++	udev = HID_DEV_HANDLE_CLOSED;
+ 	Free_ReportDesc(pDesc);
+ 	free_report_buffer(reportbuf);
+ #ifndef SHUT_MODE


Home | Main Index | Thread Index | Old Index