lm_sensors-3.4.0_p20160725.ebuild 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. inherit linux-info systemd toolchain-funcs multilib-minimal
  5. DESCRIPTION="Hardware Monitoring user-space utilities"
  6. HOMEPAGE="http://www.lm-sensors.org/ https://github.com/groeck/lm-sensors"
  7. COMMIT="45ffa15cf02e63f70ff3b85c23e22dfbab7e8f9c"
  8. MY_PN="${PN/_/-}"
  9. #SRC_URI="http://dl.lm-sensors.org/lm-sensors/releases/${P}.tar.bz2"
  10. SRC_URI="https://github.com/groeck/${MY_PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
  11. LICENSE="GPL-2+ LGPL-2.1"
  12. # SUBSLOT based on SONAME of libsensors.so
  13. SLOT="0/4.4.0"
  14. KEYWORDS="alpha amd64 arm ~mips ppc ppc64 sparc x86 ~amd64-linux ~arm-linux ~x86-linux"
  15. IUSE="sensord static-libs"
  16. COMMON_DEPS="
  17. sensord? (
  18. net-analyzer/rrdtool
  19. virtual/logger
  20. )"
  21. RDEPEND="${COMMON_DEPS}
  22. dev-lang/perl
  23. !<sys-apps/openrc-0.21.7"
  24. DEPEND="${COMMON_DEPS}
  25. sys-devel/bison
  26. sys-devel/flex"
  27. CONFIG_CHECK="~HWMON ~I2C_CHARDEV ~I2C"
  28. WARNING_HWMON="${PN} requires CONFIG_HWMON to be enabled for use."
  29. WARNING_I2C_CHARDEV="sensors-detect requires CONFIG_I2C_CHARDEV to be enabled."
  30. WARNING_I2C="${PN} requires CONFIG_I2C to be enabled for most sensors."
  31. PATCHES=( "${FILESDIR}"/${PN}-3.4.0-sensors-detect-gentoo.patch )
  32. DOCS=( CHANGES CONTRIBUTORS INSTALL README )
  33. DOCS+=( doc/{donations,fancontrol.txt,fan-divisors,libsensors-API.txt,progs,temperature-sensors,vid} )
  34. S="${WORKDIR}/${MY_PN}-${COMMIT}"
  35. src_prepare() {
  36. default
  37. if [[ -n "${COMMIT}" ]]; then
  38. local _version="${PV%_*}+git_${COMMIT}"
  39. sed -i \
  40. -e "s:LM_VERSION.*:LM_VERSION \"${_version}\":" \
  41. version.h || \
  42. die "Failed to update version.h"
  43. sed -i \
  44. -e "s/^\$revision = '.*/\$revision = '${_version}';/" \
  45. -e "/^\$revision =~ s.*/d" \
  46. prog/detect/sensors-detect || \
  47. die "Failed to set revision in prog/detect/sensors-detect"
  48. sed -i \
  49. -e "s/^echo \"# pwmconfig revision.*/echo \"# pwmconfig revision ${_version}\"/" \
  50. -e "/^REVISION=.*/d" \
  51. -e "/^REVDATE=.*/d" \
  52. -e "s:^PIDFILE=\".*:PIDFILE=\"/run/fancontrol.pid\":" \
  53. prog/pwm/pwmconfig || \
  54. die "Failed to adjust prog/pwm/pwmconfig"
  55. else
  56. sed -i \
  57. -e "s:^PIDFILE=\".*:PIDFILE=\"/run/fancontrol.pid\":" \
  58. prog/pwm/pwmconfig || \
  59. die "Failed to adjust PIDFILE in prog/pwm/pwmconfig"
  60. fi
  61. # Respect LDFLAGS
  62. sed -i -e 's/\$(LIBDIR)$/\$(LIBDIR) \$(LDFLAGS)/g' Makefile || \
  63. die "Failed to sed in LDFLAGS"
  64. sed -i \
  65. -e "s:^PIDFILE=\".*:PIDFILE=\"/run/fancontrol.pid\":" \
  66. prog/pwm/fancontrol || \
  67. die "Failed to adjust PIDFILE of prog/pwm/fancontrol"
  68. # Don't use EnvironmentFile in systemd unit
  69. sed -i \
  70. -e '/^EnvironmentFile=/d' \
  71. -e '/^Exec.*modprobe.*/d' \
  72. prog/init/lm_sensors.service || \
  73. die "Failed to remove EnvironmentFile from systemd unit file"
  74. if ! use static-libs; then
  75. sed -i -e '/^BUILD_STATIC_LIB/d' Makefile || \
  76. die "Failed to disable static building"
  77. fi
  78. # Don't show outdated user instructions
  79. sed -i -e '/^ @echo "\*\*\* /d' Makefile || \
  80. die "Failed to remove outdated user instructions"
  81. multilib_copy_sources
  82. }
  83. multilib_src_configure() {
  84. default
  85. if multilib_is_native_abi && use sensord; then
  86. # sensord requires net-analyzer/rrdtool which doesn't have real multilib
  87. # support. To prevent errors like
  88. #
  89. # skipping incompatible /usr/lib/librrd.so when searching for -lrrd
  90. # cannot find -lrrd
  91. #
  92. # we only build sensord when we are building for profile's native ABI
  93. # (it doesn't affect libsensors.so).
  94. sed -i -e 's:^#\(PROG_EXTRA.*\):\1:' Makefile || \
  95. die "Failed to enable building of sensord"
  96. fi
  97. }
  98. multilib_src_compile() {
  99. emake \
  100. CC="$(tc-getCC)" \
  101. CXX="$(tc-getCXX)" \
  102. LD="$(tc-getLD)" \
  103. AR="$(tc-getAR)"
  104. }
  105. multilib_src_install() {
  106. emake \
  107. DESTDIR="${D%/}" \
  108. PREFIX="/usr" \
  109. MANDIR="/usr/share/man" \
  110. ETCDIR="/etc" \
  111. LIBDIR="/usr/$(get_libdir)" \
  112. install
  113. }
  114. multilib_src_install_all() {
  115. newinitd "${FILESDIR}"/${PN}.initd ${PN}
  116. newconfd "${FILESDIR}"/${PN}.confd ${PN}
  117. systemd_dounit prog/init/lm_sensors.service
  118. newinitd "${FILESDIR}"/fancontrol.initd fancontrol
  119. newconfd "${FILESDIR}"/fancontrol.confd fancontrol
  120. systemd_newunit "${FILESDIR}"/fancontrol.service-r1 fancontrol.service
  121. if use sensord; then
  122. newconfd "${FILESDIR}"/sensord.confd sensord
  123. newinitd "${FILESDIR}"/sensord.initd sensord
  124. systemd_newunit "${FILESDIR}"/sensord.service-r1 sensord.service
  125. fi
  126. einstalldocs
  127. docinto developers
  128. dodoc doc/developers/applications
  129. }
  130. pkg_postinst() {
  131. local _new_loader='3.4.0_p20160725'
  132. local _v
  133. for _v in ${REPLACING_VERSIONS}; do
  134. if ! version_is_at_least ${_new_loader} ${v}; then
  135. # This is an upgrade which require migration
  136. elog ""
  137. elog "Since version 3.4.0_p20160725 ${PN} no longer loads modules on its own"
  138. elog "instead it is using \"modules-load\" services provided by OpenRC or systemd."
  139. elog ""
  140. elog "To migrate your configuration you have 2 options:"
  141. elog ""
  142. elog " a) Re-create a new configuration using \"/usr/sbin/sensors-detect\""
  143. elog ""
  144. elog " b) Copy existing \"modules_<n>\", \"HWMON_MODULES\" or \"BUS_MODULES\""
  145. elog " variables from \"/etc/conf.d/lm_modules\" to"
  146. elog " \"/etc/modules-load.d/lm_sensors.conf\" and adjust format."
  147. elog ""
  148. elog " For details see https://wiki.gentoo.org/wiki/Systemd#Automatic_module_loading"
  149. elog ""
  150. elog " Important: Don't forget to migrate your module's argument"
  151. elog " (modules_<name>_args variable) if your are not already"
  152. elog " using \"/etc/modprobe.d\" (which is recommended)."
  153. # Show this elog only once
  154. break
  155. fi
  156. done
  157. if [[ -z "${REPLACING_VERSIONS}" ]]; then
  158. # New installation
  159. elog ""
  160. elog "Please run \`/usr/sbin/sensors-detect' in order to setup"
  161. elog "\"/etc/modules-load.d/lm_sensors.conf\"."
  162. elog ""
  163. elog "You might want to add ${PN} to your default runlevel to make"
  164. elog "sure the sensors get initialized on the next startup."
  165. elog ""
  166. elog "Be warned, the probing of hardware in your system performed by"
  167. elog "sensors-detect could freeze your system. Also make sure you read"
  168. elog "the documentation before running ${PN} on IBM ThinkPads."
  169. fi
  170. }