dev-qt/qtgui: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / sys-apps / smartmontools / smartmontools-7.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
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"
10         inherit subversion
11 else
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"
14 fi
15
16 DESCRIPTION="Tools to monitor storage systems to provide advanced warning of disk degradation"
17 HOMEPAGE="https://www.smartmontools.org"
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 IUSE="caps +daemon selinux static systemd update_drivedb"
22
23 DEPEND="
24         caps? (
25                 static? ( sys-libs/libcap-ng[static-libs] )
26                 !static? ( sys-libs/libcap-ng )
27         )
28         selinux? (
29                 sys-libs/libselinux
30         )"
31 RDEPEND="${DEPEND}
32         daemon? ( virtual/mailx )
33         selinux? ( sec-policy/selinux-smartmon )
34         systemd? ( sys-apps/systemd )
35         update_drivedb? (
36                 app-crypt/gnupg
37                 || (
38                         net-misc/curl
39                         net-misc/wget
40                         www-client/lynx
41                         dev-vcs/subversion
42                 )
43         )
44 "
45
46 REQUIRED_USE="( caps? ( daemon ) )"
47
48 src_prepare() {
49         default
50         eautoreconf
51 }
52
53 src_configure() {
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.
57         myeconfargs=(
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)
62                 $(use_with selinux)
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)" '')
67         )
68         econf "${myeconfargs[@]}"
69 }
70
71 src_install() {
72         local db_path="/var/db/${PN}"
73
74         if use daemon; then
75                 default
76
77                 newinitd "${FILESDIR}"/smartd-r1.rc smartd
78                 newconfd "${FILESDIR}"/smartd.confd smartd
79         else
80                 dosbin smartctl
81                 doman smartctl.8
82
83                 local DOCS=( AUTHORS ChangeL* COPYING INSTALL NEWS README TODO )
84                 einstalldocs
85         fi
86
87         if use update_drivedb ; then
88                 if ! use daemon; then
89                         dosbin "${S}"/update-smart-drivedb
90                 fi
91
92                 exeinto /etc/cron.monthly
93                 doexe "${FILESDIR}/${PN}-update-drivedb"
94         fi
95
96         if use daemon || use update_drivedb; then
97                 keepdir "${db_path}"
98
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
104         fi
105
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
110
111         # Bug #622072
112         find "${ED%/}"/usr/share/doc -type f -exec chmod a-x '{}' \; || die
113 }
114
115 pkg_postinst() {
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}"
119
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}'."
125                 else
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:"
130                         ewarn ""
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."
133                         ewarn ""
134                         ewarn "     cp \"${initial_db_file}\" \"${db_path}\""
135                         ewarn ""
136                         ewarn "b) Run the following command as root:"
137                         ewarn ""
138                         ewarn "     /usr/sbin/update-smart-drivedb"
139
140                         if ! use update_drivedb ; then
141                                 ewarn ""
142                                 ewarn "However, 'update-smart-drivedb' requires that you re-emerge ${PN}"
143                                 ewarn "with USE='update_drivedb'."
144                         fi
145                 fi
146         fi
147 }