Patch from upstream for a bug with the bcmxcp driver.
authorRobin H. Johnson <robbat2@gentoo.org>
Sun, 25 Feb 2007 11:23:47 +0000 (11:23 +0000)
committerRobin H. Johnson <robbat2@gentoo.org>
Sun, 25 Feb 2007 11:23:47 +0000 (11:23 +0000)
Package-Manager: portage-2.1.2-r11

sys-power/nut/ChangeLog
sys-power/nut/Manifest
sys-power/nut/files/digest-nut-2.0.5-r1 [new file with mode: 0644]
sys-power/nut/files/nut-2.0.5-bcmxcp-3phase.patch [new file with mode: 0644]
sys-power/nut/nut-2.0.5-r1.ebuild [new file with mode: 0644]

index 95c40c8c0407177491999ca6b7788efa0eaecddf..e672de29a2bce3b73c6698b01ccaab70688a56d5 100644 (file)
@@ -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.
index 5950584df85b98ed0b00bd859cbffdd6f9573d13..8b8e134bed4daf106bfe9762ba8ebf67d7d525a6 100644 (file)
@@ -5,6 +5,10 @@ AUX lighttpd_nut.conf 961 RMD160 636b45860713453dc88d7ed0392862735e329099 SHA1 1
 MD5 cb4007ab506c4c49dcf12a7a5516fff9 files/lighttpd_nut.conf 961
 RMD160 636b45860713453dc88d7ed0392862735e329099 files/lighttpd_nut.conf 961
 SHA256 5604058313d3cfeba426c69a756944bc7cc3ddb3813db68582e69dff1a00f7cb files/lighttpd_nut.conf 961
+AUX nut-2.0.5-bcmxcp-3phase.patch 2983 RMD160 f27271648742d96952902e27b83e4b5ed39067e7 SHA1 5c87466ddfed6455989871c14d77c488a4e75a58 SHA256 1ce3938251c834e8ea31850635c085ff7f4785d268d2257f4e1c05e8732056ee
+MD5 e34108f029decb93d403be53790b7507 files/nut-2.0.5-bcmxcp-3phase.patch 2983
+RMD160 f27271648742d96952902e27b83e4b5ed39067e7 files/nut-2.0.5-bcmxcp-3phase.patch 2983
+SHA256 1ce3938251c834e8ea31850635c085ff7f4785d268d2257f4e1c05e8732056ee files/nut-2.0.5-bcmxcp-3phase.patch 2983
 AUX upsd.rc6 587 RMD160 3a4c313d7ea20551fd6ea2f6b46901a5a082245b SHA1 c8d5f3294aa2b9a267d304c1d0a0619c617c2313 SHA256 7ce640a11d1d74a260a10d313f7d688463d80ea9649c27a99f14f4f8526253d3
 MD5 75ae39e289ce8dbcc2b48bb1c2761e63 files/upsd.rc6 587
 RMD160 3a4c313d7ea20551fd6ea2f6b46901a5a082245b files/upsd.rc6 587
@@ -66,14 +70,18 @@ EBUILD nut-2.0.4.ebuild 4799 RMD160 4fbcbaa4c7e719146fa2e64729521865f9b9151f SHA
 MD5 25382ac4db5d91a9c1d589192675a289 nut-2.0.4.ebuild 4799
 RMD160 4fbcbaa4c7e719146fa2e64729521865f9b9151f nut-2.0.4.ebuild 4799
 SHA256 a3014053beb6142acffe8a33704ce08e0427ac2789bd7e62dc0d18d6246ece44 nut-2.0.4.ebuild 4799
+EBUILD nut-2.0.5-r1.ebuild 5081 RMD160 b0367e5e7cc43ed7f7ca9dfc9fb9c756ae2141df SHA1 4521aeed2d3829d1739750b3bbec38536a81a5f0 SHA256 b72deb731a015fbdc769c2169172d1f4b160f20682e30b3dc903dc9f1b50cfa8
+MD5 19f407b242c6abb3df145d034fed9c55 nut-2.0.5-r1.ebuild 5081
+RMD160 b0367e5e7cc43ed7f7ca9dfc9fb9c756ae2141df nut-2.0.5-r1.ebuild 5081
+SHA256 b72deb731a015fbdc769c2169172d1f4b160f20682e30b3dc903dc9f1b50cfa8 nut-2.0.5-r1.ebuild 5081
 EBUILD nut-2.0.5.ebuild 5002 RMD160 88a98485e6ad1aee7e25681ca14784b4febd50f0 SHA1 952e3ced46ddd59f850c214ffd6e3eb4f0990c2a SHA256 998d6f98aefa58d3d3541ca00c53565abcde1b80c01724be49c60ae087f47f20
 MD5 dcf423ba716f4ed8db30fa5fa6039e3f nut-2.0.5.ebuild 5002
 RMD160 88a98485e6ad1aee7e25681ca14784b4febd50f0 nut-2.0.5.ebuild 5002
 SHA256 998d6f98aefa58d3d3541ca00c53565abcde1b80c01724be49c60ae087f47f20 nut-2.0.5.ebuild 5002
-MISC ChangeLog 11042 RMD160 98df5fc1906fa018291e3cf5a29540ef8b399748 SHA1 8e236cba5c5cd233a615e85e9959953af129bf38 SHA256 07cdebeea3b1f304b4f49eca8c51ef982f3395b7a90545db530154a2017736d3
-MD5 0d56e93b1edcff6d26dd4b3a8c0a6535 ChangeLog 11042
-RMD160 98df5fc1906fa018291e3cf5a29540ef8b399748 ChangeLog 11042
-SHA256 07cdebeea3b1f304b4f49eca8c51ef982f3395b7a90545db530154a2017736d3 ChangeLog 11042
+MISC ChangeLog 11243 RMD160 89ca0cde7ba9ba9d1bfd7eba50c22b27ec5b9090 SHA1 b8e5a586ae9f9949afeb338451a8c8ba213fdf1b SHA256 70c0ea39a44465a395bc3c421dff981259a507f6d30a10fd5f2273f01b41a113
+MD5 749b8d2488a1c443ba0a7046cf8efab2 ChangeLog 11243
+RMD160 89ca0cde7ba9ba9d1bfd7eba50c22b27ec5b9090 ChangeLog 11243
+SHA256 70c0ea39a44465a395bc3c421dff981259a507f6d30a10fd5f2273f01b41a113 ChangeLog 11243
 MISC metadata.xml 219 RMD160 7737543ce33cd412792e332121aa1c6ed452adfc SHA1 6c360930b80d6f4168ba1a486a25ad176505ea63 SHA256 8b2ef93d0d6f03a1ad115651dc46a7752e7775a62a32a7046c3294e50b14725b
 MD5 a961228140ef319b2ddba54d99b6e401 metadata.xml 219
 RMD160 7737543ce33cd412792e332121aa1c6ed452adfc metadata.xml 219
@@ -102,11 +110,14 @@ SHA256 4d18f4ecac989c959db626584630384b449594a864db3308df3801807620e705 files/di
 MD5 270b9f0a8aca065d2bff7c6ed52c096d files/digest-nut-2.0.5 229
 RMD160 af5257a0dbc5ad3ba25177d900e971613d1d676e files/digest-nut-2.0.5 229
 SHA256 edfec92b45e8c6d3dff87771a2a0535666d38fdba5c150a00b518ee9f4fcdff3 files/digest-nut-2.0.5 229
+MD5 270b9f0a8aca065d2bff7c6ed52c096d files/digest-nut-2.0.5-r1 229
+RMD160 af5257a0dbc5ad3ba25177d900e971613d1d676e files/digest-nut-2.0.5-r1 229
+SHA256 edfec92b45e8c6d3dff87771a2a0535666d38fdba5c150a00b518ee9f4fcdff3 files/digest-nut-2.0.5-r1 229
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6-ecc01.6 (GNU/Linux)
 Comment: Robbat2 @ Orbis-Terrarum Networks - The text below is a digital signature. If it doesn't make any sense to you, ignore it.
 
-iD8DBQFF4XBYPgYlrpyh79cRAub+AJ9mV/XAqqRFfYTszZEkI/DCYXnb+wCfcgL1
-i9QSM3xGWfFrlCdZkF/2J28=
-=CKiA
+iD8DBQFF4XHXPgYlrpyh79cRAtxaAJoCu8HojlgUZOn6GlvQ0Ml+g4gSMgCfQrOM
+/WkOQRjUOX6sjZcp+8mzhiw=
+=xGHt
 -----END PGP SIGNATURE-----
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 (file)
index 0000000..782b315
--- /dev/null
@@ -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 (file)
index 0000000..98f023e
--- /dev/null
@@ -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 (file)
index 0000000..62bc304
--- /dev/null
@@ -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."
+}