| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sys-power/nut/nut-2.6.3.ebuild,v 1.7 2012/09/20 11:53:50 xarthisius Exp $
|
| 4 |
|
| 5 |
EAPI=2
|
| 6 |
inherit autotools bash-completion eutils fixheadtails multilib user
|
| 7 |
|
| 8 |
MY_P=${P/_/-}
|
| 9 |
|
| 10 |
DESCRIPTION="Network-UPS Tools"
|
| 11 |
HOMEPAGE="http://www.networkupstools.org/"
|
| 12 |
# Nut mirrors are presently broken
|
| 13 |
SRC_URI="http://random.networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz
|
| 14 |
http://www.networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
|
| 15 |
|
| 16 |
LICENSE="GPL-2"
|
| 17 |
SLOT="0"
|
| 18 |
KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd"
|
| 19 |
IUSE="avahi cgi snmp usb ssl tcpd xml"
|
| 20 |
|
| 21 |
RDEPEND="avahi? ( net-dns/avahi )
|
| 22 |
cgi? ( >=media-libs/gd-2[png] )
|
| 23 |
snmp? ( net-analyzer/net-snmp )
|
| 24 |
usb? ( virtual/libusb:0 )
|
| 25 |
ssl? ( >=dev-libs/openssl-1 )
|
| 26 |
tcpd? ( sys-apps/tcp-wrappers )
|
| 27 |
xml? ( >=net-libs/neon-0.25.0 )
|
| 28 |
>=sys-fs/udev-114"
|
| 29 |
DEPEND="$RDEPEND
|
| 30 |
>=sys-apps/sed-4
|
| 31 |
virtual/pkgconfig"
|
| 32 |
|
| 33 |
S=${WORKDIR}/${MY_P}
|
| 34 |
|
| 35 |
# public files should be 644 root:root
|
| 36 |
NUT_PUBLIC_FILES="/etc/nut/{ups,upssched}.conf"
|
| 37 |
# private files should be 640 root:nut - readable by nut, writeable by root,
|
| 38 |
NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
|
| 39 |
# public files should be 644 root:root, only installed if USE=cgi
|
| 40 |
NUT_CGI_FILES="/etc/nut/{{hosts,upsset}.conf,upsstats{,-single}.html}"
|
| 41 |
|
| 42 |
pkg_setup() {
|
| 43 |
enewgroup nut 84
|
| 44 |
enewuser nut 84 -1 /var/lib/nut nut,uucp
|
| 45 |
# As of udev-104, NUT must be in uucp and NOT in tty.
|
| 46 |
gpasswd -d nut tty 2>/dev/null
|
| 47 |
gpasswd -a nut uucp 2>/dev/null
|
| 48 |
# in some cases on old systems it wasn't in the nut group either!
|
| 49 |
gpasswd -a nut nut 2>/dev/null
|
| 50 |
warningmsg ewarn
|
| 51 |
}
|
| 52 |
|
| 53 |
src_prepare() {
|
| 54 |
ht_fix_file configure.in
|
| 55 |
|
| 56 |
epatch "${FILESDIR}"/${PN}-2.4.1-no-libdummy.patch
|
| 57 |
epatch "${FILESDIR}"/${PN}-2.6.2-lowspeed-buffer-size.patch
|
| 58 |
#epatch "${FILESDIR}"/${PN}-2.6.3-CVE-2012-2944.patch
|
| 59 |
|
| 60 |
sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
|
| 61 |
-i configure.in || die
|
| 62 |
|
| 63 |
sed -e "s:52.nut-usbups.rules:70-nut-usbups.rules:" \
|
| 64 |
-i scripts/udev/Makefile.am || die
|
| 65 |
|
| 66 |
rm -f ltmain.sh m4/lt* m4/libtool.m4
|
| 67 |
|
| 68 |
sed -i \
|
| 69 |
-e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \
|
| 70 |
lib/libupsclient{.pc,-config}.in || die #361685
|
| 71 |
|
| 72 |
eautoreconf
|
| 73 |
}
|
| 74 |
|
| 75 |
src_configure() {
|
| 76 |
local myconf
|
| 77 |
|
| 78 |
if [ -n "${NUT_DRIVERS}" ]; then
|
| 79 |
myconf="${myconf} --with-drivers=${NUT_DRIVERS// /,}"
|
| 80 |
fi
|
| 81 |
|
| 82 |
use cgi && myconf="${myconf} --with-cgipath=/usr/share/nut/cgi"
|
| 83 |
|
| 84 |
# TODO: USE flag for sys-power/powerman
|
| 85 |
econf \
|
| 86 |
--sysconfdir=/etc/nut \
|
| 87 |
--datarootdir=/usr/share/nut \
|
| 88 |
--datadir=/usr/share/nut \
|
| 89 |
--disable-static \
|
| 90 |
--with-dev \
|
| 91 |
$(use_with usb) \
|
| 92 |
--without-hal \
|
| 93 |
$(use_with snmp) \
|
| 94 |
$(use_with xml neon) \
|
| 95 |
--without-powerman \
|
| 96 |
$(use_with ssl) \
|
| 97 |
$(use_with tcpd wrap) \
|
| 98 |
$(use_with cgi) \
|
| 99 |
$(use_with avahi) \
|
| 100 |
--with-statepath=/var/lib/nut \
|
| 101 |
--with-drvpath=/$(get_libdir)/nut \
|
| 102 |
--with-htmlpath=/usr/share/nut/html \
|
| 103 |
--with-user=nut \
|
| 104 |
--with-group=nut \
|
| 105 |
--with-logfacility=LOG_DAEMON \
|
| 106 |
${myconf}
|
| 107 |
}
|
| 108 |
|
| 109 |
src_install() {
|
| 110 |
emake DESTDIR="${D}" install || die
|
| 111 |
|
| 112 |
find "${D}" -name '*.la' -exec rm -f {} +
|
| 113 |
|
| 114 |
dodir /sbin
|
| 115 |
dosym /$(get_libdir)/nut/upsdrvctl /sbin/upsdrvctl
|
| 116 |
# This needs to exist for the scripts
|
| 117 |
dosym /$(get_libdir)/nut/upsdrvctl /usr/sbin/upsdrvctl
|
| 118 |
|
| 119 |
if use cgi; then
|
| 120 |
elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
|
| 121 |
elog "copy them to your web server's ScriptPath to activate (this is a"
|
| 122 |
elog "change from the old location)."
|
| 123 |
elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
|
| 124 |
fi
|
| 125 |
|
| 126 |
# this must be done after all of the install phases
|
| 127 |
for i in "${D}"/etc/nut/*.sample ; do
|
| 128 |
mv "${i}" "${i/.sample/}"
|
| 129 |
done
|
| 130 |
|
| 131 |
dodoc AUTHORS ChangeLog docs/*.txt MAINTAINERS NEWS README TODO UPGRADING || die
|
| 132 |
|
| 133 |
newdoc lib/README README.lib || die
|
| 134 |
newdoc "${FILESDIR}"/lighttpd_nut.conf-2.2.0 lighttpd_nut.conf || die
|
| 135 |
|
| 136 |
docinto cables
|
| 137 |
dodoc docs/cables/* || die
|
| 138 |
|
| 139 |
newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsd upsd || die
|
| 140 |
newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv || die
|
| 141 |
newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsmon upsmon || die
|
| 142 |
newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail || die
|
| 143 |
|
| 144 |
keepdir /var/lib/nut
|
| 145 |
|
| 146 |
einfo "Setting up permissions on files and directories"
|
| 147 |
fperms 0700 /var/lib/nut
|
| 148 |
fowners nut:nut /var/lib/nut
|
| 149 |
|
| 150 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 151 |
eval fperms 0640 ${NUT_PRIVATE_FILES}
|
| 152 |
eval fowners root:nut ${NUT_PRIVATE_FILES}
|
| 153 |
|
| 154 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 155 |
eval fperms 0644 ${NUT_PUBLIC_FILES}
|
| 156 |
eval fowners root:root ${NUT_PUBLIC_FILES}
|
| 157 |
|
| 158 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 159 |
if use cgi; then
|
| 160 |
eval fperms 0644 ${NUT_CGI_FILES}
|
| 161 |
eval fowners root:root ${NUT_CGI_FILES}
|
| 162 |
fi
|
| 163 |
|
| 164 |
# this is installed for 2.4 and fbsd guys
|
| 165 |
if ! has_version sys-fs/udev; then
|
| 166 |
einfo "Installing non-udev hotplug support"
|
| 167 |
insinto /etc/hotplug/usb
|
| 168 |
insopts -m 755
|
| 169 |
doins scripts/hotplug/nut-usbups.hotplug
|
| 170 |
fi
|
| 171 |
|
| 172 |
dobashcompletion "${S}"/scripts/misc/nut.bash_completion
|
| 173 |
}
|
| 174 |
|
| 175 |
pkg_postinst() {
|
| 176 |
# this is to ensure that everybody that installed old versions still has
|
| 177 |
# correct permissions
|
| 178 |
|
| 179 |
chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null
|
| 180 |
chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null
|
| 181 |
|
| 182 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 183 |
eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
|
| 184 |
eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
|
| 185 |
|
| 186 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 187 |
eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
|
| 188 |
eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
|
| 189 |
|
| 190 |
# Do not remove eval here, because the variables contain shell expansions.
|
| 191 |
if use cgi; then
|
| 192 |
eval chown root:root "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
|
| 193 |
eval chmod 0644 "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
|
| 194 |
fi
|
| 195 |
|
| 196 |
warningmsg elog
|
| 197 |
}
|
| 198 |
|
| 199 |
warningmsg() {
|
| 200 |
msgfunc="$1"
|
| 201 |
[ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!"
|
| 202 |
${msgfunc} "Please note that NUT now runs under the 'nut' user."
|
| 203 |
${msgfunc} "NUT is in the uucp group for access to RS-232 UPS."
|
| 204 |
${msgfunc} "However if you use a USB UPS you may need to look at the udev or"
|
| 205 |
${msgfunc} "hotplug rules that are installed, and alter them suitably."
|
| 206 |
${msgfunc} ''
|
| 207 |
${msgfunc} "You are strongly advised to read the UPGRADING file provided by upstream."
|
| 208 |
${msgfunc} ''
|
| 209 |
${msgfunc} "Please note that upsdrv is NOT automatically started by upsd anymore."
|
| 210 |
${msgfunc} "If you have multiple UPS units, you can use their NUT names to"
|
| 211 |
${msgfunc} "have a service per UPS:"
|
| 212 |
${msgfunc} "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
|
| 213 |
${msgfunc} ''
|
| 214 |
${msgfunc} 'If you want apcupsd to power off your UPS when it'
|
| 215 |
${msgfunc} 'shuts down your system in a power failure, you must'
|
| 216 |
${msgfunc} 'add nut.powerfail to your shutdown runlevel:'
|
| 217 |
${msgfunc} ''
|
| 218 |
${msgfunc} 'rc-update add nut.powerfail shutdown'
|
| 219 |
${msgfunc} ''
|
| 220 |
|
| 221 |
}
|