1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools flag-o-matic systemd
7 if [[ ${PV} == "9999" ]] ; then
8 ESVN_REPO_URI="https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools"
9 ESVN_PROJECT="smartmontools"
12 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
13 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
16 DESCRIPTION="Tools to monitor storage systems to provide advanced warning of disk degradation"
17 HOMEPAGE="https://www.smartmontools.org"
21 IUSE="caps +daemon selinux static systemd update_drivedb"
25 static? ( sys-libs/libcap-ng[static-libs] )
26 !static? ( sys-libs/libcap-ng )
32 daemon? ( virtual/mailx )
33 selinux? ( sec-policy/selinux-smartmon )
34 systemd? ( sys-apps/systemd )
46 REQUIRED_USE="( caps? ( daemon ) )"
54 use static && append-ldflags -static
55 # The build installs /etc/init.d/smartd, but we clobber it
56 # in our src_install, so no need to manually delete it.
58 --with-drivedbdir="${EPREFIX}/var/db/${PN}" #575292
59 --with-initscriptdir="${EPREFIX}/etc/init.d"
60 #--with-smartdscriptdir="${EPREFIX}/usr/share/${PN}"
61 $(use_with caps libcap-ng)
63 $(use_with systemd libsystemd)
64 $(use_with update_drivedb gnupg)
65 $(use_with update_drivedb update-smart-drivedb)
66 $(usex systemd "--with-systemdsystemunitdir=$(systemd_get_systemunitdir)" '')
68 econf "${myeconfargs[@]}"
72 local db_path="/var/db/${PN}"
77 newinitd "${FILESDIR}"/smartd-r1.rc smartd
78 newconfd "${FILESDIR}"/smartd.confd smartd
83 local DOCS=( AUTHORS ChangeL* COPYING INSTALL NEWS README TODO )
87 if use update_drivedb ; then
89 dosbin "${S}"/update-smart-drivedb
92 exeinto /etc/cron.monthly
93 doexe "${FILESDIR}/${PN}-update-drivedb"
96 if use daemon || use update_drivedb; then
99 # Install a copy of the initial drivedb.h to /usr/share/${PN}
100 # so that we can access that file later in pkg_postinst
101 # even when dealing with binary packages (bug #575292)
102 insinto /usr/share/${PN}
103 doins "${S}"/drivedb.h
106 # Make sure we never install drivedb.h into the db location
107 # of the acutal image so we don't record hashes because user
108 # can modify that file
109 rm -f "${ED%/}${db_path}/drivedb.h" || die
112 find "${ED%/}"/usr/share/doc -type f -exec chmod a-x '{}' \; || die
116 if use daemon || use update_drivedb; then
117 local initial_db_file="${EPREFIX}/usr/share/${PN}/drivedb.h"
118 local db_path="${EPREFIX}/var/db/${PN}"
120 if [[ ! -f "${db_path}/drivedb.h" ]] ; then
121 # No initial database found
122 cp "${initial_db_file}" "${db_path}" || die
123 einfo "Default drive database which was shipped with this release of ${PN}"
124 einfo "has been installed to '${db_path}'."
126 ewarn "WARNING: There's already a drive database in '${db_path}'!"
127 ewarn "Because we cannot determine if this database is untouched"
128 ewarn "or was modified by the user you have to manually update the"
129 ewarn "drive database:"
131 ewarn "a) Replace '${db_path}/drivedb.h' by the database shipped with this"
132 ewarn " release which can be found in '${initial_db_file}', i.e."
134 ewarn " cp \"${initial_db_file}\" \"${db_path}\""
136 ewarn "b) Run the following command as root:"
138 ewarn " /usr/sbin/update-smart-drivedb"
140 if ! use update_drivedb ; then
142 ewarn "However, 'update-smart-drivedb' requires that you re-emerge ${PN}"
143 ewarn "with USE='update_drivedb'."