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

  ViewVC Help
Powered by ViewVC 1.1.20