blob: f0755e3ae5df968ddbe576b0ba9e649fde97600a [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
Patrick Williams8e7b46e2023-05-01 14:19:06 -050013SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz \
14 file://run-ptest \
15 "
Andrew Geissler517393d2023-01-13 08:55:19 -060016
17SRC_URI[sha256sum] = "8fa12015e3b8415c121fc9c0ca53aa872f7b0702f543afda7e32b6c4900f6516"
18
19# These CVEs are debian, gentoo or SUSE specific on the way logrotate was installed/used
20CVE_CHECK_IGNORE += "CVE-2011-1548 CVE-2011-1549 CVE-2011-1550"
21
22PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}"
23
24PACKAGECONFIG[acl] = ",,acl"
25PACKAGECONFIG[selinux] = ",,libselinux"
26
27CONFFILES:${PN} += "${localstatedir}/lib/logrotate.status \
28 ${sysconfdir}/logrotate.conf \
29 ${sysconfdir}/logrotate.d/btmp \
30 ${sysconfdir}/logrotate.d/wtmp"
31
32# If RPM_OPT_FLAGS is unset, it adds -g itself rather than obeying our
33# optimization variables, so use it rather than EXTRA_CFLAGS.
34EXTRA_OEMAKE = "\
35 LFS= \
36 OS_NAME='${OS_NAME}' \
37 'CC=${CC}' \
38 'RPM_OPT_FLAGS=${CFLAGS}' \
39 'EXTRA_LDFLAGS=${LDFLAGS}' \
40 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'WITH_ACL=yes', '', d)} \
41 ${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'WITH_SELINUX=yes', '', d)} \
42"
43
44# OS_NAME in the makefile defaults to `uname -s`. The behavior for
45# freebsd/netbsd is questionable, so leave it as Linux, which only sets
46# INSTALL=install and BASEDIR=/usr.
47OS_NAME = "Linux"
48
Patrick Williams8e7b46e2023-05-01 14:19:06 -050049inherit autotools systemd github-releases ptest
Andrew Geissler517393d2023-01-13 08:55:19 -060050
51SYSTEMD_SERVICE:${PN} = "\
52 ${BPN}.service \
53 ${BPN}.timer \
54"
55
56LOGROTATE_OPTIONS ?= ""
57
58LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
59LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
60LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true"
61
62do_install(){
63 oe_runmake install DESTDIR=${D} PREFIX=${D} MANDIR=${mandir}
64 mkdir -p ${D}${sysconfdir}/logrotate.d
65 mkdir -p ${D}${localstatedir}/lib
66 install -p -m 644 ${S}/examples/logrotate.conf ${D}${sysconfdir}/logrotate.conf
67 install -p -m 644 ${S}/examples/btmp ${D}${sysconfdir}/logrotate.d/btmp
68 install -p -m 644 ${S}/examples/wtmp ${D}${sysconfdir}/logrotate.d/wtmp
Andrew Geissler517393d2023-01-13 08:55:19 -060069
70 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
71 install -d ${D}${systemd_system_unitdir}
72 install -m 0644 ${S}/examples/logrotate.service ${D}${systemd_system_unitdir}/logrotate.service
73 install -m 0644 ${S}/examples/logrotate.timer ${D}${systemd_system_unitdir}/logrotate.timer
74 [ -z "${LOGROTATE_OPTIONS}" ] ||
75 sed -ri \
76 -e 's|(ExecStart=.*/logrotate.*)$|\1 ${LOGROTATE_OPTIONS}|g' \
77 ${D}${systemd_system_unitdir}/logrotate.service
78 sed -ri \
79 -e 's|(OnCalendar=).*$|\1${LOGROTATE_SYSTEMD_TIMER_BASIS}|g' \
80 -e 's|(AccuracySec=).*$|\1${LOGROTATE_SYSTEMD_TIMER_ACCURACY}|g' \
81 -e 's|(Persistent=).*$|\1${LOGROTATE_SYSTEMD_TIMER_PERSISTENT}|g' \
82 ${D}${systemd_system_unitdir}/logrotate.timer
83 fi
84
85 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
86 mkdir -p ${D}${sysconfdir}/cron.daily
87 install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
88 fi
89}
Patrick Williams8e7b46e2023-05-01 14:19:06 -050090
91do_install_ptest() {
92 cp -r ${S}/test/* ${D}${PTEST_PATH}
93 cp ${S}/test-driver ${D}${PTEST_PATH}
94 cp ${B}/test/Makefile ${D}${PTEST_PATH}
95
96 # Do not rebuild Makefile
97 sed -i 's/^Makefile:/_Makefile:/' ${D}${PTEST_PATH}/Makefile
98
99 # Fix top_builddir and top_srcdir
100 sed -e 's/^top_builddir = \(.*\)/top_builddir = ./' \
101 -e 's/^top_srcdir = \(.*\)/top_srcdir = ./' \
102 -i ${D}${PTEST_PATH}/Makefile
103
104 # Replace bash with sh
105 sed -i 's,/bin/bash,/bin/sh,' ${D}${PTEST_PATH}/Makefile
106
107 # Replace gawk with awk
108 sed -i 's/gawk/awk/' ${D}${PTEST_PATH}/Makefile
109 ln -s ${sbindir}/logrotate ${D}${PTEST_PATH}
110}
111
112# coreutils is needed to have "readlink"
113RDEPENDS:${PN}-ptest += "make coreutils"