| 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 |
|---|
| 2 | # $Id$ |
|---|
| 3 | |
|---|
| 4 | PortSystem 1.0 |
|---|
| 5 | |
|---|
| 6 | name logrotate |
|---|
| 7 | version 3.8.1 |
|---|
| 8 | categories sysutils |
|---|
| 9 | maintainers pixilla openmaintainer |
|---|
| 10 | platforms darwin |
|---|
| 11 | |
|---|
| 12 | description Rotates, compresses, and mails system logs |
|---|
| 13 | |
|---|
| 14 | long_description The logrotate utility is designed to simplify the administration of log files \ |
|---|
| 15 | on a system which generates a lot of log files. Logrotate allows for the \ |
|---|
| 16 | automatic rotation compression, removal and mailing of log files. Logrotate \ |
|---|
| 17 | can be set to handle a log file \daily, weekly, monthly or when the log file \ |
|---|
| 18 | gets to a certain size. |
|---|
| 19 | |
|---|
| 20 | homepage https://fedorahosted.org/logrotate/ |
|---|
| 21 | master_sites https://fedorahosted.org/releases/l/o/logrotate/ |
|---|
| 22 | |
|---|
| 23 | checksums rmd160 cec3bc6a4cb4226b31696977935818695027b0f8 \ |
|---|
| 24 | sha256 c12471e70ae8bc923bd5c4f25e8fd6483b68c6301f3cd79f7cfe37bc5b370169 |
|---|
| 25 | |
|---|
| 26 | patchfiles patch-Makefile.diff |
|---|
| 27 | |
|---|
| 28 | depends_run port:popt port:gettext |
|---|
| 29 | |
|---|
| 30 | post-extract { |
|---|
| 31 | touch ${worksrcpath}/.depend |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | post-patch { |
|---|
| 35 | reinplace "s|@@PREFIX@@|${prefix}|g" \ |
|---|
| 36 | ${worksrcpath}/examples/logrotate-default |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | use_configure no |
|---|
| 40 | |
|---|
| 41 | variant universal {} |
|---|
| 42 | |
|---|
| 43 | build.env-append CC="${configure.cc} [get_canonical_archflags]" \ |
|---|
| 44 | CXX="${configure.cxx} [get_canonical_archflags]" \ |
|---|
| 45 | CPP="${configure.cpp} [get_canonical_archflags]" \ |
|---|
| 46 | BASEDIR="${prefix}" \ |
|---|
| 47 | POPT_DIR="${prefix}" \ |
|---|
| 48 | STATEFILE="${prefix}/var/run/logrotate/logrotate.status" \ |
|---|
| 49 | DEFAULT_MAIL_COMMAND="/usr/sbin/mail" |
|---|
| 50 | |
|---|
| 51 | destroot.args INSTALL="install" \ |
|---|
| 52 | BINDIR="${destroot}${prefix}/sbin" \ |
|---|
| 53 | MANDIR="${destroot}${prefix}/share/man" |
|---|
| 54 | destroot.keepdirs ${destroot}${prefix}/etc/logrotate.d \ |
|---|
| 55 | ${destroot}${prefix}/var/run/logrotate |
|---|
| 56 | post-destroot { |
|---|
| 57 | xinstall -d ${destroot}${prefix}/share/${name} |
|---|
| 58 | set fp [open ${destroot}${prefix}/share/${name}/logrotate.conf.example w] |
|---|
| 59 | puts $fp \ |
|---|
| 60 | "# see \"man logrotate\" for details |
|---|
| 61 | # rotate log files weekly |
|---|
| 62 | weekly |
|---|
| 63 | |
|---|
| 64 | # keep 4 weeks worth of backlogs |
|---|
| 65 | rotate 4 |
|---|
| 66 | |
|---|
| 67 | # create new (empty) log files after rotating old ones |
|---|
| 68 | create |
|---|
| 69 | |
|---|
| 70 | # use date as a suffix of the rotated file |
|---|
| 71 | dateext |
|---|
| 72 | |
|---|
| 73 | # uncomment this if you want your log files compressed |
|---|
| 74 | #compress |
|---|
| 75 | |
|---|
| 76 | # Drop log rotation information into this directory |
|---|
| 77 | include ${prefix}/etc/logrotate.d" |
|---|
| 78 | close $fp |
|---|
| 79 | |
|---|
| 80 | set fp [open ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example w] |
|---|
| 81 | puts $fp \ |
|---|
| 82 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
|---|
| 83 | <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> |
|---|
| 84 | <plist version=\"1.0\"> |
|---|
| 85 | <dict> |
|---|
| 86 | <key>Disabled</key> |
|---|
| 87 | <true/> |
|---|
| 88 | <key>Label</key> |
|---|
| 89 | <string>com.pixilla.logrotate</string> |
|---|
| 90 | <key>ProgramArguments</key> |
|---|
| 91 | <array> |
|---|
| 92 | <string>${prefix}/sbin/logrotate</string> |
|---|
| 93 | <string>${prefix}/etc/logrotate.conf</string> |
|---|
| 94 | </array> |
|---|
| 95 | <key>StartCalendarInterval</key> |
|---|
| 96 | <dict> |
|---|
| 97 | <key>Hour</key> |
|---|
| 98 | <integer>5</integer> |
|---|
| 99 | <key>Minute</key> |
|---|
| 100 | <integer>30</integer> |
|---|
| 101 | </dict> |
|---|
| 102 | </dict> |
|---|
| 103 | </plist>" |
|---|
| 104 | close $fp |
|---|
| 105 | if {[variant_isset startupitem]} { |
|---|
| 106 | xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate |
|---|
| 107 | xinstall -d ${destroot}/Library/LaunchDaemons |
|---|
| 108 | xinstall -m 644 ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example \ |
|---|
| 109 | ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist |
|---|
| 110 | ln -sf "${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist" "${destroot}/Library/LaunchDaemons/org.macports.logrotate.plist" |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | variant bzip2 conflicts gzip description {Use bzip2 compression by default} { |
|---|
| 115 | build.env-append \ |
|---|
| 116 | COMPRESS_COMMAND="${prefix}/bin/bzip2" \ |
|---|
| 117 | COMPRESS_EXT=".bz2" \ |
|---|
| 118 | UNCOMPRESS_COMMAND="${prefix}/bin/bunzip2" |
|---|
| 119 | depends_run-append \ |
|---|
| 120 | port:bzip2 |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | variant gzip conflicts bzip2 description {Use gzip compression by default} { |
|---|
| 124 | build.pre_args-append \ |
|---|
| 125 | COMPRESS_COMMAND="${prefix}/bin/gzip" \ |
|---|
| 126 | COMPRESS_EXT=".gz" \ |
|---|
| 127 | UNCOMPRESS_COMMAND="${prefix}/bin/gunzip" |
|---|
| 128 | depends_run-append \ |
|---|
| 129 | port:gzip |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | variant startupitem description {Install launchd plist} { |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | if {![variant_isset bzip2]} { |
|---|
| 136 | default_variants-append \ |
|---|
| 137 | +gzip |
|---|
| 138 | variant_set gzip |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | livecheck.url $homepage |
|---|
| 142 | livecheck.type regex |
|---|
| 143 | livecheck.regex "(?!${name}).*${name}-((?!${extract.suffix}).*)${extract.suffix}" |
|---|
| 144 | |
|---|
| 145 | notes \ |
|---|
| 146 | " |
|---|
| 147 | |
|---|
| 148 | To use logrotate: |
|---|
| 149 | |
|---|
| 150 | * If ${prefix}/etc/logrotate.conf does not exist copy the example into place. |
|---|
| 151 | |
|---|
| 152 | \$ sudo cp ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf |
|---|
| 153 | |
|---|
| 154 | * Logrotate scripts added to ${prefix}/etc/logrotate.d are read by default. |
|---|
| 155 | |
|---|
| 156 | \$ sudo ${prefix}/sbin/${name} ${prefix}/etc/logrotate.conf |
|---|
| 157 | |
|---|
| 158 | * With the startupitem variant (+startupitem) you can activate a scheduled log |
|---|
| 159 | rotation with this command. |
|---|
| 160 | |
|---|
| 161 | \$ sudo port load Logrotate |
|---|
| 162 | |
|---|
| 163 | * To create your own startup item with non-default intervals, build logrotate |
|---|
| 164 | without the startupitem variant (-startupitem), copy the example into place |
|---|
| 165 | and edit to your liking and load with launchctl when finished. |
|---|
| 166 | |
|---|
| 167 | \$ sudo cp ${prefix}/share/${name}/org.macports.logrotate.plist.example /Library/LaunchDaemons/org.macports.logrotate.plist |
|---|
| 168 | |
|---|
| 169 | \$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.logrotate.plist |
|---|
| 170 | |
|---|
| 171 | " |
|---|