blob: 0f3da2b94bdb5c5e70721a0cd9dc7e4666f28ef0 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "Rotates, compresses, removes and mails system log files"
2SECTION = "console/utils"
3HOMEPAGE = "https://github.com/logrotate/logrotate/issues"
4LICENSE = "GPLv2"
5
6# TODO: Document coreutils dependency. Why not RDEPENDS? Why not busybox?
7
8DEPENDS="coreutils popt"
9
10LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
11
12# When updating logrotate to latest upstream, SRC_URI should point to
13# a proper release tarball from https://github.com/logrotate/logrotate/releases
14# and we have to take the snapshot for now because there is no such
15# tarball available for 3.9.1.
16
17S = "${WORKDIR}/${BPN}-${PV}"
18
19UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/releases"
20UPSTREAM_CHECK_REGEX = "logrotate-(?P<pver>\d+(\.\d+)+).tar"
21
22SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/${PV}/${BP}.tar.xz \
23 file://act-as-mv-when-rotate.patch \
24 file://update-the-manual.patch \
25 file://disable-check-different-filesystems.patch \
26 "
27
28SRC_URI[md5sum] = "320046f0b9fc38337e8827d4c5a866a0"
29SRC_URI[sha256sum] = "313612c4776a305393454c874ef590d8acf84c9ffa648717731dfe902284ff8f"
30
31PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
32
33PACKAGECONFIG[acl] = ",,acl"
34PACKAGECONFIG[selinux] = ",,libselinux"
35
36CONFFILES_${PN} += "${localstatedir}/lib/logrotate.status \
37 ${sysconfdir}/logrotate.conf \
38 ${sysconfdir}/logrotate.d/btmp \
39 ${sysconfdir}/logrotate.d/wtmp"
40
41# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
42# optimization variables, so use it rather than EXTRA_CFLAGS.
43EXTRA_OEMAKE = "\
44 LFS= \
45 OS_NAME='${OS_NAME}' \
46 'CC=${CC}' \
47 'RPM_OPT_FLAGS=${CFLAGS}' \
48 'EXTRA_LDFLAGS=${LDFLAGS}' \
49 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
50 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
51"
52
53# OS_NAME in the makefile defaults to `uname -s`. The behavior for
54# freebsd/netbsd is questionable, so leave it as Linux, which only sets
55# INSTALL=install and BASEDIR=/usr.
56OS_NAME = "Linux"
57
58inherit autotools systemd
59
60SYSTEMD_SERVICE_${PN} = "\
61 ${BPN}.service \
62 ${BPN}.timer \
63"
64
65LOGROTATE_OPTIONS ?= ""
66
67LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
68LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
69LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
70
71do_install(){
72 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
73 mkdir -p ${D}${sysconfdir}/logrotate.d
74 mkdir -p ${D}${localstatedir}/lib
75 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
76 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
77 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
78 touch ${D}${localstatedir}/lib/logrotate.status
79
80 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
81 install -d ${D}${systemd_system_unitdir}
82 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
83 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
84 [ -z "${LOGROTATE_OPTIONS}" ] ||
85 sed -ri \
86 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
87 ${D}${systemd_system_unitdir}/logrotate.service
88 sed -ri \
89 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
90 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
91 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
92 ${D}${systemd_system_unitdir}/logrotate.timer
93 fi
94
95 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
96 mkdir -p ${D}${sysconfdir}/cron.daily
97 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
98 fi
99}