Changeset 97990


Ignore:
Timestamp:
Sep 21, 2012, 1:21:51 PM (12 years ago)
Author:
pixilla@…
Message:

sysutils/logrotate:

  • Instead of using tcl to write example conf and plist files to destroot add them to files/.
  • Make +startupitem a default variant.
Location:
trunk/dports/sysutils/logrotate
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/sysutils/logrotate/Portfile

    r97677 r97990  
    66name                logrotate
    77version             3.8.2
    8 revision            1
     8revision            2
    99categories          sysutils
    1010platforms           darwin
     
    3232post-extract {
    3333    touch ${worksrcpath}/.depend
     34    copy ${filespath}/logrotate.conf.example \
     35        ${worksrcpath}/
     36    copy ${filespath}/org.macports.logrotate.plist.example \
     37        ${worksrcpath}/
    3438}
    3539
    3640post-patch {
    37     reinplace "s|@@PREFIX@@|${prefix}|g" \
     41    reinplace "s|@PREFIX@|${prefix}|g" \
    3842        ${worksrcpath}/examples/logrotate-default
     43    reinplace "s|@PREFIX@|${prefix}|g" \
     44        ${worksrcpath}/logrotate.conf.example
     45    reinplace "s|@PREFIX@|${prefix}|g" \
     46        ${worksrcpath}/org.macports.logrotate.plist.example
    3947}
    4048
     
    5967    xinstall -d ${destroot}${prefix}/share/${name}
    6068        xinstall -m 644 -W ${worksrcpath} CHANGES COPYING \
     69            logrotate.conf.example org.macports.logrotate.plist.example \
    6170                ${destroot}${prefix}/share/${name}
    62     set fp [open ${destroot}${prefix}/share/${name}/logrotate.conf.example w]
    63     puts $fp \
    64 "# see \"man logrotate\" for details
    65 # rotate log files weekly
    66 weekly
    6771
    68 # keep 4 weeks worth of backlogs
    69 rotate 4
     72    # The startupitem.install keyword does not exist in MacPorts < 2.1.
     73    if {![info exists startupitem.install]} {
    7074
    71 # create new (empty) log files after rotating old ones
    72 create
     75        set startupitem.install yes
     76    }
     77    if {[variant_isset startupitem]
     78    && ${startupitem.install} != "no"} {
    7379
    74 # use date as a suffix of the rotated file
    75 dateext
    76 
    77 # uncomment this if you want your log files compressed
    78 #compress
    79 
    80 # Drop log rotation information into this directory
    81 include ${prefix}/etc/logrotate.d"
    82     close $fp
    83 
    84     set fp [open ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example w]
    85     puts $fp \
    86 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    87 <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
    88 <plist version=\"1.0\">
    89 <dict>
    90         <key>Disabled</key>
    91         <true/>
    92         <key>Label</key>
    93         <string>com.pixilla.logrotate</string>
    94         <key>ProgramArguments</key>
    95         <array>
    96                 <string>${prefix}/sbin/logrotate</string>
    97                 <string>${prefix}/etc/logrotate.conf</string>
    98         </array>
    99         <key>StartCalendarInterval</key>
    100         <dict>
    101                 <key>Hour</key>
    102                 <integer>5</integer>
    103                 <key>Minute</key>
    104                 <integer>30</integer>
    105         </dict>
    106 </dict>
    107 </plist>"
    108     close $fp
    109     if {[variant_isset startupitem]} {
    11080        xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate
    11181        xinstall -d ${destroot}/Library/LaunchDaemons
     
    11383            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist
    11484        ln -sf "${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist" "${destroot}/Library/LaunchDaemons/org.macports.logrotate.plist"
     85    }
     86}
     87
     88post-activate {
     89
     90    if ![file exists ${prefix}/etc/logrotate.conf] {
     91   
     92        copy ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf
    11593    }
    11694}
     
    142120    variant_set     gzip
    143121}
     122default_variants-append \
     123                    +startupitem
    144124
    145125livecheck.url       $homepage
     
    156136    \$ sudo cp ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf
    157137
    158   * Logrotate scripts added to ${prefix}/etc/logrotate.d are read by default.
    159 
    160     \$ sudo ${prefix}/sbin/${name} ${prefix}/etc/logrotate.conf
    161 
    162138  * With the startupitem variant (+startupitem) you can activate a scheduled log
    163139    rotation with this command.
    164140
    165     \$ sudo port load Logrotate
     141    \$ sudo port load logrotate
    166142
    167143  * To create your own startup item with non-default intervals, build logrotate
    168144    without the startupitem variant (-startupitem), copy the example into place
    169     and edit to your liking and load with launchctl when finished.
     145    and edit to your liking, then load with launchctl when finished.
    170146
    171147    \$ sudo cp ${prefix}/share/${name}/org.macports.logrotate.plist.example /Library/LaunchDaemons/org.macports.logrotate.plist
Note: See TracChangeset for help on using the changeset viewer.