update apcupsd to 3.4.19, switch from net-snmp support to internal snmp

support (removing the separate snmp flavour), and add an rc file.

from maintainer Kirill Bychkov; wantlib-x11 synced by me.
This commit is contained in:
sthen 2011-08-30 09:59:30 +00:00
parent b848622381
commit acc69348be
8 changed files with 56 additions and 119 deletions

View File

@ -1,15 +1,13 @@
# $OpenBSD: Makefile,v 1.11 2011/05/14 21:29:03 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.12 2011/08/30 09:59:30 sthen Exp $
COMMENT-main = daemon for controlling APC UPSes
COMMENT-cgi = CGI scripts for web monitoring
COMMENT-x11 = gapcmon - GUI for apcupsd
DISTNAME = apcupsd-3.14.8
DISTNAME = apcupsd-3.14.9
PKGNAME-main = ${DISTNAME}
REVISION-main = 2
PKGNAME-cgi = ${DISTNAME:S/-/-cgi-/}
PKGNAME-x11 = ${DISTNAME:S/-/-x11-/}
REVISION-x11 = 2
CATEGORIES = sysutils
@ -17,7 +15,7 @@ HOMEPAGE = http://www.apcupsd.com
MAINTAINER = Kirill Bychkov <yason@linklevel.net>
# GPLv2
# GPLv2
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM =Yes
@ -31,7 +29,6 @@ MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=apcupsd/}
CONFIGURE_STYLE = gnu old # old prevents overriding sysconfdir
USE_GMAKE = Yes
USE_GROFF = Yes
MAKE_FLAGS = VERBOSE=2
WEB_ROOT = /var/www
@ -44,10 +41,10 @@ CONFIGURE_ARGS = --mandir=${PREFIX}/man \
--with-cgi-bin=${WEB_ROOT}/cgi-bin/apcupsd \
--with-lock-dir=/var/run \
--with-nisip=127.0.0.1 \
--enable-test \
--enable-usb
PSEUDO_FLAVORS = no_x11
FLAVORS = snmp
FLAVOR ?=
MULTI_PACKAGES = -main
@ -55,7 +52,7 @@ MULTI_PACKAGES = -main
MULTI_PACKAGES += -cgi
PREFIX-cgi = ${WEB_ROOT}
CONFIGURE_ARGS += --enable-cgi
WANTLIB-cgi = c pthread gd
WANTLIB-cgi = c pthread gd
LIB_DEPENDS-cgi = graphics/gd
RUN_DEPENDS-cgi =
@ -68,19 +65,12 @@ LIB_DEPENDS-x11 = devel/gconf2 \
RUN_DEPENDS-x11 = devel/desktop-file-utils \
${MODGETTEXT_RUN_DEPENDS}
WANTLIB-x11 += ORBit-2 X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes
WANTLIB-x11 += Xi Xinerama Xrandr Xrender atk-1.0 cairo expat fontconfig
WANTLIB-x11 += freetype gconf-2 gdk-x11-2.0 gdk_pixbuf-2.0 gio-2.0 glib-2.0
WANTLIB-x11 += gmodule-2.0 gobject-2.0 gthread-2.0 gtk-x11-2.0
WANTLIB-x11 += m pango-1.0 pangocairo-1.0 pangoft2-1.0 pixman-1 png
WANTLIB-x11 += pthread-stubs xcb-render xcb z ${WANTLIB} c pthread
WANTLIB-x11 += GL X11-xcb Xxf86vm drm xcb-shm
.endif
.if ${FLAVOR:L:Msnmp}
CONFIGURE_ARGS += --enable-net-snmp
LIB_DEPENDS-main += net/net-snmp
WANTLIB-main = ${WANTLIB} crypto netsnmp
WANTLIB-x11 += GL X11 Xcomposite Xcursor Xdamage Xext Xfixes Xi Xinerama
WANTLIB-x11 += Xrandr Xrender atk-1.0 c cairo expat fontconfig freetype gconf-2
WANTLIB-x11 += gdk-x11-2.0 gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0
WANTLIB-x11 += gobject-2.0 gthread-2.0 gtk-x11-2.0 m pango-1.0 pangocairo-1.0
WANTLIB-x11 += pangoft2-1.0 pixman-1 png pthread pthread-stubs xcb-render
WANTLIB-x11 += xcb-shm xcb z ${WANTLIB}
.endif
FAKE_FLAGS = sysconfdir=${TRUEPREFIX}/share/examples/apcupsd/etc

View File

@ -1,5 +1,5 @@
MD5 (apcupsd-3.14.8.tar.gz) = zRfwqQPcIiDlXtVOJCNZ0g==
RMD160 (apcupsd-3.14.8.tar.gz) = 9kJYLgFQbruYbBbfAUKea7CMfos=
SHA1 (apcupsd-3.14.8.tar.gz) = y3p7QBeX4SnJKmuNwr97GTsdbHI=
SHA256 (apcupsd-3.14.8.tar.gz) = jn8ldNOrr2Y32j55CGDD+bpk+rHsflC7CA3kQ5RBxac=
SIZE (apcupsd-3.14.8.tar.gz) = 1317601
MD5 (apcupsd-3.14.9.tar.gz) = ql4sKVSoHC8H4KNW44/oUw==
RMD160 (apcupsd-3.14.9.tar.gz) = vhozuFx5D8O8YrqzcKYtAU2/Clc=
SHA1 (apcupsd-3.14.9.tar.gz) = Hp6KBU8XxVTAR+wdezY9NVUwWLw=
SHA256 (apcupsd-3.14.9.tar.gz) = AEHwCy5igFbmaNtymNCvCtUB/hJ+DFw0TuyYc6CYipI=
SIZE (apcupsd-3.14.9.tar.gz) = 1334762

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-doc_apcupsd_conf_5,v 1.1 2011/08/30 09:59:30 sthen Exp $
--- doc/apcupsd.conf.5.orig Wed May 6 01:51:26 2009
+++ doc/apcupsd.conf.5 Mon Jul 25 10:10:31 2011
@@ -1,5 +1,4 @@
.\" manual page [] for apcupsd.conf version 3.14.6
-.Pp
.Dd January 10, 2009
.Dt APCUPSD.CONF 5
.Os apcupsd.conf v3.14.6
@@ -82,7 +81,6 @@ for most situations.
apcupsd creates a lockfile for the serial or USB port in the specified
directory. It must be changed when running more than one copy of apcupsd
on the same computer to control multiple UPSes.
-
.It SCRIPTDIR <path>
.Pp
Directory in which apccontrol and event scripts are located.

View File

@ -1,83 +0,0 @@
$OpenBSD: patch-src_apcupsd_c,v 1.1.1.1 2010/05/25 21:56:33 sthen Exp $
--- src/apcupsd.c.orig Tue May 18 02:07:50 2010
+++ src/apcupsd.c Tue May 18 02:20:02 2010
@@ -68,9 +68,10 @@ UPSINFO *core_ups = NULL;
static void daemon_start(void);
-int shm_OK = 0;
+int pidcreated = 0;
extern int kill_on_powerfail;
extern FILE *trace_fd;
+extern char *pidfile;
/*
* The terminate function and trapping signals allows apcupsd
@@ -91,11 +92,10 @@ void apcupsd_terminate(int sig)
log_event(ups, LOG_WARNING, _("apcupsd exiting, signal %u\n"), sig);
clear_files();
-
device_close(ups);
-
delete_lockfile(ups);
-
+ if (pidcreated)
+ unlink(pidfile);
clean_threads();
log_event(ups, LOG_WARNING, _("apcupsd shutdown succeeded"));
destroy_ups(ups);
@@ -107,6 +107,8 @@ void apcupsd_error_cleanup(UPSINFO *ups)
{
device_close(ups);
delete_lockfile(ups);
+ if (pidcreated)
+ unlink(pidfile);
clean_threads();
log_event(ups, LOG_ERR, _("apcupsd error shutdown completed"));
destroy_ups(ups);
@@ -261,7 +263,6 @@ int main(int argc, char *argv[])
Dmsg1(10, "Attached to driver: %s\n", ups->driver->driver_name);
ups->start_time = time(NULL);
- delete_lockfile(ups);
if (!hibernate_ups && !shutdown_ups && go_background) {
daemon_start();
@@ -270,7 +271,6 @@ int main(int argc, char *argv[])
openlog("apcupsd", LOG_CONS | LOG_PID, ups->sysfac);
}
- make_pid_file();
init_signals(apcupsd_terminate);
/* Create temp events file if we are not doing a hibernate or shutdown */
@@ -282,6 +282,14 @@ int main(int argc, char *argv[])
}
}
+ if (create_lockfile(ups) == LCKERROR) {
+ Error_abort1(_("Failed to acquire device lock file\n"),
+ ups->device);
+ }
+
+ make_pid_file();
+ pidcreated = 1;
+
setup_device(ups);
if (hibernate_ups) {
@@ -295,13 +303,6 @@ int main(int argc, char *argv[])
}
prep_device(ups);
-
- if (create_lockfile(ups) == LCKERROR) {
- Error_abort1(_("Failed to reacquire serial port lock file on device %s\n"),
- ups->device);
- }
-
- shm_OK = 1;
/*
* From now ... we must _only_ start up threads!

View File

@ -5,6 +5,6 @@ This switch is on by default.
To run scripts in chrooted apache (default behaviour), configuration
files must be available to the webserver:
# mv ${SYSCONFDIR}/apcupsd /var/www/${SYSCONFDIR}/apcupsd
# ln -s /var/www/${SYSCONFIDR}/apcupsd ${SYSCONFDIR}/
# ln -s /var/www/${SYSCONFDIR}/apcupsd ${SYSCONFDIR}/
And some libraries must be copied in:
# ${WEB_ROOT}/cgi-bin/apcupsd/copy-libs.sh

View File

@ -1,10 +1,3 @@
To start apcupsd at boot time, edit ${SYSCONFDIR}/apcupsd/apcupsd.conf
and add the following lines to /etc/rc.local:
if [ -x ${PREFIX}/sbin/apcupsd ]; then
echo -n ' apcupsd'; ${PREFIX}/sbin/apcupsctl start
fi
To allow the system to be fully powered down (in order to preserve
UPS battery), add the following lines to /etc/rc.shutdown:

View File

@ -1,4 +1,5 @@
@comment $OpenBSD: PLIST-main,v 1.1.1.1 2010/05/25 21:56:33 sthen Exp $
@comment $OpenBSD: PLIST-main,v 1.2 2011/08/30 09:59:30 sthen Exp $
@pkgpath sysutils/apcupsd,snmp
@group bin
@man man/man5/apcupsd.conf.5
@man man/man8/apcaccess.8
@ -11,8 +12,8 @@ sbin/apcupsctl
@bin sbin/apcupsd
@bin sbin/smtp
@comment share/applications/
share/doc/apcupsd/
@group
share/doc/apcupsd/
share/doc/apcupsd/COPYING
share/doc/apcupsd/COPYRIGHT
share/doc/apcupsd/DISCLAIMER
@ -82,3 +83,4 @@ share/examples/apcupsd/status/SmartUPS700-2.status
share/examples/apcupsd/status/SmartUPS700.status
share/examples/apcupsd/status/newbackupspro1.status
share/examples/apcupsd/status/newbackupspro2.status
@rcscript ${RCDIR}/apcupsd

View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# $OpenBSD: apcupsd.rc,v 1.1 2011/08/30 09:59:30 sthen Exp $
daemon="${TRUEPREFIX}/sbin/apcupsd"
daemon_flags="--kill-on-powerfail"
. /etc/rc.d/rc.subr
rc_reload=NO
rc_pre() {
if [ -f ${SYSCONFDIR}/apcupsd/powerfail ]; then
rm -f ${SYSCONFDIR}/apcupsd/powerfail
fi
}
rc_cmd $1