media-plugins/gst-plugins-opus-1.14.4-r1: ia64 stable, bug 674854
[gentoo.git] / sys-power / apcupsd / apcupsd-3.14.13.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit eutils linux-info flag-o-matic systemd udev
7
8 DESCRIPTION="APC UPS daemon with integrated tcp/ip remote shutdown"
9 HOMEPAGE="http://www.apcupsd.org/"
10 SRC_URI="mirror://sourceforge/apcupsd/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="amd64 ~arm ppc x86 ~x86-fbsd"
15 IUSE="snmp +usb cgi nls gnome kernel_linux"
16
17 DEPEND="
18         ||      ( >=sys-apps/util-linux-2.23[tty-helpers(-)]
19                   sys-freebsd/freebsd-ubin
20                 )
21         cgi? ( >=media-libs/gd-1.8.4 )
22         nls? ( sys-devel/gettext )
23         snmp? ( >=net-analyzer/net-snmp-5.7.2 )
24         gnome? ( >=x11-libs/gtk+-2.4.0:2
25                 dev-libs/glib:2
26                 >=gnome-base/gconf-2.0 )"
27 RDEPEND="${DEPEND}
28         sys-apps/openrc
29         virtual/mailx"
30
31 CONFIG_CHECK="~USB_HIDDEV ~HIDRAW"
32 ERROR_USB_HIDDEV="CONFIG_USB_HIDDEV:    needed to access USB-attached UPSes"
33 ERROR_HIDRAW="CONFIG_HIDRAW:            needed to access USB-attached UPSes"
34
35 pkg_setup() {
36         if use kernel_linux && use usb && linux_config_exists; then
37                 check_extra_config
38         fi
39 }
40
41 src_prepare() {
42         epatch "${FILESDIR}/${PN}-3.14.9-aliasing.patch"
43 }
44
45 src_configure() {
46         local myconf
47         use cgi && myconf="${myconf} --enable-cgi --with-cgi-bin=/usr/libexec/${PN}/cgi-bin"
48         if use usb; then
49                 myconf="${myconf} --with-upstype=usb --with-upscable=usb --enable-usb --with-dev= "
50         else
51                 myconf="${myconf} --with-upstype=apcsmart --with-upscable=smart --disable-usb"
52         fi
53
54         # We force the DISTNAME to gentoo so it will use gentoo's layout also
55         # when installed on non-linux systems.
56         econf \
57                 --sbindir=/sbin \
58                 --sysconfdir=/etc/apcupsd \
59                 --with-pwrfail-dir=/etc/apcupsd \
60                 --with-lock-dir=/run/apcupsd \
61                 --with-pid-dir=/run/apcupsd \
62                 --with-log-dir=/var/log \
63                 --with-nis-port=3551 \
64                 --enable-net --enable-pcnet \
65                 --with-distname=gentoo \
66                 $(use_enable snmp net-snmp) \
67                 $(use_enable gnome gapcmon) \
68                 ${myconf} \
69                 APCUPSD_MAIL=/bin/mail
70 }
71
72 src_compile() {
73         # Workaround for bug #280674; upstream should really just provide
74         # the text files in the distribution, but I wouldn't count on them
75         # doing that anytime soon.
76         MANPAGER=$(type -p cat) \
77                 emake || die "emake failed"
78 }
79
80 src_install() {
81         emake DESTDIR="${D}" install
82         rm -f "${D}"/etc/init.d/halt
83
84         insinto /etc/apcupsd
85         newins examples/safe.apccontrol safe.apccontrol
86         doins "${FILESDIR}"/apcupsd.conf
87
88         dodoc ChangeLog* ReleaseNotes
89         doman doc/*.8 doc/*.5
90
91         dohtml -r doc/manual/*
92
93         rm "${D}"/etc/init.d/apcupsd
94         newinitd "${FILESDIR}/${PN}.init.4" "${PN}"
95         newinitd "${FILESDIR}/${PN}.powerfail.init" "${PN}".powerfail
96
97         systemd_dounit "${FILESDIR}"/${PN}.service
98         systemd_dotmpfilesd "${FILESDIR}"/${PN}-tmpfiles.conf
99
100         # remove hal settings, we don't really want to have it around still.
101         rm -r "${D}"/usr/share/hal
102
103         # replace it with our udev rules if we're in Linux
104         if use kernel_linux; then
105                 udev_newrules "${FILESDIR}"/apcupsd-udev.rules 60-${PN}.rules
106         fi
107
108 }
109
110 pkg_postinst() {
111         if use cgi; then
112                 elog "The cgi-bin directory for ${PN} is /usr/libexec/${PN}/cgi-bin."
113                 elog "Set up your ScriptAlias or symbolic links accordingly."
114         fi
115
116         elog ""
117         elog "Since version 3.14.0 you can use multiple apcupsd instances to"
118         elog "control more than one UPS in a single box with openRC."
119         elog "To do this, create a link between /etc/init.d/apcupsd to a new"
120         elog "/etc/init.d/apcupsd.something, and it will then load the"
121         elog "configuration file at /etc/apcupsd/something.conf."
122         elog ""
123
124         elog 'If you want apcupsd to power off your UPS when it'
125         elog 'shuts down your system in a power failure, you must'
126         elog 'add apcupsd.powerfail to your shutdown runlevel:'
127         elog ''
128         elog ' \e[01m rc-update add apcupsd.powerfail shutdown \e[0m'
129         elog ''
130
131         if use kernel_linux; then
132                 elog "Starting from version 3.14.9-r1, ${PN} installs udev rules"
133                 elog "for persistent device naming. If you have multiple UPS"
134                 elog "connected to the machine, you can point them to the devices"
135                 elog "in /dev/apcups/by-id directory."
136         fi
137 }