Opened 2 years ago

Closed 2 years ago

#66348 closed defect (fixed)

logrotate: doesn't install default startitem

Reported by: catap (Kirill A. Korinsky) Owned by: ctreleaven (Craig Treleaven)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: logrotate

Description

By default a logrotate says that I should simple run sudo port load logrotate to enable daily log rotation.

Anyway, running this command filed as:

Error: Failed to load logrotate: Launchd plist /Library/LaunchDaemons/org.macports.logrotate.plist was not found

because it hasn't created any startupitem by default.

Change History (10)

comment:1 Changed 2 years ago by jmroot (Joshua Root)

It's checking if {[variant_isset startupitem] but there is no such variant in the port. The code for installing the startupitem could be greatly simplified with the new startupitem.custom_file option in MacPorts 2.8. Something like this (untested):

  • sysutils/logrotate/Portfile

    a b configure.args-append \ 
    6666
    6767destroot.keepdirs   ${destroot}${prefix}/etc/logrotate.d \
    6868                    ${destroot}${prefix}/var/run/logrotate
     69
     70startupitem.type    launchd
     71startupitem.create  no
     72startupitem.custom_file ${worksrcpath}/org.macports.logrotate.plist.example
     73
    6974post-destroot {
    7075    xinstall -d ${destroot}${prefix}/share/${name}
    7176        xinstall -m 644 -W ${worksrcpath} ChangeLog.md COPYING \
    72             logrotate.conf.example org.macports.logrotate.plist.example \
     77            logrotate.conf.example \
    7378                ${destroot}${prefix}/share/${name}
    74 
    75     if {[variant_isset startupitem]
    76     && ${startupitem.install} != "no"
    77     && [getuid] == 0} {
    78 
    79         xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate
    80         xinstall -d ${destroot}/Library/LaunchDaemons
    81         xinstall -m 644 ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example \
    82             ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist
    83         ln -sf "${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist" "${destroot}/Library/LaunchDaemons/org.macports.logrotate.plist"
    84     }
    8579}
    8680
    8781post-activate {

comment:2 Changed 2 years ago by ctreleaven (Craig Treleaven)

@catap - Thanks for reporting this problem. The port has been broken for new installs since Feb 2019 and no one bothered to file a ticket! I should be able to fix this fairly quickly.

@jmroot - I was not aware of startupitem.custom_file and I usually pay attention to stuff related to daemons. I don't see this keyword mentioned in 'man portfile'. Where can I learn more about it?

comment:3 Changed 2 years ago by ctreleaven (Craig Treleaven)

Found in the 2.8.0 release notes.

comment:4 Changed 2 years ago by ctreleaven (Craig Treleaven)

In 5682ced6e70b17c1f2b4a26fab413e259b44adec/macports-ports (master):

logrotate: fix installing .conf file

revbump
use startupitem.customfile per jmroot suggestion
See: #66348

comment:6 Changed 2 years ago by jmroot (Joshua Root)

Looks like some of the buildbot workers (and so presumably some users also) have an existing unregistered /Library/LaunchDaemons/org.macports.logrotate.plist which will need to be cleaned up in pre-activate. Also, the notes still refer to the startupitem variant.

comment:7 Changed 2 years ago by ctreleaven (Craig Treleaven)

Rats. I inherited that approach when I took over this port. It always seemed odd to handle the launchd plist so differently from logrotate.conf. In both cases, the objective was to preserve any customizations the user may have made. Since the plist has been broken for nearly 3 years, I'll assume that nobody feels a need to run it more or less frequently than daily.

comment:8 Changed 2 years ago by ctreleaven (Craig Treleaven)

In 2253352cd4c1200a3b5cb66782a5aa21e9a251c9/macports-ports (master):

logrotate: delete unregistered plist

no revbump as this fixes cases where port failed installation
plist was formerly unreqistered, delete if found
remove superfluous notes
See: #66348

comment:9 in reply to:  description Changed 2 years ago by ctreleaven (Craig Treleaven)

Replying to catap:

By default a logrotate says that I should simple run sudo port load logrotate to enable daily log rotation.

Anyway, running this command filed as:

Error: Failed to load logrotate: Launchd plist /Library/LaunchDaemons/org.macports.logrotate.plist was not found

because it hasn't created any startupitem by default.

Could you please confirm if logrotate is now working for you?

comment:10 Changed 2 years ago by ctreleaven (Craig Treleaven)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.