hddtemp-0.3_beta15-r26.ebuild 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils autotools readme.gentoo-r1 systemd
  5. MY_P=${P/_beta/-beta}
  6. DBV=20080531
  7. DESCRIPTION="A simple utility to read the temperature of SMART capable hard drives"
  8. HOMEPAGE="https://savannah.nongnu.org/projects/hddtemp/"
  9. SRC_URI="http://download.savannah.gnu.org/releases/hddtemp/${MY_P}.tar.bz2 mirror://gentoo/hddtemp-${DBV}.db.bz2"
  10. LICENSE="GPL-2"
  11. SLOT="0"
  12. KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~sparc ~x86"
  13. IUSE="network-cron nls selinux"
  14. DEPEND=""
  15. RDEPEND="selinux? ( sec-policy/selinux-hddtemp )"
  16. S="${WORKDIR}/${MY_P}"
  17. DOCS=(README TODO ChangeLog)
  18. DISABLE_AUTOFORMATTING="yes"
  19. DOC_CONTENTS="In order to update your hddtemp database, run:
  20. emerge --config =${CATEGORY}/${PF} or update-hddtemp.db (if USE
  21. network-cron is enabled)
  22. If your hard drive is not recognized by hddtemp, please consider
  23. submitting your HDD info for inclusion into the Gentoo hddtemp
  24. database by filing a bug at https://bugs.gentoo.org/
  25. If hddtemp complains but finds your HDD temperature sensor, use the
  26. --quiet option to suppress the warning.
  27. "
  28. PATCHES=(
  29. "${FILESDIR}"/${P}-satacmds.patch
  30. "${FILESDIR}"/${P}-byteswap.patch
  31. "${FILESDIR}"/${P}-execinfo.patch
  32. "${FILESDIR}"/${P}-nls.patch
  33. "${FILESDIR}"/${P}-iconv.patch
  34. "${FILESDIR}"/${P}-dontwake.patch
  35. )
  36. src_prepare() {
  37. epatch "${PATCHES[@]}"
  38. mv "${S}"/configure.{in,ac} || die
  39. AT_M4DIR="m4" eautoreconf
  40. }
  41. src_configure() {
  42. local myconf
  43. myconf="--with-db-path=/usr/share/hddtemp/hddtemp.db"
  44. # disabling nls breaks compiling
  45. use nls || myconf="--disable-nls ${myconf}"
  46. econf ${myconf}
  47. }
  48. src_install() {
  49. default
  50. insinto /usr/share/hddtemp
  51. newins "${WORKDIR}/hddtemp-${DBV}.db" hddtemp.db
  52. doins "${FILESDIR}"/hddgentoo.db
  53. update_db "${D}/usr/share/hddtemp/hddgentoo.db" "${D}/usr/share/hddtemp/hddtemp.db"
  54. newconfd "${FILESDIR}"/hddtemp-conf.d hddtemp
  55. newinitd "${FILESDIR}"/hddtemp-init hddtemp
  56. systemd_newunit "${FILESDIR}"/hddtemp.service-r1 "${PN}.service"
  57. systemd_install_serviced "${FILESDIR}"/hddtemp.service.conf
  58. readme.gentoo_create_doc
  59. if use network-cron; then
  60. dosbin "${FILESDIR}"/update-hddtemp.db
  61. exeinto /etc/cron.monthly
  62. echo -e "#!/bin/sh\n/usr/sbin/update-hddtemp.db" > "${T}"/hddtemp.cron
  63. newexe "${T}"/hddtemp.cron update-hddtemp.db
  64. fi
  65. }
  66. pkg_postinst() {
  67. readme.gentoo_print_elog
  68. }
  69. update_db() {
  70. local src=$1
  71. local dst=$2
  72. while read line ; do
  73. if [[ -z $(echo "${line}" | sed -re 's/(^#.*|^\w*$)//') ]]; then
  74. echo "${line}" >> "${dst}"
  75. fi
  76. id=$(echo "${line}" | grep -o '"[^"]*"')
  77. grep "${id}" "${dst}" 2>&1 >/dev/null || echo "${line}" >> "${dst}"
  78. done < "${src}"
  79. }
  80. pkg_config() {
  81. cd "${ROOT}"/usr/share/hddtemp || die
  82. einfo "Trying to download the latest hddtemp.db file"
  83. wget http://www.guzu.net/linux/hddtemp.db -O hddtemp.db \
  84. || die "failed to download hddtemp.db"
  85. update_db "hddgentoo.db" "hddtemp.db"
  86. }