apcupsd-3.14.14.ebuild 3.8 KB

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