[82675] trunk/dports/sysutils/logrotate

pixilla at macports.org pixilla at macports.org
Thu Aug 18 08:13:32 PDT 2011


Revision: 82675
          http://trac.macports.org/changeset/82675
Author:   pixilla at macports.org
Date:     2011-08-17 16:09:48 -0700 (Wed, 17 Aug 2011)
Log Message:
-----------
systuils/logrotate:
- Upgrade to 3.8.0.
- Add conf and startupitem examples.
- Add +startupitem variant.
- Add +gzip and +bzip2 variants to select default compression engine.

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

Added Paths:
-----------
    trunk/dports/sysutils/logrotate/files/
    trunk/dports/sysutils/logrotate/files/patch-Makefile.diff
    trunk/dports/sysutils/logrotate/files/patch-config.c.diff

Modified: trunk/dports/sysutils/logrotate/Portfile
===================================================================
--- trunk/dports/sysutils/logrotate/Portfile	2011-08-17 22:54:28 UTC (rev 82674)
+++ trunk/dports/sysutils/logrotate/Portfile	2011-08-17 23:09:48 UTC (rev 82675)
@@ -4,8 +4,7 @@
 PortSystem          1.0
 
 name                logrotate
-version             3.7.1
-revision            3
+version             3.8.0
 categories          sysutils
 maintainers         pixilla openmaintainer
 platforms           darwin
@@ -18,36 +17,158 @@
                     can be set to handle a log file \daily, weekly, monthly or when the log file \
                     gets to a certain size.
 
-distname            ${name}_${version}.orig
-worksrcdir          ${name}-${version}
+homepage            https://fedorahosted.org/logrotate/
+master_sites        gentoo
+checksums           sha1    a79c500c4ce45177b47bb473a6bff4021af7121e \
+                    rmd160  7e1e24f53db5230eee2e1db8d90fe3a33692ca01
 
-homepage            http://packages.debian.org/stable/admin/logrotate
+patch.pre_args      -p1
+patchfiles          patch-config.c.diff \
+                    patch-Makefile.diff
 
-master_sites        http://ftp.debian.org/debian/pool/main/l/logrotate
-checksums           ${distname}${extract.suffix} md5 552639142e163745f6bcd4f1f3816d8a \
-                    logrotate_${version}-5.diff.gz md5 619d36e123f8d5d6e25a1544a589cf27
+depends_run         port:popt port:gettext
 
-patch_sites         http://ftp.debian.org/debian/pool/main/l/logrotate/
-patchfiles          logrotate_${version}-5.diff.gz
+post-extract {
+    touch ${worksrcpath}/.depend
+}
 
-depends_run         port:popt \
-                    port:gettext \
-                    port:gzip
+post-patch {
+    reinplace "s|@@PREFIX@@|${prefix}|g" \
+        ${worksrcpath}/examples/logrotate-default
+}
 
 use_configure       no
 
-build.args          POPT_DIR=${prefix}/include LDFLAGS="-L${prefix}/lib -lpopt"
+build.env-append    CC="${configure.cc} [get_canonical_archflags]" \
+                    CXX="${configure.cxx} [get_canonical_archflags]" \
+                    CPP="${configure.cpp} [get_canonical_archflags]" \
+                    BASEDIR="${prefix}" \
+                    POPT_DIR="${prefix}/include" \
+                    STATEFILE="${prefix}/var/run/logrotate/logrotate.status" \
+                    DEFAULT_MAIL_COMMAND="/usr/sbin/mail"
 
-post-patch {
-  reinplace "s|\"/bin/gzip\"|\"${prefix}/bin/gzip\"|g" \
-    ${worksrcpath}/config.h
+destroot.args       INSTALL="install" \
+                    BASEDIR=[string trimleft ${destroot}${prefix} /] \
+                    MANDIR="${prefix}/share/man"
+destroot.keepdirs   ${destroot}${prefix}/etc/logrotate.d \
+                    ${destroot}${prefix}/var/run/logrotate
+post-destroot {
+    xinstall -d ${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
 
-  system "cd ${worksrcpath} && patch -p1 < logrotate-${version}/debian/patches/rh-dateext.patch"
+# 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
+
+# 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 755 ${destroot}${prefix}/share/${name}/org.macports.logrotate.plist.example \
+            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist
+        ln -sf "${prefix}/etc/LaunchDaemons/org.macports.logrotate/org.macports.logrotate.plist" "${destroot}/Library/LaunchDaemons/org.macports.logrotate.plist"
+    }
 }
 
-destroot {
-  xinstall -m 755 ${worksrcpath}/logrotate ${destroot}${prefix}/sbin
-  xinstall -m 755 ${worksrcpath}/examples/logrotate-default \
-    ${destroot}${prefix}/etc/logrotate.conf.sample
-  xinstall -m 444 ${worksrcpath}/logrotate.8 ${destroot}${prefix}/share/man/man8
+variant bzip2 conflicts gzip description {Use bzip2 compression by default} {
+    build.env-append \
+                    COMPRESS_COMMAND="${prefix}/bin/bzip2" \
+                    COMPRESS_EXT=".bz2" \
+                    UNCOMPRESS_COMMAND="${prefix}/bin/bunzip2"
+    depends_run-append \
+                    port:bzip2
 }
+
+variant gzip conflicts bzip2 description {Use gzip compression by default} {
+    build.pre_args-append \
+                    COMPRESS_COMMAND="${prefix}/bin/gzip" \
+                    COMPRESS_EXT=".gz" \
+                    UNCOMPRESS_COMMAND="${prefix}/bin/gunzip"
+    depends_run-append \
+                    port:gzip
+}
+
+variant startupitem description {Install launchd plist} {
+}
+
+default_variants    +startupitem
+
+if {![variant_isset bzip2]} {
+    default_variants-append \
+                    +gzip
+    variant_set     gzip
+}
+
+livecheck.type      regex
+livecheck.url       ${master_sites}
+livecheck.regex     ${name}-(\\d+\\.\\d+(\\.\\d+)?)${extract.suffix}
+
+notes \
+"
+
+To use logrotate:
+
+  * If ${prefix}/etc/logrotate.conf does not exist copy the example into place.
+
+    \$ sudo cp ${prefix}/share/${name}/logrotate.conf.example ${prefix}/etc/logrotate.conf
+
+  * logrotate scripts added to ${prefix}/etc/logrotate.d will read by default
+
+    \$ sudo ${prefix}/sbin/${name} ${prefix}/etc/logrotate.conf
+
+  * With the +startupitem variant you can activate a scheduled log rotation with this command.
+
+    \$ sudo port load Logrotate
+
+  * To create your own startup item with non-default intervals build; without the +startupitem
+    variant, copy the example into place and manually edit to your liking.
+
+    \$ sudo cp ${prefix}/share/${name}/org.macports.logrotate.plist.example\
+/Library/LaunchDaemons/org.macports.logrotate.plist
+
+    Once your /Library/LaunchDaemons/org.macports.logrotate.plist file is ready maunually load it
+    with this command.
+
+    \$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.logrotate.plist
+    
+"

Added: trunk/dports/sysutils/logrotate/files/patch-Makefile.diff
===================================================================
--- trunk/dports/sysutils/logrotate/files/patch-Makefile.diff	                        (rev 0)
+++ trunk/dports/sysutils/logrotate/files/patch-Makefile.diff	2011-08-17 23:09:48 UTC (rev 82675)
@@ -0,0 +1,29 @@
+--- a/Makefile	2011-08-11 14:18:53.000000000 -0700
++++ b/Makefile	2011-08-11 19:22:02.000000000 -0700
+@@ -82,8 +82,24 @@
+     CFLAGS += -DSTATEFILE=\"$(STATEFILE)\"
+ endif
+ 
+-BINDIR = $(BASEDIR)/sbin
+-MANDIR = $(BASEDIR)/man
++ifneq ($(COMPRESS_COMMAND),)
++    CFLAGS += -DCOMPRESS_COMMAND=\"$(COMPRESS_COMMAND)\"
++endif
++
++ifneq ($(COMPRESS_EXT),)
++    CFLAGS += -DCOMPRESS_EXT=\"$(COMPRESS_EXT)\"
++endif
++
++ifneq ($(UNCOMPRESS_COMMAND),)
++    CFLAGS += -DUNCOMPRESS_COMMAND=\"$(UNCOMPRESS_COMMAND)\"
++endif
++
++ifneq ($(DEFAULT_MAIL_COMMAND),)
++    CFLAGS += -DDEFAULT_MAIL_COMMAND=\"$(DEFAULT_MAIL_COMMAND)\"
++endif
++
++BINDIR := $(BASEDIR)/sbin
++MANDIR := $(BASEDIR)/man
+ 
+ #--------------------------------------------------------------------------
+ 

Added: trunk/dports/sysutils/logrotate/files/patch-config.c.diff
===================================================================
--- trunk/dports/sysutils/logrotate/files/patch-config.c.diff	                        (rev 0)
+++ trunk/dports/sysutils/logrotate/files/patch-config.c.diff	2011-08-17 23:09:48 UTC (rev 82675)
@@ -0,0 +1,32 @@
+--- a/config.c	2011-08-11 14:18:53.000000000 -0700
++++ b/config.c	2011-08-11 14:19:23.000000000 -0700
+@@ -74,6 +74,29 @@
+ 
+ #endif
+ 
++#if !defined(strndup)
++char *strndup(const char *s, size_t n)
++{
++       size_t nAvail;
++       char *p;
++
++       if(!s)
++               return NULL;
++
++       /* min() */
++       nAvail = strlen(s) + 1;
++       if ( (n + 1) < nAvail)
++               nAvail = n + 1;
++
++       p = malloc(nAvail);
++       if (!p)
++               return NULL;
++       memcpy(p, s, nAvail);
++       p[nAvail - 1] = 0;
++       return p;
++}
++#endif
++
+ enum {
+ 	STATE_DEFAULT = 2,
+ 	STATE_SKIP_LINE = 4,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110818/5dfc2159/attachment.html>


More information about the macports-changes mailing list