On 13 April 2017 at 08:42, Romain Perier <romain.per...@collabora.com>
wrote:

> --- /dev/null
> +++ b/meta/recipes-extended/logrotate/logrotate/logrotate.service
> @@ -0,0 +1,10 @@
> +[Unit]
> +Description=Rotate log files
> +ConditionACPower=true
> +
> +[Service]
> +Type=oneshot
> +ExecStart=/usr/sbin/logrotate /etc/logrotate.conf
>

Hard-coding these paths breaks anyone who wants to change them, use symbols
and replace them at build time.


> +SYSTEMD_AUTO_ENABLE = "disable"
>

What's the rationale for disabling logrotate by default?  The cron script
in the sysv case isn't disabled out of the box from what I can tell, so
that's a behavioural change based on init.


> +LOGROTATE_SYSTEMD_TIMER_BASIS ?= "daily"
> +LOGROTATE_SYSTEMD_TIMER_ACCURACY ?= "12h"
>

Do these really need to be variables in the recipe?

+    # Install systemd unit files
> +    if [ "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd',
> '', d)}" = "systemd" ]; then
> +        install -d ${D}${systemd_system_unitdir}
> +        install -m 0644 ${WORKDIR}/logrotate.service
> ${D}${systemd_system_unitdir}/logrotate.service
> +        install -m 0644 ${WORKDIR}/logrotate.timer
> ${D}${systemd_system_unitdir}/logrotate.timer
> +        sed -i -e 
> 's,OnCalendar=.*$,OnCalendar=${LOGROTATE_SYSTEMD_TIMER_BASIS},g'
> ${D}${systemd_system_unitdir}/logrotate.timer
> +        sed -i -e 
> 's,AccuracySec=.*$,AccuracySec=${LOGROTATE_SYSTEMD_TIMER_ACCURACY},g'
> ${D}${systemd_system_unitdir}/logrotate.timer
> +    else
> +        mkdir -p ${D}${sysconfdir}/cron.daily
> +        install -p -m 0755 examples/logrotate.cron
> ${D}${sysconfdir}/cron.daily/logrotate
> +    fi
>

This breaks if the DISTRO_FEATURES contains both sysvinit and systemd (so
packages should contain the systemd and sysv integration), and different
images are generated that use either sysvinit or systemd.  With this the
cron hooks won't be added but if the package is used under sysv they'll be
needed.

Not that I have a good idea for how to solve this.  Maybe the cron should
check the timer unit isn't running?

Ross
-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to