Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | SUMMARY = "Rotates, compresses, removes and mails system log files" |
| 2 | SECTION = "console/utils" |
| 3 | HOMEPAGE = "https://github.com/logrotate/logrotate/" |
| 4 | DESCRIPTION = "The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files." |
| 5 | LICENSE = "GPL-2.0-only" |
| 6 | |
| 7 | # TODO: Document coreutils dependency. Why not RDEPENDS? Why not busybox? |
| 8 | |
| 9 | DEPENDS="coreutils popt" |
| 10 | |
| 11 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" |
| 12 | |
| 13 | SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz" |
| 14 | |
| 15 | SRC_URI[sha256sum] = "8fa12015e3b8415c121fc9c0ca53aa872f7b0702f543afda7e32b6c4900f6516" |
| 16 | |
| 17 | # These CVEs are debian, gentoo or SUSE specific on the way logrotate was installed/used |
| 18 | CVE_CHECK_IGNORE += "CVE-2011-1548 CVE-2011-1549 CVE-2011-1550" |
| 19 | |
| 20 | PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}" |
| 21 | |
| 22 | PACKAGECONFIG[acl] = ",,acl" |
| 23 | PACKAGECONFIG[selinux] = ",,libselinux" |
| 24 | |
| 25 | CONFFILES:${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. |
| 32 | EXTRA_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. |
| 45 | OS_NAME = "Linux" |
| 46 | |
| 47 | inherit autotools systemd github-releases |
| 48 | |
| 49 | SYSTEMD_SERVICE:${PN} = "\ |
| 50 | ${BPN}.service \ |
| 51 | ${BPN}.timer \ |
| 52 | " |
| 53 | |
| 54 | LOGROTATE_OPTIONS ?= "" |
| 55 | |
| 56 | LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily" |
| 57 | LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h" |
| 58 | LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true" |
| 59 | |
| 60 | do_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 | } |