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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Feb 25 11:09:39 2007 UTC (13 years, 1 month ago) by robbat2
Branch: MAIN
Changes since 1.1: +3 -1 lines
Fix bug #157069.
(Portage version: 2.1.2-r11)

1 robbat2 1.1 # Copyright 1999-2007 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 robbat2 1.2 # $Header: /var/cvsroot/gentoo-x86/sys-power/nut/nut-2.0.5.ebuild,v 1.1 2007/02/25 02:57:28 robbat2 Exp $
4 robbat2 1.1
5     inherit eutils fixheadtails
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? ( >=dev-libs/libusb-0.1.12 )
25     ssl? ( dev-libs/openssl )"
26     DEPEND="$RDEPEND
27     >=sys-apps/sed-4
28     >=sys-devel/autoconf-2.58"
29    
30     # public files should be 644 root:root
31     NUT_PUBLIC_FILES="/etc/nut/{{hosts,upsset,ups,upssched}.conf,upsstats{,-single}.html}"
32     # private files should be 640 root:nut - readable by nut, writeable by root,
33     NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
34    
35     pkg_setup() {
36     enewgroup nut 84
37     enewuser nut 84 -1 /var/state/nut nut,tty
38     # try to add nut to the tty group for old cases where it already existed
39     gpasswd -a nut tty
40 robbat2 1.2 # in some cases it wasn't in the nut group either!
41     gpasswd -a nut nut
42 robbat2 1.1 warningmsg
43     }
44    
45     src_unpack() {
46     unpack ${A}
47    
48     EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/upsstats-upsset-link-2.0.5.patch
49    
50     cd "${S}"
51    
52     sed -e "s/install: install-dirs/install: install-dirs install-conf/" \
53     -i Makefile.in || die "sed failed"
54    
55     ht_fix_file configure.in
56    
57     sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
58     -i configure.in || die "sed failed"
59    
60     ebegin "Recreating configure"
61     WANT_AUTOCONF=2.5 autoconf || die "autoconf failed"
62     eend $?
63     }
64    
65     src_compile() {
66     local myconf
67    
68     if [ -n "${NUT_DRIVERS}" ]; then
69     myconf="${myconf} --with-drivers=${NUT_DRIVERS// /,}"
70     fi
71    
72     econf \
73     --with-user=nut \
74     --with-group=nut \
75     --with-drvpath=/lib/nut \
76     --sysconfdir=/etc/nut \
77     --with-logfacility=LOG_DAEMON \
78     --with-statepath=/var/lib/nut \
79     $(use_with ssl) \
80     $(use_with cgi) \
81     $(use_with cgi cgipath /usr/share/nut) \
82     ${myconf} || die "econf failed"
83    
84     emake || die "compile problem"
85    
86     if use snmp; then
87     emake snmp || die "snmp compile problem"
88     fi
89    
90     if use usb; then
91     emake usb || die "usb compile problem"
92     fi
93    
94     if use cgi; then
95     emake cgi || die "cgi compile problem"
96     fi
97     }
98    
99     src_install() {
100     make DESTDIR="${D}" install install-lib || die "make install failed"
101    
102     dodir /sbin
103     dosym /lib/nut/upsdrvctl /sbin/upsdrvctl
104     # This needs to exist for the scripts
105     dosym /lib/nut/upsdrvctl /usr/sbin/upsdrvctl
106    
107     if use snmp; then
108     make DESTDIR="${D}" install-snmp || die "make install-snmp failed"
109     fi
110    
111     if use usb; then
112     make DESTDIR="${D}" install-usb || die "make install-usb failed"
113     fi
114    
115     if use cgi; then
116     make DESTDIR="${D}" install-cgi || die "make install-cgi failed"
117     make DESTDIR="${D}" install-cgi-conf || die "make install-cgi-conf failed"
118     einfo "CGI monitoring scripts are installed in /usr/share/nut."
119     einfo "copy them to your web server's ScriptPath to activate."
120     einfo "If you use lighttpd, see lighttpd_nut.conf in the documentation."
121     fi
122    
123     # this must be done after all of the install phases
124     for i in "${D}"/etc/nut/*.sample ; do
125     mv "${i}" "${i/.sample/}"
126     done
127    
128    
129     dodoc ChangeLog CREDITS INSTALL MAINTAINERS NEWS README UPGRADING \
130     docs/{FAQ,*.txt}
131    
132     newdoc lib/README README.lib
133    
134     dodoc ${FILESDIR}/lighttpd_nut.conf
135    
136     docinto cables
137     dodoc docs/cables/*
138    
139    
140     exeinto /etc/init.d
141     newexe "${FILESDIR}/upsd.rc6" upsd
142     newexe "${FILESDIR}/upsdrv.rc6-r1" upsdrv
143     newexe "${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
181     }
182    
183     warningmsg() {
184     ewarn "Please note that NUT now runs under the 'nut' user."
185     ewarn "NUT is in the tty group for access to RS-232 UPS."
186     ewarn "However if you use a USB UPS you may need to look at the udev or"
187     ewarn "hotplug rules that are installed."
188     }

  ViewVC Help
Powered by ViewVC 1.1.20