laptop-mode-tools-1.71.ebuild 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit multilib systemd udev
  5. MY_P="${PN}_${PV}"
  6. DESCRIPTION="Linux kernel laptop_mode user-space utilities"
  7. HOMEPAGE="https://github.com/rickysarraf/laptop-mode-tools/wiki"
  8. SRC_URI="https://github.com/rickysarraf/${PN}/releases/download/${PV}/${MY_P}.tar.gz"
  9. LICENSE="GPL-2"
  10. SLOT="0"
  11. KEYWORDS="~amd64 ~ppc ~x86"
  12. IUSE="+acpi apm bluetooth scsi"
  13. RDEPEND="net-wireless/wireless-tools
  14. sys-apps/iproute2
  15. sys-apps/ethtool
  16. sys-apps/hdparm
  17. sys-apps/which
  18. acpi? ( sys-power/acpid )
  19. apm? ( sys-apps/apmd )
  20. bluetooth? ( net-wireless/bluez:= )
  21. scsi? ( sys-apps/sdparm )"
  22. DEPEND=""
  23. S="${WORKDIR}/${MY_P}"
  24. src_prepare() {
  25. default
  26. # This should avoid conflict with pm-powersave wrt #327443 and #396703
  27. cat <<-EOF > "${T}"/${PN}
  28. HOOK_BLACKLIST="00powersave"
  29. EOF
  30. }
  31. src_compile() { :; }
  32. src_install() {
  33. DESTDIR="${D}" \
  34. INIT_D="none" \
  35. MAN_D="/usr/share/man" \
  36. LIB_D="/usr/$(get_libdir)" \
  37. UDEV_D="$(get_udevdir)" \
  38. SYSTEMD_UNIT_D="$(systemd_get_systemunitdir)" \
  39. TMPFILES_D="/usr/lib/tmpfiles.d" \
  40. ACPI="$(use acpi && echo force || echo disabled)" \
  41. PMU="$(false && echo force || echo disabled)" \
  42. APM="$(use apm && echo force || echo disabled)" \
  43. SYSTEMD=yes \
  44. sh ./install.sh || die
  45. dodoc Documentation/*.txt README.md
  46. newinitd "${FILESDIR}"/laptop_mode.init-1.4 laptop_mode
  47. # See src_prepare()
  48. insinto /etc/pm/config.d
  49. doins "${T}"/${PN}
  50. }
  51. pkg_postinst() {
  52. if use acpi || use apm; then
  53. if use acpi; then
  54. daemon_name="acpid"
  55. elif use apm; then
  56. deamon_name="apmd"
  57. fi
  58. if [ "$(rc-config list default | grep laptop_mode)" = "" ] || [ "$(rc-config list default | grep ${daemon_name} )" = "" ]; then
  59. ewarn "To enable automatic power state event handling,"
  60. ewarn "e.g. enabling laptop_mode after unplugging the battery,"
  61. ewarn "both laptop_mode and the ${daemon_name} daemon must be"
  62. ewarn "added to default runlevel:"
  63. if [ "$(rc-config list default | grep laptop_mode)" = "" ]; then
  64. ewarn "# rc-update add laptop_mode default"
  65. fi
  66. if [ "$(rc-config list default | grep ${daemon_name} )" = "" ]; then
  67. ewarn "# rc-update add ${daemon_name} default"
  68. fi
  69. fi
  70. else
  71. ewarn "Without USE=\"acpi\" or USE=\"apm\" ${PN} can not"
  72. ewarn "automatically disable laptop_mode on low battery."
  73. ewarn
  74. ewarn "This means you can lose up to 10 minutes of work if running"
  75. ewarn "out of battery while laptop_mode is enabled."
  76. ewarn
  77. ewarn "Please see laptop-mode.txt in /usr/share/doc/${PF} for further"
  78. ewarn "information."
  79. ewarn
  80. fi
  81. }