/[gentoo-x86]/sys-power/nut/nut-2.7.1.ebuild
Gentoo

Contents of /sys-power/nut/nut-2.7.1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Jan 5 20:37:52 2014 UTC (6 years, 1 month ago) by robbat2
Branch: MAIN
Bug #493814: version bump; Bug #480664: NUT_DRIVERS hidden variable converted to UPS_DRIVERS local use family; Bug #485568: Respect AR. Bug #486640: partial fix.

(Portage version: 2.2.7/cvs/Linux x86_64, unsigned Manifest commit)

1 # Copyright 1999-2014 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.5-r1.ebuild,v 1.5 2013/09/25 17:24:11 ago Exp $
4
5 EAPI=5
6 inherit autotools bash-completion-r1 eutils fixheadtails multilib user systemd flag-o-matic toolchain-funcs
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
20 IUSE="avahi cgi ipmi snmp +usb ssl tcpd xml"
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 ipmi? ( sys-libs/freeipmi )
29 virtual/udev"
30 DEPEND="$RDEPEND
31 >=sys-apps/sed-4
32 virtual/pkgconfig"
33
34 S=${WORKDIR}/${MY_P}
35
36 # Bug #480664 requested UPS_DRIVERS_IUSE for more flexibility in building this package
37 SERIAL_DRIVERLIST="al175 bcmxcp belkin belkinunv bestfcom bestfortress bestuferrups bestups dummy-ups etapro everups gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino safenet solis tripplite tripplitesu upscode2 victronups powerpanel blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser nutdrv_qx"
38 SNMP_DRIVERLIST="snmp-ups"
39 USB_LIBUSB_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb richcomm_usb riello_usb nutdrv_qx"
40 USB_DRIVERLIST=${USB_LIBUSB_DRIVERLIST}
41 #HAL_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb riello_usb nutdrv_qx"
42 NEONXML_DRIVERLIST="netxml-ups"
43 IPMI_DRIVERLIST="nut-ipmipsu"
44 # Now we build from it:
45 for name in ${SERIAL_DRIVERLIST} ; do
46 IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
47 done
48 for name in ${USB_DRIVERLIST} ; do
49 IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
50 REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( usb )"
51 done
52 #for name in ${USB_DRIVERLIST} ; do
53 # name="hald-addon-${name}"
54 # IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
55 # REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( hal )"
56 #done
57 for name in ${NEONXML_DRIVERLIST}; do
58 IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
59 REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( xml )"
60 done
61 for name in ${SNMP_DRIVERLIST} ; do
62 IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
63 REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( snmp )"
64 done
65 for name in ${IPMI_DRIVERLIST} ; do
66 IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
67 REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( ipmi )"
68 done
69 IUSE="${IUSE} ${IUSE_UPS_DRIVERS}"
70
71 # public files should be 644 root:root
72 NUT_PUBLIC_FILES="/etc/nut/{ups,upssched}.conf"
73 # private files should be 640 root:nut - readable by nut, writeable by root,
74 NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
75 # public files should be 644 root:root, only installed if USE=cgi
76 NUT_CGI_FILES="/etc/nut/{{hosts,upsset}.conf,upsstats{,-single}.html}"
77
78 pkg_setup() {
79 enewgroup nut 84
80 enewuser nut 84 -1 /var/lib/nut nut,uucp
81 # As of udev-104, NUT must be in uucp and NOT in tty.
82 gpasswd -d nut tty 2>/dev/null
83 gpasswd -a nut uucp 2>/dev/null
84 # in some cases on old systems it wasn't in the nut group either!
85 gpasswd -a nut nut 2>/dev/null
86 warningmsg ewarn
87 }
88
89 src_prepare() {
90 ht_fix_file configure.in
91
92 epatch "${FILESDIR}"/${PN}-2.4.1-no-libdummy.patch
93 epatch "${FILESDIR}"/${PN}-2.6.2-lowspeed-buffer-size.patch
94 #epatch "${FILESDIR}"/${PN}-2.6.3-CVE-2012-2944.patch
95 #epatch "${FILESDIR}"/${PN}-2.6.5-freeipmi_fru.patch
96 epatch "${FILESDIR}"/${PN}-2.7.1-fix-scanning.patch
97 epatch "${FILESDIR}"/${PN}-2.7.1-snmpusb-order.patch
98
99 sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
100 -e '/systemdsystemunitdir=.*echo.*sed.*libdir/s,^,#,g' \
101 -i configure.in || die
102
103 sed -e "s:52.nut-usbups.rules:70-nut-usbups.rules:" \
104 -i scripts/udev/Makefile.am || die
105
106 rm -f ltmain.sh m4/lt* m4/libtool.m4
107
108 sed -i \
109 -e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \
110 lib/libupsclient{.pc,-config}.in || die #361685
111
112 # This file appears twice in the install list, and if both install rules
113 # trigger simultaneously during parallel-make, it fails.
114 sed -i \
115 -e '/nodist_sysconf_DATA/s,upsmon.conf.sample,,g' \
116 conf/Makefile.am || die
117
118 eautoreconf
119 }
120
121 src_configure() {
122 local myconf
123 append-flags -fno-lto
124 tc-export CC
125 tc-export CXX
126 tc-export AR
127
128 local UPS_DRIVERS=""
129 for u in $USE ; do
130 u2=${u#ups_drivers_}
131 [[ "${u}" != "${u2}" ]] && UPS_DRIVERS="${UPS_DRIVERS} ${u2}"
132 done
133 UPS_DRIVERS="${UPS_DRIVERS# }" UPS_DRIVERS="${UPS_DRIVERS% }"
134 myconf="${myconf} --with-drivers=${UPS_DRIVERS// /,}"
135
136 use cgi && myconf="${myconf} --with-cgipath=/usr/share/nut/cgi"
137
138 # TODO: USE flag for sys-power/powerman
139 econf \
140 --sysconfdir=/etc/nut \
141 --datarootdir=/usr/share/nut \
142 --datadir=/usr/share/nut \
143 --disable-static \
144 --with-statepath=/var/lib/nut \
145 --with-drvpath=/$(get_libdir)/nut \
146 --with-htmlpath=/usr/share/nut/html \
147 --with-user=nut \
148 --with-group=nut \
149 --with-logfacility=LOG_DAEMON \
150 --with-dev \
151 --with-serial \
152 --without-hal \
153 --without-powerman \
154 $(use_with avahi) \
155 $(use_with cgi) \
156 $(use_with ipmi) \
157 $(use_with ipmi freeipmi) \
158 $(use_with snmp) \
159 $(use_with ssl) \
160 $(use_with tcpd wrap) \
161 $(use_with usb) \
162 $(use_with xml neon) \
163 $(systemd_with_unitdir) \
164 ${myconf}
165 }
166
167 src_install() {
168 emake DESTDIR="${D}" install || die
169
170 find "${D}" -name '*.la' -exec rm -f {} +
171
172 dodir /sbin
173 dosym /$(get_libdir)/nut/upsdrvctl /sbin/upsdrvctl
174 # This needs to exist for the scripts
175 dosym /$(get_libdir)/nut/upsdrvctl /usr/sbin/upsdrvctl
176
177 if use cgi; then
178 elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
179 elog "copy them to your web server's ScriptPath to activate (this is a"
180 elog "change from the old location)."
181 elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
182 fi
183
184 # this must be done after all of the install phases
185 for i in "${D}"/etc/nut/*.sample ; do
186 mv "${i}" "${i/.sample/}"
187 done
188
189 dodoc AUTHORS ChangeLog docs/*.txt MAINTAINERS NEWS README TODO UPGRADING || die
190
191 newdoc lib/README README.lib || die
192 newdoc "${FILESDIR}"/lighttpd_nut.conf-2.2.0 lighttpd_nut.conf || die
193
194 docinto cables
195 dodoc docs/cables/* || die
196
197 newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsd upsd || die
198 newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv || die
199 newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon || die
200 newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog || die
201 newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail || die
202
203 keepdir /var/lib/nut
204
205 einfo "Setting up permissions on files and directories"
206 fperms 0700 /var/lib/nut
207 fowners nut:nut /var/lib/nut
208
209 # Do not remove eval here, because the variables contain shell expansions.
210 eval fperms 0640 ${NUT_PRIVATE_FILES}
211 eval fowners root:nut ${NUT_PRIVATE_FILES}
212
213 # Do not remove eval here, because the variables contain shell expansions.
214 eval fperms 0644 ${NUT_PUBLIC_FILES}
215 eval fowners root:root ${NUT_PUBLIC_FILES}
216
217 # Do not remove eval here, because the variables contain shell expansions.
218 if use cgi; then
219 eval fperms 0644 ${NUT_CGI_FILES}
220 eval fowners root:root ${NUT_CGI_FILES}
221 fi
222
223 # this is installed for 2.4 and fbsd guys
224 if ! has_version virtual/udev; then
225 einfo "Installing non-udev hotplug support"
226 insinto /etc/hotplug/usb
227 insopts -m 755
228 doins scripts/hotplug/nut-usbups.hotplug
229 fi
230
231 dobashcomp "${S}"/scripts/misc/nut.bash_completion
232 }
233
234 pkg_postinst() {
235 # this is to ensure that everybody that installed old versions still has
236 # correct permissions
237
238 chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null
239 chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null
240
241 # Do not remove eval here, because the variables contain shell expansions.
242 eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
243 eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
244
245 # Do not remove eval here, because the variables contain shell expansions.
246 eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
247 eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
248
249 # Do not remove eval here, because the variables contain shell expansions.
250 if use cgi; then
251 eval chown root:root "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
252 eval chmod 0644 "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
253 fi
254
255 warningmsg elog
256 }
257
258 warningmsg() {
259 msgfunc="$1"
260 [ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!"
261 ${msgfunc} "Please note that NUT now runs under the 'nut' user."
262 ${msgfunc} "NUT is in the uucp group for access to RS-232 UPS."
263 ${msgfunc} "However if you use a USB UPS you may need to look at the udev or"
264 ${msgfunc} "hotplug rules that are installed, and alter them suitably."
265 ${msgfunc} ''
266 ${msgfunc} "You are strongly advised to read the UPGRADING file provided by upstream."
267 ${msgfunc} ''
268 ${msgfunc} "Please note that upsdrv is NOT automatically started by upsd anymore."
269 ${msgfunc} "If you have multiple UPS units, you can use their NUT names to"
270 ${msgfunc} "have a service per UPS:"
271 ${msgfunc} "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
272 ${msgfunc} ''
273 ${msgfunc} 'If you want apcupsd to power off your UPS when it'
274 ${msgfunc} 'shuts down your system in a power failure, you must'
275 ${msgfunc} 'add nut.powerfail to your shutdown runlevel:'
276 ${msgfunc} ''
277 ${msgfunc} 'rc-update add nut.powerfail shutdown'
278 ${msgfunc} ''
279
280 }

  ViewVC Help
Powered by ViewVC 1.1.20