blob: 4e4ea106286ea7cee52286981f2f16cbfb8aa5b7 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001SUMMARY = "Rotates, compresses, removes and mails system log files"
2SECTION = "console/utils"
3HOMEPAGE = "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."
5LICENSE = "GPL-2.0-only"
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
13SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz"
14
15SRC_URI[sha256sum] = "8fa12015e3b8415c121fc9c0ca53aa872f7b0702f543afda7e32b6c4900f6516"
16
17# These CVEs are debian, gentoo or SUSE specific on the way logrotate was installed/used
18CVE_CHECK_IGNORE += "CVE-2011-1548 CVE-2011-1549 CVE-2011-1550"
19
20PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
21
22PACKAGECONFIG[acl] = ",,acl"
23PACKAGECONFIG[selinux] = ",,libselinux"
24
25CONFFILES:${PN} += "${localstatedir}/lib/logrotate.status \
26 ${sysconfdir}/logrotate.conf \
27 ${sysconfdir}/logrotate.d/btmp \
28 ${sysconfdir}/logrotate.d/wtmp"
29
30# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
31# optimization variables, so use it rather than EXTRA_CFLAGS.
32EXTRA_OEMAKE = "\
33 LFS= \
34 OS_NAME='${OS_NAME}' \
35 'CC=${CC}' \
36 'RPM_OPT_FLAGS=${CFLAGS}' \
37 'EXTRA_LDFLAGS=${LDFLAGS}' \
38 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
39 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
40"
41
42# OS_NAME in the makefile defaults to `uname -s`. The behavior for
43# freebsd/netbsd is questionable, so leave it as Linux, which only sets
44# INSTALL=install and BASEDIR=/usr.
45OS_NAME = "Linux"
46
47inherit autotools systemd github-releases
48
49SYSTEMD_SERVICE:${PN} = "\
50 ${BPN}.service \
51 ${BPN}.timer \
52"
53
54LOGROTATE_OPTIONS ?= ""
55
56LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
57LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
58LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
59
60do_install(){
61 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
62 mkdir -p ${D}${sysconfdir}/logrotate.d
63 mkdir -p ${D}${localstatedir}/lib
64 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
65 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
66 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
67 touch ${D}${localstatedir}/lib/logrotate.status
68
69 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
70 install -d ${D}${systemd_system_unitdir}
71 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
72 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
73 [ -z "${LOGROTATE_OPTIONS}" ] ||
74 sed -ri \
75 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
76 ${D}${systemd_system_unitdir}/logrotate.service
77 sed -ri \
78 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
79 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
80 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
81 ${D}${systemd_system_unitdir}/logrotate.timer
82 fi
83
84 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
85 mkdir -p ${D}${sysconfdir}/cron.daily
86 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
87 fi
88}