apcupsd-3.14.13.ebuild 3.9 KB

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