[97990] trunk/dports/sysutils/logrotate

pixilla at macports.org pixilla at macports.org
Fri Sep 21 06:21:51 PDT 2012


Revision: 97990
          http://trac.macports.org//changeset/97990
Author:   pixilla at macports.org
Date:     2012-09-21 06:21:51 -0700 (Fri, 21 Sep 2012)
Log 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.

Modified Paths:
--------------
    trunk/dports/sysutils/logrotate/Portfile

Added Paths:
-----------
    trunk/dports/sysutils/logrotate/files/logrotate.conf.example
    trunk/dports/sysutils/logrotate/files/org.macports.logrotate.plist.example

Modified: trunk/dports/sysutils/logrotate/Portfile
===================================================================
--- trunk/dports/sysutils/logrotate/Portfile	2012-09-21 12:52:09 UTC (rev 97989)
+++ trunk/dports/sysutils/logrotate/Portfile	2012-09-21 13:21:51 UTC (rev 97990)
@@ -5,7 +5,7 @@
 
 name                logrotate
 version             3.8.2
-revision            1
+revision            2
 categories          sysutils
 platforms           darwin
 license             GPL-2
@@ -31,11 +31,19 @@
 
 post-extract {
     touch ${worksrcpath}/.depend
+    copy ${filespath}/logrotate.conf.example \
+        ${worksrcpath}/
+    copy ${filespath}/org.macports.logrotate.plist.example \
+        ${worksrcpath}/
 }
 
 post-patch {
-    reinplace "s|@@PREFIX@@|${prefix}|g" \
+    reinplace "s|@PREFIX@|${prefix}|g" \
         ${worksrcpath}/examples/logrotate-default
+    reinplace "s|@PREFIX@|${prefix}|g" \
+        ${worksrcpath}/logrotate.conf.example
+    reinplace "s|@PREFIX@|${prefix}|g" \
+        ${worksrcpath}/org.macports.logrotate.plist.example
 }
 
 use_configure       no
@@ -58,55 +66,17 @@
 post-destroot {
     xinstall -d ${destroot}${prefix}/share/${name}
 	xinstall -m 644 -W ${worksrcpath} CHANGES COPYING \
+	    logrotate.conf.example org.macports.logrotate.plist.example \
 		${destroot}${prefix}/share/${name}
-    set fp [open ${destroot}${prefix}/share/${name}/logrotate.conf.example w]
-    puts $fp \
-"# see \"man logrotate\" for details
-# rotate log files weekly
-weekly
 
-# keep 4 weeks worth of backlogs
-rotate 4
+    # The startupitem.install keyword does not exist in MacPorts < 2.1.
+    if {![info exists startupitem.install]} {
 
-# create new (empty) log files after rotating old ones
-create
+        set startupitem.install yes
+    }
+    if {[variant_isset startupitem]
+    && ${startupitem.install} != "no"} {
 
-# use date as a suffix of the rotated file
-dateext
-
-# uncomment this if you want your log files compressed
-#compress
-
-# Drop log rotation information into this directory
-include ${prefix}/etc/logrotate.d"
-    close $fp
-
-    set fp [open ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example w]
-    puts $fp \
-"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>Disabled</key>
-	<true/>
-	<key>Label</key>
-	<string>com.pixilla.logrotate</string>
-	<key>ProgramArguments</key>
-	<array>
-		<string>${prefix}/sbin/logrotate</string>
-		<string>${prefix}/etc/logrotate.conf</string>
-	</array>
-	<key>StartCalendarInterval</key>
-	<dict>
-		<key>Hour</key>
-		<integer>5</integer>
-		<key>Minute</key>
-		<integer>30</integer>
-	</dict>
-</dict>
-</plist>"
-    close $fp
-    if {[variant_isset startupitem]} {
         xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate
         xinstall -d ${destroot}/Library/LaunchDaemons
         xinstall -m 644 ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example \
@@ -115,6 +85,14 @@
     }
 }
 
+post-activate {
+
+    if ![file exists ${prefix}/etc/logrotate.conf] {
+    
+        copy ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf
+    }
+}
+
 variant bzip2 conflicts gzip description {Use bzip2 compression by default} {
     build.env-append \
                     COMPRESS_COMMAND="${prefix}/bin/bzip2" \
@@ -141,6 +119,8 @@
                     +gzip
     variant_set     gzip
 }
+default_variants-append \
+                    +startupitem
 
 livecheck.url       $homepage
 livecheck.type      regex
@@ -155,18 +135,14 @@
 
     \$ sudo cp ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf
 
-  * Logrotate scripts added to ${prefix}/etc/logrotate.d are read by default.
-
-    \$ sudo ${prefix}/sbin/${name} ${prefix}/etc/logrotate.conf
-
   * With the startupitem variant (+startupitem) you can activate a scheduled log 
     rotation with this command.
 
-    \$ sudo port load Logrotate
+    \$ sudo port load logrotate
 
   * To create your own startup item with non-default intervals, build logrotate
     without the startupitem variant (-startupitem), copy the example into place
-    and edit to your liking and load with launchctl when finished.
+    and edit to your liking, then load with launchctl when finished.
 
     \$ sudo cp ${prefix}/share/${name}/org.macports.logrotate.plist.example /Library/LaunchDaemons/org.macports.logrotate.plist
 

Added: trunk/dports/sysutils/logrotate/files/logrotate.conf.example
===================================================================
--- trunk/dports/sysutils/logrotate/files/logrotate.conf.example	                        (rev 0)
+++ trunk/dports/sysutils/logrotate/files/logrotate.conf.example	2012-09-21 13:21:51 UTC (rev 97990)
@@ -0,0 +1,18 @@
+# see "man logrotate" for details
+# Rotate log files weekly.
+weekly
+
+# Keep 4 weeks worth of backlogs.
+rotate 4
+
+# Create new (empty) log files after rotating old ones.
+create
+
+# Use date as a suffix of the rotated file.
+dateext
+
+# Compress log files.
+compress
+
+# Add your logrotate scripts to this directory for convenient inclusion.
+include @PREFIX@/etc/logrotate.d

Added: trunk/dports/sysutils/logrotate/files/org.macports.logrotate.plist.example
===================================================================
(Binary files differ)


Property changes on: trunk/dports/sysutils/logrotate/files/org.macports.logrotate.plist.example
___________________________________________________________________
Added: svn:mime-type
   + application/xml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120921/e68d6d85/attachment.html>


More information about the macports-changes mailing list