blob: d853f7bec927d6d7f423ce05631f7bad4f760b30 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "Rotates, compresses, removes and mails system log files"
2SECTION = "console/utils"
Andrew Geissler95ac1b82021-03-31 14:34:31 -05003HOMEPAGE = "https://github.com/logrotate/logrotate/"
4DESCRIPTION = "The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files."
Brad Bishop19323692019-04-05 15:28:33 -04005LICENSE = "GPLv2"
6
7# TODO: Document coreutils dependency. Why not RDEPENDS? Why not busybox?
8
9DEPENDS="coreutils popt"
10
11LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
12
Brad Bishop19323692019-04-05 15:28:33 -040013UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/releases"
14UPSTREAM_CHECK_REGEX = "logrotate-(?P<pver>\d+(\.\d+)+).tar"
15
16SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/${PV}/${BP}.tar.xz \
17 file://act-as-mv-when-rotate.patch \
Andrew Geissler4b740dc2020-05-05 08:54:39 -050018 file://0001-Update-the-manual.patch \
Brad Bishop19323692019-04-05 15:28:33 -040019 file://disable-check-different-filesystems.patch \
20 "
21
William A. Kennington IIIac69b482021-06-02 12:28:27 -070022SRC_URI[sha256sum] = "14a924e4804b3974e85019a9f9352c2a69726702e6656155c48bcdeace68a5dc"
23
24# These CVEs are debian, gentoo or SUSE specific on the way logrotate was installed/used
25CVE_CHECK_WHITELIST += "CVE-2011-1548 CVE-2011-1549 CVE-2011-1550"
Brad Bishop19323692019-04-05 15:28:33 -040026
27PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
28
29PACKAGECONFIG[acl] = ",,acl"
30PACKAGECONFIG[selinux] = ",,libselinux"
31
32CONFFILES_${PN} += "${localstatedir}/lib/logrotate.status \
33 ${sysconfdir}/logrotate.conf \
34 ${sysconfdir}/logrotate.d/btmp \
35 ${sysconfdir}/logrotate.d/wtmp"
36
37# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
38# optimization variables, so use it rather than EXTRA_CFLAGS.
39EXTRA_OEMAKE = "\
40 LFS= \
41 OS_NAME='${OS_NAME}' \
42 'CC=${CC}' \
43 'RPM_OPT_FLAGS=${CFLAGS}' \
44 'EXTRA_LDFLAGS=${LDFLAGS}' \
45 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
46 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
47"
48
49# OS_NAME in the makefile defaults to `uname -s`. The behavior for
50# freebsd/netbsd is questionable, so leave it as Linux, which only sets
51# INSTALL=install and BASEDIR=/usr.
52OS_NAME = "Linux"
53
54inherit autotools systemd
55
56SYSTEMD_SERVICE_${PN} = "\
57 ${BPN}.service \
58 ${BPN}.timer \
59"
60
61LOGROTATE_OPTIONS ?= ""
62
63LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
64LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
65LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
66
67do_install(){
68 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
69 mkdir -p ${D}${sysconfdir}/logrotate.d
70 mkdir -p ${D}${localstatedir}/lib
71 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
72 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
73 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
74 touch ${D}${localstatedir}/lib/logrotate.status
75
76 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
77 install -d ${D}${systemd_system_unitdir}
78 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
79 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
80 [ -z "${LOGROTATE_OPTIONS}" ] ||
81 sed -ri \
82 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
83 ${D}${systemd_system_unitdir}/logrotate.service
84 sed -ri \
85 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
86 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
87 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
88 ${D}${systemd_system_unitdir}/logrotate.timer
89 fi
90
91 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
92 mkdir -p ${D}${sysconfdir}/cron.daily
93 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
94 fi
95}