blob: 1c9df5a3cadb9c3e8185b0541c1ba3eb9373a88c [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
Brad Bishop19323692019-04-05 15:28:33 -040012UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/releases"
13UPSTREAM_CHECK_REGEX = "logrotate-(?P<pver>\d+(\.\d+)+).tar"
14
15SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/${PV}/${BP}.tar.xz \
16 file://act-as-mv-when-rotate.patch \
Andrew Geissler4b740dc2020-05-05 08:54:39 -050017 file://0001-Update-the-manual.patch \
Brad Bishop19323692019-04-05 15:28:33 -040018 file://disable-check-different-filesystems.patch \
19 "
20
Andrew Geissler4b740dc2020-05-05 08:54:39 -050021SRC_URI[md5sum] = "faf729e0e24bfaafaa677bc6deb46ed8"
22SRC_URI[sha256sum] = "442f6fdf61c349eeae5f76799878b88fe45a11c8863a38b618bac6988f4a7ce5"
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}