app-admin/logrotate: stable 3.14.0 for ia64, bug #652804
[gentoo.git] / app-admin / logrotate / logrotate-3.14.0.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit systemd
7
8 DESCRIPTION="Rotates, compresses, and mails system logs"
9 HOMEPAGE="https://github.com/logrotate/logrotate"
10 SRC_URI="https://github.com/${PN}/${PN}/releases/download/${PV}/${P}.tar.gz -> ${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="alpha amd64 ~arm ~arm64 ~hppa ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc x86 ~amd64-fbsd ~x86-fbsd"
15 IUSE="acl +cron selinux"
16
17 CDEPEND="
18         >=dev-libs/popt-1.5
19         selinux? ( sys-libs/libselinux )
20         acl? ( virtual/acl )"
21
22 DEPEND="${CDEPEND}
23         >=sys-apps/sed-4"
24
25 RDEPEND="${CDEPEND}
26         selinux? ( sec-policy/selinux-logrotate )
27         cron? ( virtual/cron )"
28
29 STATEFILE="/var/lib/misc/logrotate.status"
30 OLDSTATEFILE="/var/lib/logrotate.status"
31
32 move_old_state_file() {
33         elog "logrotate state file is now located at ${STATEFILE}"
34         elog "See bug #357275"
35         if [[ -e "${OLDSTATEFILE}" ]] ; then
36                 elog "Moving your current state file to new location: ${STATEFILE}"
37                 mv -n "${OLDSTATEFILE}" "${STATEFILE}"
38         fi
39 }
40
41 install_cron_file() {
42         exeinto /etc/cron.daily
43         newexe "${S}"/examples/logrotate.cron "${PN}"
44 }
45
46 PATCHES=(
47         "${FILESDIR}/${P}-ignore-hidden.patch"
48 )
49
50 src_prepare() {
51         sed -i -e 's#/usr/sbin/logrotate#/usr/bin/logrotate#' "${S}"/examples/logrotate.{cron,service} || die
52         eapply_user
53 }
54
55 src_configure() {
56         econf $(use_with acl) $(use_with selinux) --with-state-file-path="${STATEFILE}"
57 }
58
59 src_test() {
60         emake test
61 }
62
63 src_install() {
64         insinto /usr
65         dobin logrotate
66         doman logrotate.8
67         dodoc ChangeLog.md examples/logrotate-default
68
69         insinto /etc
70         doins "${FILESDIR}"/logrotate.conf
71
72         use cron && install_cron_file
73
74         systemd_dounit examples/logrotate.{service,timer}
75         systemd_newtmpfilesd "${FILESDIR}/${PN}.tmpfiles" "${PN}".conf
76
77         keepdir /etc/logrotate.d
78 }
79
80 pkg_postinst() {
81         elog
82         elog "The ${PN} binary is now installed under /usr/bin. Please"
83         elog "update your links"
84         elog
85         move_old_state_file
86         elog "If you are running systemd you might need to run:"
87         elog "systemd-tmpfiles --create /usr/lib/tmpfiles.d/logrotate.conf"
88         elog "in order to create the new location of the logrotate state file"
89         elog
90         if [[ -z ${REPLACING_VERSIONS} ]] ; then
91                 elog "If you wish to have logrotate e-mail you updates, please"
92                 elog "emerge virtual/mailx and configure logrotate in"
93                 elog "/etc/logrotate.conf appropriately"
94                 elog
95                 elog "Additionally, /etc/logrotate.conf may need to be modified"
96                 elog "for your particular needs. See man logrotate for details."
97         fi
98 }