blob: 55684ac9fbc533ba4709bf0924eabad455b3c2e3 [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
Andrew Geisslerd1e89492021-02-12 15:35:20 -060022SRC_URI[sha256sum] = "841f81bf09d0014e4a2e11af166bb33fcd8429cc0c2d4a7d3d9ceb3858cfccc5"
Brad Bishop19323692019-04-05 15:28:33 -040023
24PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
25
26PACKAGECONFIG[acl] = ",,acl"
27PACKAGECONFIG[selinux] = ",,libselinux"
28
29CONFFILES_${PN} += "${localstatedir}/lib/logrotate.status \
30 ${sysconfdir}/logrotate.conf \
31 ${sysconfdir}/logrotate.d/btmp \
32 ${sysconfdir}/logrotate.d/wtmp"
33
34# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
35# optimization variables, so use it rather than EXTRA_CFLAGS.
36EXTRA_OEMAKE = "\
37 LFS= \
38 OS_NAME='${OS_NAME}' \
39 'CC=${CC}' \
40 'RPM_OPT_FLAGS=${CFLAGS}' \
41 'EXTRA_LDFLAGS=${LDFLAGS}' \
42 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
43 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
44"
45
46# OS_NAME in the makefile defaults to `uname -s`. The behavior for
47# freebsd/netbsd is questionable, so leave it as Linux, which only sets
48# INSTALL=install and BASEDIR=/usr.
49OS_NAME = "Linux"
50
51inherit autotools systemd
52
53SYSTEMD_SERVICE_${PN} = "\
54 ${BPN}.service \
55 ${BPN}.timer \
56"
57
58LOGROTATE_OPTIONS ?= ""
59
60LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
61LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
62LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
63
64do_install(){
65 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
66 mkdir -p ${D}${sysconfdir}/logrotate.d
67 mkdir -p ${D}${localstatedir}/lib
68 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
69 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
70 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
71 touch ${D}${localstatedir}/lib/logrotate.status
72
73 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
74 install -d ${D}${systemd_system_unitdir}
75 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
76 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
77 [ -z "${LOGROTATE_OPTIONS}" ] ||
78 sed -ri \
79 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
80 ${D}${systemd_system_unitdir}/logrotate.service
81 sed -ri \
82 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
83 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
84 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
85 ${D}${systemd_system_unitdir}/logrotate.timer
86 fi
87
88 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
89 mkdir -p ${D}${sysconfdir}/cron.daily
90 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
91 fi
92}