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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Mon Sep 8 04:55:35 2014 UTC (5 years, 5 months ago) by prometheanfire
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
fixing systemd stuffs for bug 518622

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

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

  ViewVC Help
Powered by ViewVC 1.1.20