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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Sat Feb 12 23:16:14 2011 UTC (9 years ago) by ssuominen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +1 -1 lines
FILE REMOVED
old

(Portage version: 2.2.0_alpha23/cvs/Linux x86_64)

1 # Copyright 1999-2009 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.0.5-r2.ebuild,v 1.12 2009/05/16 08:45:32 robbat2 Exp $
4
5 inherit eutils fixheadtails autotools
6
7 MY_P="${P/_/-}"
8
9 DESCRIPTION="Network-UPS Tools"
10 HOMEPAGE="http://www.networkupstools.org/"
11 # Nut mirrors are presently broken
12 #SRC_URI="mirror://nut/source/${PV%.*}/${MY_P}.tar.gz"
13 SRC_URI="http://www.networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
14
15 S="${WORKDIR}/${MY_P}"
16
17 LICENSE="GPL-2"
18 SLOT="0"
19 KEYWORDS="~alpha amd64 ppc ppc64 sparc x86 ~x86-fbsd"
20 IUSE="cgi snmp usb ssl"
21
22 RDEPEND="cgi? ( >=media-libs/gd-2 )
23 snmp? ( net-analyzer/net-snmp )
24 usb? ( =virtual/libusb-0* )
25 ssl? ( dev-libs/openssl )
26 !<sys-fs/udev-104"
27 DEPEND="$RDEPEND
28 >=sys-apps/sed-4
29 >=sys-devel/autoconf-2.58"
30
31 # public files should be 644 root:root
32 NUT_PUBLIC_FILES="/etc/nut/{{hosts,upsset,ups,upssched}.conf,upsstats{,-single}.html}"
33 # private files should be 640 root:nut - readable by nut, writeable by root,
34 NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
35
36 pkg_setup() {
37 enewgroup nut 84
38 enewuser nut 84 -1 /var/state/nut nut,uucp
39 # As of udev-104, NUT must be in uucp and NOT in tty.
40 gpasswd -d nut tty
41 gpasswd -a nut uucp
42 # in some cases on old systems it wasn't in the nut group either!
43 gpasswd -a nut nut
44 warningmsg ewarn
45 }
46
47 src_unpack() {
48 unpack ${A}
49
50 EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/upsstats-upsset-link-2.0.5.patch
51 EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/nut-2.0.5-bcmxcp-3phase.patch
52
53 cd "${S}"
54
55 sed -e "s/install: install-dirs/install: install-dirs install-conf/" \
56 -i Makefile.in || die "sed failed"
57
58 ht_fix_file configure.in
59
60 sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
61 -i configure.in || die "sed failed"
62
63 ebegin "Recreating configure"
64 WANT_AUTOCONF=2.5 eautoconf || die "autoconf failed"
65 eend $?
66 }
67
68 src_compile() {
69 local myconf
70
71 if [ -n "${NUT_DRIVERS}" ]; then
72 myconf="${myconf} --with-drivers=${NUT_DRIVERS// /,}"
73 fi
74
75 econf \
76 --with-user=nut \
77 --with-group=nut \
78 --with-drvpath=/lib/nut \
79 --sysconfdir=/etc/nut \
80 --with-logfacility=LOG_DAEMON \
81 --with-statepath=/var/lib/nut \
82 $(use_with ssl) \
83 $(use_with cgi) \
84 $(use_with cgi cgipath /usr/share/nut) \
85 ${myconf} || die "econf failed"
86
87 emake || die "compile problem"
88
89 if use snmp; then
90 emake snmp || die "snmp compile problem"
91 fi
92
93 if use usb; then
94 emake usb || die "usb compile problem"
95 fi
96
97 if use cgi; then
98 emake cgi || die "cgi compile problem"
99 fi
100 }
101
102 src_install() {
103 make DESTDIR="${D}" install install-lib || die "make install failed"
104
105 dodir /sbin
106 dosym /lib/nut/upsdrvctl /sbin/upsdrvctl
107 # This needs to exist for the scripts
108 dosym /lib/nut/upsdrvctl /usr/sbin/upsdrvctl
109
110 if use snmp; then
111 make DESTDIR="${D}" install-snmp || die "make install-snmp failed"
112 fi
113
114 if use usb; then
115 make DESTDIR="${D}" install-usb || die "make install-usb failed"
116 fi
117
118 if use cgi; then
119 make DESTDIR="${D}" install-cgi || die "make install-cgi failed"
120 make DESTDIR="${D}" install-cgi-conf || die "make install-cgi-conf failed"
121 einfo "CGI monitoring scripts are installed in /usr/share/nut."
122 einfo "copy them to your web server's ScriptPath to activate."
123 einfo "If you use lighttpd, see lighttpd_nut.conf in the documentation."
124 fi
125
126 # this must be done after all of the install phases
127 for i in "${D}"/etc/nut/*.sample ; do
128 mv "${i}" "${i/.sample/}"
129 done
130
131 dodoc ChangeLog CREDITS INSTALL MAINTAINERS NEWS README UPGRADING \
132 docs/{FAQ,*.txt}
133
134 newdoc lib/README README.lib
135
136 dodoc "${FILESDIR}"/lighttpd_nut.conf
137
138 docinto cables
139 dodoc docs/cables/*
140
141 newinitd "${FILESDIR}"/upsd.rc6 upsd
142 newinitd "${FILESDIR}"/upsdrv.rc6-r1 upsdrv
143 newinitd "${FILESDIR}"/upsmon.rc6 upsmon
144
145 # This sets up permissions for nut to access a UPS
146 insinto /etc/udev/rules.d/
147 newins scripts/hotplug-ng/nut-usbups.rules 70-nut-usbups.rules
148
149 keepdir /var/lib/nut
150
151 fperms 0700 /var/lib/nut
152 fowners nut:nut /var/lib/nut
153
154 eval fperms 0640 ${NUT_PRIVATE_FILES}
155 eval fowners root:nut ${NUT_PRIVATE_FILES}
156
157 eval fperms 0644 ${NUT_PUBLIC_FILES}
158 eval fowners root:root ${NUT_PUBLIC_FILES}
159
160 # this is installed for 2.4 and fbsd guys
161 if ! has_version sys-fs/udev; then
162 insinto /etc/hotplug/usb
163 insopts -m 755
164 doins scripts/hotplug-ng/nut-usbups.hotplug
165 fi
166 }
167
168 pkg_postinst() {
169 # this is to ensure that everybody that installed old versions still has
170 # correct permissions
171 chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null
172 chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null
173
174 eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
175 eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
176
177 eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
178 eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
179
180 warningmsg elog
181 }
182
183 warningmsg() {
184 msgfunc="$1"
185 [ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!"
186 ${msgfunc} "Please note that NUT now runs under the 'nut' user."
187 ${msgfunc} "NUT is in the uucp group for access to RS-232 UPS."
188 ${msgfunc} "However if you use a USB UPS you may need to look at the udev or"
189 ${msgfunc} "hotplug rules that are installed, and alter them suitably."
190 }

  ViewVC Help
Powered by ViewVC 1.1.20