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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Sun Jun 29 08:28:45 2014 UTC (5 years, 8 months ago) by swift
Branch: MAIN
Changes since 1.8: +4 -3 lines
Add dependency towards sec-policy/selinux-nut if USE=selinux is set

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

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

  ViewVC Help
Powered by ViewVC 1.1.20