Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | SUMMARY = "Rotates, compresses, removes and mails system log files" |
| 2 | SECTION = "console/utils" |
| 3 | HOMEPAGE = "https://github.com/logrotate/logrotate/issues" |
| 4 | LICENSE = "GPLv2" |
| 5 | |
| 6 | # TODO: Document coreutils dependency. Why not RDEPENDS? Why not busybox? |
| 7 | |
| 8 | DEPENDS="coreutils popt" |
| 9 | |
| 10 | LIC_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 | |
| 17 | S = "${WORKDIR}/${BPN}-${PV}" |
| 18 | |
| 19 | UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/releases" |
| 20 | UPSTREAM_CHECK_REGEX = "logrotate-(?P<pver>\d+(\.\d+)+).tar" |
| 21 | |
| 22 | SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/${PV}/${BP}.tar.xz \ |
| 23 | file://act-as-mv-when-rotate.patch \ |
| 24 | file://update-the-manual.patch \ |
| 25 | file://disable-check-different-filesystems.patch \ |
| 26 | " |
| 27 | |
| 28 | SRC_URI[md5sum] = "320046f0b9fc38337e8827d4c5a866a0" |
| 29 | SRC_URI[sha256sum] = "313612c4776a305393454c874ef590d8acf84c9ffa648717731dfe902284ff8f" |
| 30 | |
| 31 | PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'acl selinux', d)}" |
| 32 | |
| 33 | PACKAGECONFIG[acl] = ",,acl" |
| 34 | PACKAGECONFIG[selinux] = ",,libselinux" |
| 35 | |
| 36 | CONFFILES_${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. |
| 43 | EXTRA_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. |
| 56 | OS_NAME = "Linux" |
| 57 | |
| 58 | inherit autotools systemd |
| 59 | |
| 60 | SYSTEMD_SERVICE_${PN} = "\ |
| 61 | ${BPN}.service \ |
| 62 | ${BPN}.timer \ |
| 63 | " |
| 64 | |
| 65 | LOGROTATE_OPTIONS ?= "" |
| 66 | |
| 67 | LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily" |
| 68 | LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h" |
| 69 | LOGROTATE_SYSTEMD_TIMER_PERSISTENT ?= "true" |
| 70 | |
| 71 | do_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 | } |