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