blob: 034c37b429817227fff541ab6b55aa6731db0f42 [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001SUMMARY = "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."
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00005LICENSE = "GPL-2.0-only"
Andrew Geissler595f6302022-01-24 19:11:47 +00006
7# TODO: Document coreutils dependency. Why not RDEPENDS? Why not busybox?
8
9DEPENDS="coreutils popt"
10
11LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
12
Andrew Geissler87f5cff2022-09-30 13:13:31 -050013SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz"
Andrew Geissler595f6302022-01-24 19:11:47 +000014
Andrew Geissler78b72792022-06-14 06:47:25 -050015SRC_URI[sha256sum] = "742f6d6e18eceffa49a4bacd933686d3e42931cfccfb694d7f6369b704e5d094"
Andrew Geissler595f6302022-01-24 19:11:47 +000016
17# These CVEs are debian, gentoo or SUSE specific on the way logrotate was installed/used
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000018CVE_CHECK_IGNORE += "CVE-2011-1548 CVE-2011-1549 CVE-2011-1550"
Andrew Geissler595f6302022-01-24 19:11:47 +000019
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
Andrew Geissler87f5cff2022-09-30 13:13:31 -050047inherit autotools systemd github-releases
Andrew Geissler595f6302022-01-24 19:11:47 +000048
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}