blob: 2b6ee0a19a3ae3708b94db36bbc34d70127f5c58 [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
12# When updating logrotate to latest upstream, SRC_URI should point to
13# a proper release tarball from https://github.com/logrotate/logrotate/releases
14# and we have to take the snapshot for now because there is no such
15# tarball available for 3.9.1.
16
17S = "${WORKDIR}/${BPN}-${PV}"
18
19UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/releases"
20UPSTREAM_CHECK_REGEX = "logrotate-(?P<pver>\d+(\.\d+)+).tar"
21
22SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/${PV}/${BP}.tar.xz \
23 file://act-as-mv-when-rotate.patch \
Andrew Geissler4b740dc2020-05-05 08:54:39 -050024 file://0001-Update-the-manual.patch \
Brad Bishop19323692019-04-05 15:28:33 -040025 file://disable-check-different-filesystems.patch \
26 "
27
Andrew Geissler4b740dc2020-05-05 08:54:39 -050028SRC_URI[md5sum] = "faf729e0e24bfaafaa677bc6deb46ed8"
29SRC_URI[sha256sum] = "442f6fdf61c349eeae5f76799878b88fe45a11c8863a38b618bac6988f4a7ce5"
Brad Bishop19323692019-04-05 15:28:33 -040030
31PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
32
33PACKAGECONFIG[acl] = ",,acl"
34PACKAGECONFIG[selinux] = ",,libselinux"
35
36CONFFILES_${PN} += "${localstatedir}/lib/logrotate.status \
37 ${sysconfdir}/logrotate.conf \
38 ${sysconfdir}/logrotate.d/btmp \
39 ${sysconfdir}/logrotate.d/wtmp"
40
41# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
42# optimization variables, so use it rather than EXTRA_CFLAGS.
43EXTRA_OEMAKE = "\
44 LFS= \
45 OS_NAME='${OS_NAME}' \
46 'CC=${CC}' \
47 'RPM_OPT_FLAGS=${CFLAGS}' \
48 'EXTRA_LDFLAGS=${LDFLAGS}' \
49 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
50 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
51"
52
53# OS_NAME in the makefile defaults to `uname -s`. The behavior for
54# freebsd/netbsd is questionable, so leave it as Linux, which only sets
55# INSTALL=install and BASEDIR=/usr.
56OS_NAME = "Linux"
57
58inherit autotools systemd
59
60SYSTEMD_SERVICE_${PN} = "\
61 ${BPN}.service \
62 ${BPN}.timer \
63"
64
65LOGROTATE_OPTIONS ?= ""
66
67LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
68LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
69LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
70
71do_install(){
72 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
73 mkdir -p ${D}${sysconfdir}/logrotate.d
74 mkdir -p ${D}${localstatedir}/lib
75 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
76 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
77 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
78 touch ${D}${localstatedir}/lib/logrotate.status
79
80 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
81 install -d ${D}${systemd_system_unitdir}
82 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
83 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
84 [ -z "${LOGROTATE_OPTIONS}" ] ||
85 sed -ri \
86 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
87 ${D}${systemd_system_unitdir}/logrotate.service
88 sed -ri \
89 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
90 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
91 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
92 ${D}${systemd_system_unitdir}/logrotate.timer
93 fi
94
95 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
96 mkdir -p ${D}${sysconfdir}/cron.daily
97 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
98 fi
99}