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

Contents of /sys-power/nut/nut-2.7.2-r2.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Nov 2 10:18:14 2014 UTC (5 years, 3 months ago) by swift
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +6 -4 lines
Remove sec-policy/selinux-* dependency from DEPEND but keep in RDEPEND (bug #527698)

(Portage version: 2.2.8-r2/cvs/Linux x86_64, signed Manifest commit with key 0x2EDD52403B68AF47)

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

  ViewVC Help
Powered by ViewVC 1.1.20