summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-02-25 11:23:47 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2007-02-25 11:23:47 +0000
commit903c60ab669067049e40684327b9f2ebfddcbe2c (patch)
tree4bac0acd32dc5c58ce3ffcd85d9fb1568e0e5244 /sys-power
parentFix bug #157069. (diff)
downloadgentoo-2-903c60ab669067049e40684327b9f2ebfddcbe2c.tar.gz
gentoo-2-903c60ab669067049e40684327b9f2ebfddcbe2c.tar.bz2
gentoo-2-903c60ab669067049e40684327b9f2ebfddcbe2c.zip
Patch from upstream for a bug with the bcmxcp driver.
(Portage version: 2.1.2-r11)
Diffstat (limited to 'sys-power')
-rw-r--r--sys-power/nut/ChangeLog8
-rw-r--r--sys-power/nut/files/digest-nut-2.0.5-r13
-rw-r--r--sys-power/nut/files/nut-2.0.5-bcmxcp-3phase.patch91
-rw-r--r--sys-power/nut/nut-2.0.5-r1.ebuild189
4 files changed, 290 insertions, 1 deletions
diff --git a/sys-power/nut/ChangeLog b/sys-power/nut/ChangeLog
index 95c40c8c0407..e672de29a2bc 100644
--- a/sys-power/nut/ChangeLog
+++ b/sys-power/nut/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-power/nut
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/ChangeLog,v 1.27 2007/02/25 11:09:39 robbat2 Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/ChangeLog,v 1.28 2007/02/25 11:23:46 robbat2 Exp $
+
+*nut-2.0.5-r1 (25 Feb 2007)
+
+ 25 Feb 2007; Robin H. Johnson <robbat2@gentoo.org>
+ +files/nut-2.0.5-bcmxcp-3phase.patch, +nut-2.0.5-r1.ebuild:
+ Patch from upstream for a bug with the bcmxcp driver.
25 Feb 2007; Robin H. Johnson <robbat2@gentoo.org> nut-2.0.5.ebuild:
Fix bug #157069.
diff --git a/sys-power/nut/files/digest-nut-2.0.5-r1 b/sys-power/nut/files/digest-nut-2.0.5-r1
new file mode 100644
index 000000000000..782b3150a09e
--- /dev/null
+++ b/sys-power/nut/files/digest-nut-2.0.5-r1
@@ -0,0 +1,3 @@
+MD5 b08fde86191154bbcfda860f95a5dca2 nut-2.0.5.tar.gz 809006
+RMD160 e5f90a73932e038d3dfee8cb32faf097d99a7e0b nut-2.0.5.tar.gz 809006
+SHA256 5e1bfecfca528104db7025050c81258ee20620df7497ab5988ad461d951c8203 nut-2.0.5.tar.gz 809006
diff --git a/sys-power/nut/files/nut-2.0.5-bcmxcp-3phase.patch b/sys-power/nut/files/nut-2.0.5-bcmxcp-3phase.patch
new file mode 100644
index 000000000000..98f023e444c0
--- /dev/null
+++ b/sys-power/nut/files/nut-2.0.5-bcmxcp-3phase.patch
@@ -0,0 +1,91 @@
+Signed-off-by: Kjell Claesson <kjell.claesson@epost.tidanet.se>
+Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
+Date: Sun, 25 Feb 2007 11:08:33 +0100
+
+Patch from upstream developer (Kjell) for bcmxcp on Compaq and HP
+hardware, due to 3-phase configuration bug.
+
+--- nut-2.0.5.orig/drivers/bcmxcp.c 2006-12-14 20:06:19.000000000 +0100
++++ nut-2.0.5/drivers/bcmxcp.c 2007-01-22 22:55:41.000000000 +0100
+@@ -57,6 +57,7 @@
+ char *ABMStatus[4] = {"Charging", "Discharging", "Floating", "Resting"};
+ unsigned char AUTHOR[4] = {0xCF, 0x69, 0xE8, 0xD5}; /* Autorisation command */
+ int nphases = 0;
++char *cpu_name[] = {"Cont:", "Inve:", "Rect:", "Netw:", "Disp:"};
+
+ /* get_word funktion from nut driver metasys.c */
+ int get_word(const unsigned char *buffer) /* return an integer reading a word in the supplied buffer */
+@@ -727,23 +728,11 @@
+ unsigned char answer[256];
+ char *pTmp, sValue[17];
+ int iRating = 0, iIndex = 0, res, len;
+- int voltage = 0;
++ int voltage = 0, ncpu = 0, buf;
+
+ /* Set driver version info */
+ dstate_setinfo("driver.version.internal", "%s", DRV_VERSION);
+
+- /* Get information on Phases from UPS */
+- res = command_read_sequence(PW_UPS_TOP_DATA_REQ, answer);
+- if (res <= 0)
+- fatal_with_errno("Could not communicate with the ups");
+-
+- nphases = (answer[0] & 0x0F) +1;
+- dstate_setinfo("input.phases", "%d", nphases);
+-
+-
+- /* Init BCM/XCP <-> NUT meter map */
+- init_meter_map();
+-
+ /* Init BCM/XCP alarm descriptions */
+ init_alarm_map();
+
+@@ -761,15 +750,26 @@
+ /* Get number of CPU's in ID block */
+ len = answer[iIndex++];
+
++ buf = len * 11;
++ pTmp = xmalloc(buf+1);
++
++ pTmp[0] = 0;
+ /* If there is one or more CPU number, get it */
+ if (len > 0) {
+ do {
+- /* Get the ups firmware. The major number is in the last byte, the minor is in the first */
+- dstate_setinfo("ups.firmware", "%02x.%02x", (unsigned char)answer[iIndex+1],
+- (unsigned char)answer[iIndex]);
++ if ((answer[iIndex] != 0x00) || (answer[iIndex+1] != 0x00)) {
++ /* Get the ups firmware. The major number is in the last byte, the minor is in the first */
++ snprintfcat(pTmp, buf+1, "%s%02x.%02x ", cpu_name[ncpu], answer[iIndex+1], answer[iIndex]);
++ }
+ iIndex += 2;
+ len--;
+- } while ((strcmp("00.00", dstate_getinfo("ups.firmware")) == 0) && len > 0);
++ ncpu++;
++
++ } while ((len > 0) && (ncpu <= 5));
++
++ dstate_setinfo("ups.firmware", "%s", pTmp);
++
++ free(pTmp);
+
+ /* Increment index to point at end of CPU bytes. */
+ iIndex += len * 2;
+@@ -786,8 +786,15 @@
+ }
+ dstate_setinfo("ups.power.nominal", "%d", iRating);
+
+- /* Skip UPS' number of phases and phase angle, as NUT do not care */
+- iIndex += 2;
++ /* Get information on Phases from UPS */
++ nphases = (answer[iIndex++]);
++ dstate_setinfo("output.phases", "%d", nphases);
++
++ /* Init BCM/XCP <-> NUT meter map */
++ init_meter_map();
++
++ /* Skip UPS' phase angle, as NUT do not care */
++ iIndex += 1;
+
+ /* Get length of UPS description */
+ len = answer[iIndex++];
diff --git a/sys-power/nut/nut-2.0.5-r1.ebuild b/sys-power/nut/nut-2.0.5-r1.ebuild
new file mode 100644
index 000000000000..62bc30477dfa
--- /dev/null
+++ b/sys-power/nut/nut-2.0.5-r1.ebuild
@@ -0,0 +1,189 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/nut-2.0.5-r1.ebuild,v 1.1 2007/02/25 11:23:46 robbat2 Exp $
+
+inherit eutils fixheadtails
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="Network-UPS Tools"
+HOMEPAGE="http://www.networkupstools.org/"
+# Nut mirrors are presently broken
+#SRC_URI="mirror://nut/source/${PV%.*}/${MY_P}.tar.gz"
+SRC_URI="http://www.networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
+
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
+IUSE="cgi snmp usb ssl"
+
+RDEPEND="cgi? ( >=media-libs/gd-2 )
+ snmp? ( net-analyzer/net-snmp )
+ usb? ( >=dev-libs/libusb-0.1.12 )
+ ssl? ( dev-libs/openssl )"
+DEPEND="$RDEPEND
+ >=sys-apps/sed-4
+ >=sys-devel/autoconf-2.58"
+
+# public files should be 644 root:root
+NUT_PUBLIC_FILES="/etc/nut/{{hosts,upsset,ups,upssched}.conf,upsstats{,-single}.html}"
+# private files should be 640 root:nut - readable by nut, writeable by root,
+NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
+
+pkg_setup() {
+ enewgroup nut 84
+ enewuser nut 84 -1 /var/state/nut nut,tty
+ # try to add nut to the tty group for old cases where it already existed
+ gpasswd -a nut tty
+ # in some cases it wasn't in the nut group either!
+ gpasswd -a nut nut
+ warningmsg
+}
+
+src_unpack() {
+ unpack ${A}
+
+ EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/upsstats-upsset-link-2.0.5.patch
+ EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/nut-2.0.5-bcmxcp-3phase.patch
+
+ cd "${S}"
+
+ sed -e "s/install: install-dirs/install: install-dirs install-conf/" \
+ -i Makefile.in || die "sed failed"
+
+ ht_fix_file configure.in
+
+ sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
+ -i configure.in || die "sed failed"
+
+ ebegin "Recreating configure"
+ WANT_AUTOCONF=2.5 autoconf || die "autoconf failed"
+ eend $?
+}
+
+src_compile() {
+ local myconf
+
+ if [ -n "${NUT_DRIVERS}" ]; then
+ myconf="${myconf} --with-drivers=${NUT_DRIVERS// /,}"
+ fi
+
+ econf \
+ --with-user=nut \
+ --with-group=nut \
+ --with-drvpath=/lib/nut \
+ --sysconfdir=/etc/nut \
+ --with-logfacility=LOG_DAEMON \
+ --with-statepath=/var/lib/nut \
+ $(use_with ssl) \
+ $(use_with cgi) \
+ $(use_with cgi cgipath /usr/share/nut) \
+ ${myconf} || die "econf failed"
+
+ emake || die "compile problem"
+
+ if use snmp; then
+ emake snmp || die "snmp compile problem"
+ fi
+
+ if use usb; then
+ emake usb || die "usb compile problem"
+ fi
+
+ if use cgi; then
+ emake cgi || die "cgi compile problem"
+ fi
+}
+
+src_install() {
+ make DESTDIR="${D}" install install-lib || die "make install failed"
+
+ dodir /sbin
+ dosym /lib/nut/upsdrvctl /sbin/upsdrvctl
+ # This needs to exist for the scripts
+ dosym /lib/nut/upsdrvctl /usr/sbin/upsdrvctl
+
+ if use snmp; then
+ make DESTDIR="${D}" install-snmp || die "make install-snmp failed"
+ fi
+
+ if use usb; then
+ make DESTDIR="${D}" install-usb || die "make install-usb failed"
+ fi
+
+ if use cgi; then
+ make DESTDIR="${D}" install-cgi || die "make install-cgi failed"
+ make DESTDIR="${D}" install-cgi-conf || die "make install-cgi-conf failed"
+ einfo "CGI monitoring scripts are installed in /usr/share/nut."
+ einfo "copy them to your web server's ScriptPath to activate."
+ einfo "If you use lighttpd, see lighttpd_nut.conf in the documentation."
+ fi
+
+ # this must be done after all of the install phases
+ for i in "${D}"/etc/nut/*.sample ; do
+ mv "${i}" "${i/.sample/}"
+ done
+
+
+ dodoc ChangeLog CREDITS INSTALL MAINTAINERS NEWS README UPGRADING \
+ docs/{FAQ,*.txt}
+
+ newdoc lib/README README.lib
+
+ dodoc ${FILESDIR}/lighttpd_nut.conf
+
+ docinto cables
+ dodoc docs/cables/*
+
+
+ exeinto /etc/init.d
+ newexe "${FILESDIR}/upsd.rc6" upsd
+ newexe "${FILESDIR}/upsdrv.rc6-r1" upsdrv
+ newexe "${FILESDIR}/upsmon.rc6" upsmon
+
+ # This sets up permissions for nut to access a UPS
+ insinto /etc/udev/rules.d/
+ newins scripts/hotplug-ng/nut-usbups.rules 70-nut-usbups.rules
+
+ keepdir /var/lib/nut
+
+ fperms 0700 /var/lib/nut
+ fowners nut:nut /var/lib/nut
+
+ eval fperms 0640 ${NUT_PRIVATE_FILES}
+ eval fowners root:nut ${NUT_PRIVATE_FILES}
+
+ eval fperms 0644 ${NUT_PUBLIC_FILES}
+ eval fowners root:root ${NUT_PUBLIC_FILES}
+
+ # this is installed for 2.4 and fbsd guys
+ if ! has_version sys-fs/udev; then
+ insinto /etc/hotplug/usb
+ insopts -m 755
+ doins scripts/hotplug-ng/nut-usbups.hotplug
+ fi
+}
+
+pkg_postinst() {
+ # this is to ensure that everybody that installed old versions still has
+ # correct permissions
+ chown nut:nut ${ROOT}/var/lib/nut 2>/dev/null
+ chmod 0700 ${ROOT}/var/lib/nut 2>/dev/null
+
+ eval chown root:nut ${ROOT}${NUT_PRIVATE_FILES} 2>/dev/null
+ eval chmod 0640 ${ROOT}${NUT_PRIVATE_FILES} 2>/dev/null
+
+ eval chown root:root ${ROOT}${NUT_PUBLIC_FILES} 2>/dev/null
+ eval chmod 0644 ${ROOT}${NUT_PUBLIC_FILES} 2>/dev/null
+
+ warningmsg
+}
+
+warningmsg() {
+ ewarn "Please note that NUT now runs under the 'nut' user."
+ ewarn "NUT is in the tty group for access to RS-232 UPS."
+ ewarn "However if you use a USB UPS you may need to look at the udev or"
+ ewarn "hotplug rules that are installed."
+}