[55506] branches/gsoc09-logging/base/src

enl at macports.org enl at macports.org
Wed Aug 12 05:26:33 PDT 2009


Revision: 55506
          http://trac.macports.org/changeset/55506
Author:   enl at macports.org
Date:     2009-08-12 05:26:30 -0700 (Wed, 12 Aug 2009)
Log Message:
-----------
Merge from trunc

Modified Paths:
--------------
    branches/gsoc09-logging/base/src/config.h.in
    branches/gsoc09-logging/base/src/cregistry/Makefile
    branches/gsoc09-logging/base/src/macports1.0/Makefile
    branches/gsoc09-logging/base/src/macports1.0/macports.c
    branches/gsoc09-logging/base/src/macports1.0/macports.tcl
    branches/gsoc09-logging/base/src/pextlib1.0/Makefile
    branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.c
    branches/gsoc09-logging/base/src/pextlib1.0/strsed.h
    branches/gsoc09-logging/base/src/pextlib1.0/xinstall.c
    branches/gsoc09-logging/base/src/port/port-help.tcl
    branches/gsoc09-logging/base/src/port/port.tcl
    branches/gsoc09-logging/base/src/port/portindex.tcl
    branches/gsoc09-logging/base/src/port1.0/portbuild.tcl
    branches/gsoc09-logging/base/src/port1.0/portclean.tcl
    branches/gsoc09-logging/base/src/port1.0/portconfigure.tcl
    branches/gsoc09-logging/base/src/port1.0/portdestroot.tcl
    branches/gsoc09-logging/base/src/port1.0/portfetch.tcl
    branches/gsoc09-logging/base/src/port1.0/portlint.tcl
    branches/gsoc09-logging/base/src/port1.0/portmain.tcl
    branches/gsoc09-logging/base/src/port1.0/porttrace.tcl
    branches/gsoc09-logging/base/src/port1.0/portutil.tcl
    branches/gsoc09-logging/base/src/programs/daemondo/Makefile.in
    branches/gsoc09-logging/base/src/programs/daemondo/main.c
    branches/gsoc09-logging/base/src/registry1.0/portimage.tcl
    branches/gsoc09-logging/base/src/registry1.0/registry.tcl
    branches/gsoc09-logging/base/src/registry2.0/portimage.tcl
    branches/gsoc09-logging/base/src/upgrade_sources_conf_default.tcl

Added Paths:
-----------
    branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.c
    branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.h
    branches/gsoc09-logging/base/src/macports1.0/sysctl.c
    branches/gsoc09-logging/base/src/macports1.0/sysctl.h
    branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.h
    branches/gsoc09-logging/base/src/pextlib1.0/flock.c
    branches/gsoc09-logging/base/src/pextlib1.0/flock.h
    branches/gsoc09-logging/base/src/pextlib1.0/system.c
    branches/gsoc09-logging/base/src/pextlib1.0/system.h

Removed Paths:
-------------
    branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.c
    branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.h
    branches/gsoc09-logging/base/src/pextlib1.0/sysctl.c
    branches/gsoc09-logging/base/src/pextlib1.0/sysctl.h

Property Changed:
----------------
    branches/gsoc09-logging/base/src/pextlib1.0/strsed.h

Modified: branches/gsoc09-logging/base/src/config.h.in
===================================================================
--- branches/gsoc09-logging/base/src/config.h.in	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/config.h.in	2009-08-12 12:26:30 UTC (rev 55506)
@@ -211,6 +211,9 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 

Modified: branches/gsoc09-logging/base/src/cregistry/Makefile
===================================================================
--- branches/gsoc09-logging/base/src/cregistry/Makefile	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/cregistry/Makefile	2009-08-12 12:26:30 UTC (rev 55506)
@@ -11,7 +11,7 @@
 all:: ${STLIB_NAME}
 
 .c.o:
-	${CC} -c -DUSE_TCL_STUBS ${CFLAGS} ${SHLIB_CFLAGS} $< -o $@
+	${CC} -c -DUSE_TCL_STUBS ${CFLAGS} ${CPPFLAGS} ${SHLIB_CFLAGS} $< -o $@
 
 ${STLIB_NAME}:: ${OBJS}
 	${STLIB_LD} ${STLIB_NAME} ${OBJS}

Modified: branches/gsoc09-logging/base/src/macports1.0/Makefile
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/Makefile	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/macports1.0/Makefile	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,6 +1,6 @@
 SRCS=		macports.tcl macports_dlist.tcl macports_util.tcl \
 		macports_autoconf.tcl macports_index.tcl macports_fastload.tcl
-OBJS=		macports.o
+OBJS=		macports.o get_systemconfiguration_proxies.o sysctl.o
 SHLIB_NAME=	MacPorts${SHLIB_SUFFIX}
 
 INSTALLDIR=	${DESTDIR}${TCL_PACKAGE_DIR}/macports1.0
@@ -8,6 +8,10 @@
 include ../../Mk/macports.autoconf.mk
 include ../../Mk/macports.tea.mk
 
+ifeq ($(OBJC_RUNTIME), APPLE_RUNTIME)
+	LIBS+= -framework CoreFoundation -framework SystemConfiguration
+endif
+
 test::
 	${TCLSH} tests/macports_dlist.tcl
 	${TCLSH} tests/macports_util.tcl

Copied: branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.c (from rev 55505, trunk/base/src/macports1.0/get_systemconfiguration_proxies.c)
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.c	                        (rev 0)
+++ branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,175 @@
+/*
+ * get_systemconfiguration_proxies.c
+ * $Id$
+ *
+ * Copyright (c) 2008-2009, The MacPorts Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MacPorts Team nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "get_systemconfiguration_proxies.h"
+
+
+#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+int appendProxyInformationForKeys( CFDictionaryRef proxies, Tcl_Obj *tclList, const char *listKey, const void *proxyEnabledKey, const void *proxyHostKey, const void *proxyPortKey );
+char *cfStringToCStringASCII( CFStringRef cfString );
+
+#endif   /* HAVE_FRAMEWORK_SYSTEMCONFIGURATION */
+
+
+/**
+ *
+ * Query SystemConfiguration for proxy information, returning this
+ * information in a Tcl list ready to be 'array set' (key, name pairs).
+ *
+ * Synopsis: array set someArray get_systemconfiguration_proxies
+ */
+int GetSystemConfigurationProxiesCmd( ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED )
+{
+    int cmdResult = TCL_OK;
+#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
+    CFDictionaryRef proxies = SCDynamicStoreCopyProxies( NULL );
+    if( proxies != NULL )
+    {
+        Tcl_Obj *proxyList = Tcl_NewListObj( 0, NULL );
+        if( appendProxyInformationForKeys( proxies, proxyList, "proxy_http", kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort ) == 0 &&
+            appendProxyInformationForKeys( proxies, proxyList, "proxy_https", kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort ) == 0 &&
+            appendProxyInformationForKeys( proxies, proxyList, "proxy_ftp", kSCPropNetProxiesFTPEnable, kSCPropNetProxiesFTPProxy, kSCPropNetProxiesFTPPort ) == 0 )
+        {
+            CFArrayRef exceptionsCFArray = CFDictionaryGetValue( proxies, kSCPropNetProxiesExceptionsList );
+            if( exceptionsCFArray != NULL )
+            {
+                CFStringRef exceptionsCFString = CFStringCreateByCombiningStrings( kCFAllocatorDefault, exceptionsCFArray, CFSTR( "," ) );
+                char *exceptionsString = cfStringToCStringASCII( exceptionsCFString );
+                if( exceptionsString != NULL )
+                {
+                    Tcl_Obj *exceptionsKey = Tcl_NewStringObj( "proxy_skip", 10 );
+                    Tcl_Obj *exceptionsTclString = Tcl_NewStringObj( exceptionsString, strlen( exceptionsString ) );
+                    Tcl_ListObjAppendElement( interp, proxyList, exceptionsKey );
+                    Tcl_ListObjAppendElement( interp, proxyList, exceptionsTclString );
+                    free( exceptionsString );
+                }
+                else
+                    cmdResult = TCL_ERROR;
+                CFRelease( exceptionsCFString );
+            }
+            Tcl_SetObjResult( interp, proxyList );
+        }
+        else
+            cmdResult = TCL_ERROR;
+        CFRelease( proxies );
+    }
+    if( cmdResult == TCL_ERROR )
+        Tcl_SetResult( interp, (char *) Tcl_PosixError( interp ), TCL_STATIC );
+#endif
+   return cmdResult;
+}
+
+
+#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
+/**
+ *
+ * Extract the proxy information (given by proxyEnabledKey, proxyHostKey,
+ * and proxyPortKey) from the proxies dictionary, then append listKey and
+ * the pertinent proxy information to the Tcl list.
+ *
+ * Returns 0 on success; -1 on failure
+ */
+int appendProxyInformationForKeys( CFDictionaryRef proxies, Tcl_Obj *tclList, const char *listKey, const void *proxyEnabledKey, const void *proxyHostKey, const void *proxyPortKey )
+{
+    int result = 0;
+    CFNumberRef proxyEnabledNumber = CFDictionaryGetValue( proxies, proxyEnabledKey );
+    int proxyEnabled = 0;
+    if( proxyEnabledNumber != NULL &&
+        CFNumberGetValue( proxyEnabledNumber, kCFNumberIntType, &proxyEnabled ) &&
+        proxyEnabled )
+    {
+        CFStringRef proxyHostString = CFDictionaryGetValue( proxies, proxyHostKey );
+        char *hostname = NULL;
+        if( proxyHostString != NULL &&
+            ( hostname = cfStringToCStringASCII( proxyHostString ) ) != NULL )
+        {
+            CFNumberRef proxyPortNumber = CFDictionaryGetValue( proxies, proxyPortKey );
+            int proxyPort = 0;
+            if( proxyPortNumber != NULL &&
+                CFNumberGetValue( proxyPortNumber, kCFNumberIntType, &proxyPort ) &&
+                proxyPort > 0 )
+            {
+                /*
+                 * We are adding :<port>\0 to the end, which is up to 7
+                 * bytes additional (up to 5 for the port)
+                 */
+                int newLength = strlen( hostname ) + 7;
+                char *hostnameAndPort = calloc( 1, newLength );
+                if( hostnameAndPort != NULL )
+                {
+                    Tcl_Obj *hostnameAndPortTcl;
+                    Tcl_Obj *listKeyTcl = Tcl_NewStringObj( listKey, strlen( listKey ) );
+                    Tcl_ListObjAppendElement( NULL, tclList, listKeyTcl );
+                    snprintf( hostnameAndPort, newLength, "%s:%d", hostname, proxyPort );
+                    hostnameAndPortTcl = Tcl_NewStringObj( hostnameAndPort, strlen( hostnameAndPort ) );
+                    Tcl_ListObjAppendElement( NULL, tclList, hostnameAndPortTcl );
+                    free( hostnameAndPort );
+                }
+                else
+                    result = -1;
+            }
+            else
+                result = -1;
+        }
+        else
+            result = -1;
+    }
+
+    return result;
+}
+
+
+/**
+ *
+ * Convert a CFStringRef to an ASCII-encoded C string; be sure to free()
+ * the returned string when done with it.
+ */
+char *cfStringToCStringASCII( CFStringRef cfString )
+{
+    int strLen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( cfString ), kCFStringEncodingASCII ) + 1;
+    char *cString = calloc( 1, strLen );
+    if( cString != NULL )
+        CFStringGetCString( cfString, cString, strLen, kCFStringEncodingASCII );
+
+   return cString;
+}
+
+#endif
+

Copied: branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.h (from rev 55505, trunk/base/src/macports1.0/get_systemconfiguration_proxies.h)
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.h	                        (rev 0)
+++ branches/gsoc09-logging/base/src/macports1.0/get_systemconfiguration_proxies.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,41 @@
+/* 
+ * get_systemconfiguration_proxies.h 
+ * $Id$ 
+ * 
+ * Copyright (c) 2008-2009, The MacPorts Project. 
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of MacPorts Team nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *  
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE. 
+ */ 
+
+#ifndef _GETSYSTEMCONFIGURATIONPROXIES_H
+#define _GETSYSTEMCONFIGURATIONPROXIES_H
+
+#include <tcl.h> 
+
+int GetSystemConfigurationProxiesCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ); 
+
+#endif   /* _GETSYSTEMCONFIGURATIONPROXIES_H */
+

Modified: branches/gsoc09-logging/base/src/macports1.0/macports.c
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/macports.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/macports1.0/macports.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -37,6 +37,9 @@
 
 #include <tcl.h>
 
+#include "get_systemconfiguration_proxies.h"
+#include "sysctl.h"
+
 static int
 macports__version(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])
 {
@@ -54,6 +57,8 @@
 	if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
 		return TCL_ERROR;
 	Tcl_CreateObjCommand(interp, "macports::version", macports__version, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "get_systemconfiguration_proxies", GetSystemConfigurationProxiesCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "sysctl", SysctlCmd, NULL, NULL);
 	if (Tcl_PkgProvide(interp, "macports", "1.0") != TCL_OK)
 		return TCL_ERROR;
 	return TCL_OK;

Modified: branches/gsoc09-logging/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/macports.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/macports1.0/macports.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -164,9 +164,9 @@
     global macports::channels ::debuglog
     set default_channel [macports::ui_channels_default $priority]
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels($priority) [ui_channels $priority]
-    } catch * {
+    } else {
         set channels($priority) $default_channel
     }
     
@@ -510,6 +510,8 @@
             ui_debug "$variants_conf does not exist, variants_conf setting ignored."
         }
     }
+    global macports::global_variations
+    array set macports::global_variations [mport_filtervariants [array get variations] yes]
 
     if {![info exists portdbpath]} {
         return -code error "portdbpath must be set in ${macports_conf_path}/macports.conf or in your ${macports_user_dir}/macports.conf"
@@ -881,6 +883,7 @@
     $workername alias getportdir macports::getportdir
     $workername alias findBinary macports::findBinary
     $workername alias binaryInPath macports::binaryInPath
+    $workername alias sysctl sysctl
 
     # New Registry/Receipts stuff
     $workername alias registry_new registry::new_entry
@@ -1050,6 +1053,9 @@
         file {
             set proposedpath [file normalize [file join [getportdir $url] .. ..]]
         }
+        default {
+            set proposedpath [getsourcepath $url]
+        }
     }
 
     # append requested path
@@ -1168,11 +1174,9 @@
 
     $workername eval source Portfile
 
-    # add the default universal variant, but only if
-    # it will work and another one isn't already present
-    if {[$workername eval default_universal_variant_allowed]} {
-        $workername eval add_default_universal_variant
-    }
+    # add the default universal variant if appropriate, and set up flags that
+    # are conditional on whether universal is set
+    $workername eval universal_setup
 
     # evaluate the variants
     if {[$workername eval eval_variants variations] != 0} {
@@ -1484,6 +1488,11 @@
         || $target == "rpm" || $target == "dpkg"
         || $target == "srpm"|| $target == "portpkg" } {
 
+        # upgrade dependencies that are already installed
+        if {![macports::global_option_isset ports_nodeps]} {
+            macports::_upgrade_mport_deps $mport $target
+        }
+
         ui_msg -nonewline "--->  Computing dependencies for [_mportkey $mport name]"
         if {[macports::ui_isset ports_debug]} {
             # play nice with debug messages
@@ -1492,7 +1501,9 @@
         if {[mportdepends $mport $target] != 0} {
             return 1
         }
-        ui_msg ""
+        if {![macports::ui_isset ports_debug]} {
+            ui_msg ""
+        }
 
         # Select out the dependents along the critical path,
         # but exclude this mport, we might not be installing it.
@@ -1550,6 +1561,33 @@
     return $result
 }
 
+# upgrade any dependencies of mport that are installed and needed for target
+proc macports::_upgrade_mport_deps {mport target} {
+    set options [ditem_key $mport options]
+    set deptypes [macports::_deptypes_for_target $target]
+    array set portinfo [mportinfo $mport]
+    set depends {}
+    array set depscache {}
+
+    foreach deptype $deptypes {
+        # Add to the list of dependencies if the option exists and isn't empty.
+        if {[info exists portinfo($deptype)] && $portinfo($deptype) != ""} {
+            set depends [concat $depends $portinfo($deptype)]
+        }
+    }
+    
+    foreach depspec $depends {
+        set dep_portname [lindex [split $depspec :] end]
+        if {![info exists depscache(port:$dep_portname)] && [registry::entry_exists_for_name $dep_portname]} {
+            set status [macports::upgrade $dep_portname "port:$dep_portname" {} $options depscache]
+            # status 2 means the port was not found in the index
+            if {$status != 0 && $status != 2 && ![macports::ui_isset ports_processall]} {
+                return -code error "upgrade $dep_portname failed"
+            }
+        }
+    }
+}
+
 proc macports::getsourcepath {url} {
     global macports::portdbpath
 
@@ -1731,7 +1769,8 @@
                     # sync just a PortIndex file
                     set indexfile [macports::getindex $source]
                     file mkdir [file dirname $indexfile]
-                    curl $source/PortIndex $indexfile
+                    curl fetch ${source}/PortIndex $indexfile
+                    curl fetch ${source}/PortIndex.quick ${indexfile}.quick
                 }
             }
             default {
@@ -1911,13 +1950,17 @@
                     lappend matches $name
                     lappend matches $line
                     close $fd
-                    break
+                    set fd -1
                 } catch {*} {
                     ui_warn "It looks like your PortIndex file may be corrupt."
-                    throw
                 } finally {
-                    catch {close $fd}
+                    if {$fd != -1} {
+                        close $fd
+                    }
                 }
+                if {[llength $matches] > 0} {
+                    break
+                }
             }
         } else {
             array set attrs [list name $name]
@@ -1946,8 +1989,8 @@
         if {![file exists ${index}]} {
             continue
         }
-        if {![file exists ${index}.quick] || [file mtime ${index}] > [file mtime ${index}.quick]} {
-            # stale or nonexistent quick index file, so generate a new one
+        if {![file exists ${index}.quick]} {
+            ui_warn "No quick index file found, attempting to generate one for source: $source"
             if {[catch {set quicklist [mports_generate_quickindex ${index}]}]} {
                 continue
             }
@@ -2076,30 +2119,8 @@
         }
     }
 
-    # Determine deptypes to look for based on target
-    switch $target {
-        fetch       -
-        checksum    { set deptypes "depends_fetch" }
-        extract     -
-        patch       { set deptypes "depends_fetch depends_extract" }
-        configure   -
-        build       { set deptypes "depends_fetch depends_extract depends_lib depends_build" }
+    set deptypes [macports::_deptypes_for_target $target]
 
-        test        -
-        destroot    -
-        install     -
-        archive     -
-        dmg         -
-        pkg         -
-        portpkg     -
-        mdmg        -
-        mpkg        -
-        rpm         -
-        srpm        -
-        dpkg        -
-        ""          { set deptypes "depends_fetch depends_extract depends_lib depends_build depends_run" }
-    }
-
     # Gather the dependencies for deptypes
     foreach deptype $deptypes {
         # Add to the list of dependencies if the option exists and isn't empty.
@@ -2166,6 +2187,33 @@
     return 0
 }
 
+# Determine dependency types required for target
+proc macports::_deptypes_for_target {target} {
+    switch $target {
+        fetch       -
+        checksum    { set deptypes "depends_fetch" }
+        extract     -
+        patch       { set deptypes "depends_fetch depends_extract" }
+        configure   -
+        build       { set deptypes "depends_fetch depends_extract depends_lib depends_build" }
+
+        test        -
+        destroot    -
+        install     -
+        archive     -
+        dmg         -
+        pkg         -
+        portpkg     -
+        mdmg        -
+        mpkg        -
+        rpm         -
+        srpm        -
+        dpkg        -
+        ""          { set deptypes "depends_fetch depends_extract depends_lib depends_build depends_run" }
+    }
+    return $deptypes
+}
+
 # selfupdate procedure
 proc macports::selfupdate {{optionslist {}}} {
     global macports::prefix macports::portdbpath macports::libpath macports::rsync_server macports::rsync_dir macports::rsync_options
@@ -2280,10 +2328,42 @@
     return 0
 }
 
-# upgrade procedure
-proc macports::upgrade {portname dspec globalvarlist variationslist optionslist {depscachename ""}} {
+# upgrade API wrapper procedure
+# return codes: 0 = success, 1 = general failure, 2 = port name not found in index
+proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {
+    # only installed ports can be upgraded
+    if {![registry::entry_exists_for_name $portname]} {
+        ui_error "$portname is not installed"
+        return 1
+    }
+    if {![string match "" $depscachename]} {
+        upvar $depscachename depscache
+    } else {
+        array set depscache {}
+    }
+    # stop upgrade from being called via mportexec as well
+    set orig_nodeps yes
+    if {![info exists macports::global_options(ports_nodeps)]} {
+        set macports::global_options(ports_nodeps) yes
+        set orig_nodeps no
+    }
+    # filter out implicit variants from the explicitly set/unset variants.
+    set variationslist [mport_filtervariants $variationslist yes]
+    
+    # run the actual upgrade
+    set status [macports::_upgrade $portname $dspec $variationslist $optionslist depscache]
+    
+    if {!$orig_nodeps} {
+        unset -nocomplain macports::global_options(ports_nodeps)
+    }
+    return $status
+}
+
+# main internal upgrade procedure
+proc macports::_upgrade {portname dspec variationslist optionslist {depscachename ""}} {
     global macports::registry.installtype
     global macports::portarchivemode
+    global macports::global_variations
     array set options $optionslist
 
     # Note $variationslist is left alone and so retains the original
@@ -2291,6 +2371,8 @@
     # upgrade; while variations gets existing variants and global variations
     # merged in later on, so it applies only to this port's upgrade
     array set variations $variationslist
+    
+    set globalvarlist [array get macports::global_variations]
 
     if {![string match "" $depscachename]} {
         upvar $depscachename depscache
@@ -2311,8 +2393,8 @@
     }
     # argh! port doesnt exist!
     if {$result == ""} {
-        ui_error "No port $portname found."
-        return 1
+        ui_warn "No port $portname found in the index."
+        return 2
     }
     # fill array with information
     array set portinfo [lindex $result 1]
@@ -2361,7 +2443,11 @@
                 array set portinfo [mportinfo $workername]
                 
                 # upgrade its dependencies first
-                _upgrade_dependencies portinfo depscache globalvarlist variationslist options
+                set status [_upgrade_dependencies portinfo depscache variationslist options]
+                if {$status != 0 && ![ui_isset ports_processall]} {
+                    catch {mportclose $workername}
+                    return $status
+                }
                 # now install it
                 if {[catch {set result [mportexec $workername install]} result]} {
                     global errorInfo
@@ -2389,7 +2475,7 @@
             return 0
         } else {
             ui_error "Checking installed version failed: $result"
-            exit 1
+            return 1
         }
     } else {
         # we'll now take care of upgrading it, so we can add it to the cache
@@ -2463,19 +2549,10 @@
     # remove implicit variants, without printing warnings
     set oldvariantlist [mport_filtervariants $oldvariantlist no]
 
-    # check if the variants are present in $version_in_tree
-    if {[info exists portinfo(variants)]} {
-        set avariants $portinfo(variants)
-    } else {
-        set avariants {}
-    }
-    ui_debug "available variants are : $avariants"
+    # merge in the old variants
     foreach {variation value} $oldvariantlist {
-        if {[lsearch $avariants $variation] != -1} {
-            ui_debug "variant $variation is present in $portname $version_in_tree"
-            if { ![info exists variations($variation)]} {
-                set variations($variation) $value
-            }
+        if { ![info exists variations($variation)]} {
+            set variations($variation) $value
         }
     }
 
@@ -2489,7 +2566,33 @@
     }
 
     ui_debug "new fully merged portvariants: [array get variations]"
+    
+    # at this point we need to check if a different port will be replacing this one
+    if {[info exists portinfo(replaced_by)] && ![info exists options(ports_upgrade_no-replace)]} {
+        ui_debug "$portname is replaced by $portinfo(replaced_by)"
+        if {[catch {mportlookup $portinfo(replaced_by)} result]} {
+            global errorInfo
+            ui_debug "$errorInfo"
+            ui_error "port lookup failed: $result"
+            return 1
+        }
+        if {$result == ""} {
+            ui_error "No port $portinfo(replaced_by) found."
+            return 1
+        }
+        array unset portinfo
+        array set portinfo [lindex $result 1]
+        set newname $portinfo(name)
 
+        set porturl $portinfo(porturl)
+        if {![info exists porturl]} {
+            set porturl file://./
+        }
+        set depscache(port:${newname}) 1
+    } else {
+        set newname $portname
+    }
+
     if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
         global errorInfo
         ui_debug "$errorInfo"
@@ -2499,7 +2602,6 @@
 
     array unset portinfo
     array set portinfo [mportinfo $workername]
-    set portwasopened 1
     set version_in_tree "$portinfo(version)"
     set revision_in_tree "$portinfo(revision)"
     set epoch_in_tree "$portinfo(epoch)"
@@ -2507,7 +2609,11 @@
 
     # first upgrade dependencies
     if {![info exists options(ports_nodeps)]} {
-        _upgrade_dependencies portinfo depscache globalvarlist variationslist options
+        set status [_upgrade_dependencies portinfo depscache variationslist options]
+        if {$status != 0 && ![ui_isset ports_processall]} {
+            catch {mportclose $workername}
+            return $status
+        }
     } else {
         ui_debug "Not following dependencies"
     }
@@ -2517,13 +2623,21 @@
     if { ( [rpm-vercomp $version_installed $version_in_tree] > 0
             || ([rpm-vercomp $version_installed $version_in_tree] == 0
                 && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 ))
-        && ![info exists options(ports_force)] } {
-        ui_debug "No need to upgrade! $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}"
-        if {[info exists portinfo(canonical_active_variants)]
-            && $portinfo(canonical_active_variants) != $oldvariant} {
-            ui_warn "Skipping upgrade since $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variant $oldvariant does not match $portinfo(canonical_active_variants). Specify -f to force upgrade."
-        }
-        if { $epoch_installed >= $epoch_in_tree } {
+        && ![info exists options(ports_upgrade_force)] } {
+        if {$portname != $newname} { 
+            ui_debug "ignoring versions, installing replacement port"
+        } elseif { $epoch_installed < $epoch_in_tree } {
+            set epoch_override 1
+            ui_debug "epoch override ... upgrading!"
+        } elseif {[info exists options(ports_upgrade_enforce-variants)] && $options(ports_upgrade_enforce-variants) eq "yes"
+                  && [info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) != $oldvariant} {
+            ui_debug "variant override ... upgrading!"
+        } else {
+            if {[info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) != $oldvariant} {
+                ui_warn "Skipping upgrade since $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variants \"$oldvariant\" do not match \"$portinfo(canonical_active_variants)\". Use 'upgrade --enforce-variants' to switch to the requested variants."
+            } else {
+                ui_debug "No need to upgrade! $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}"
+            }
             # Check if we have to do dependents
             if {[info exists options(ports_do_dependents)]} {
                 # We do dependents ..
@@ -2536,16 +2650,17 @@
                     foreach dep $deplist {
                         set mpname [lindex $dep 2]
                         if {![llength [array get depscache port:${mpname}]]} {
-                            macports::upgrade $mpname port:${mpname} $globalvarlist $variationslist [array get options] depscache
+                            set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
+                            if {$status != 0 && ![ui_isset ports_processall]} {
+                                catch {mportclose $workername}
+                                return $status
+                            }
                         }
                     }
                 }
             }
             mportclose $workername
             return 0
-        } else {
-            set epoch_override 1
-            ui_debug "epoch override ... upgrading!"
         }
     }
 
@@ -2558,11 +2673,12 @@
     }
 
     # avoid building again unnecessarily
-    if {[info exists options(ports_force)] || $epoch_override == 1
-        || ![registry::entry_exists $portname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
+    if {[info exists options(ports_upgrade_force)] || $epoch_override == 1
+        || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
         if {[catch {set result [mportexec $workername $upgrade_action]} result] || $result != 0} {
-            global errorInfo
-            ui_debug "$errorInfo"
+            if {[info exists ::errorInfo]} {
+                ui_debug "$::errorInfo"
+            }
             ui_error "Unable to upgrade port: $result"
             catch {mportclose $workername}
             return 1
@@ -2590,17 +2706,18 @@
         }
     } else {
         # are we installing an existing version due to force or epoch override?
-        if {[registry::entry_exists $portname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
-             ui_debug "Uninstalling $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)"
+        if {[registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
+            && ([info exists options(ports_upgrade_force)] || $epoch_override == 1)} {
+             ui_debug "Uninstalling $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)"
             # we have to force the uninstall in case of dependents
             set force_cur [info exists options(ports_force)]
             set options(ports_force) yes
             if {$is_dryrun eq "yes"} {
-                ui_msg "Skipping uninstall $portname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
-            } elseif {[catch {portuninstall::uninstall $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
+                ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
+            } elseif {[catch {portuninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
                 global errorInfo
                 ui_debug "$errorInfo"
-                ui_error "Uninstall $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
+                ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
                 catch {mportclose $workername}
                 return 1
             }
@@ -2608,7 +2725,7 @@
                 unset options(ports_force)
             }
             if {$anyactive && $version_in_tree == $version_active && $revision_in_tree == $revision_active
-                && $portinfo(canonical_active_variants) == $variant_active} {
+                && $portinfo(canonical_active_variants) == $variant_active && $portname == $newname} {
                 set anyactive no
             }
         }
@@ -2632,11 +2749,11 @@
     }
 
     if {$is_dryrun eq "yes"} {
-        ui_msg "Skipping activate $portname @${version_in_tree}_${revision_in_tree} (dry run)"
+        ui_msg "Skipping activate $newname @${version_in_tree}_${revision_in_tree} (dry run)"
     } elseif {[catch {set result [mportexec $workername install]} result]} {
         global errorInfo
         ui_debug "$errorInfo"
-        ui_error "Couldn't activate $portname ${version_in_tree}_${revision_in_tree}: $result"
+        ui_error "Couldn't activate $newname ${version_in_tree}_${revision_in_tree}: $result"
         catch {mportclose $workername}
         return 1
     }
@@ -2646,7 +2763,7 @@
             set version [lindex $i 1]
             set revision [lindex $i 2]
             set variant [lindex $i 3]
-            if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants)} {
+            if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants) && $portname == $newname} {
                 continue
             }
             ui_debug "Uninstalling $portname ${version}_${revision}${variant}"
@@ -2655,9 +2772,12 @@
             } elseif {[catch {portuninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} {
                 global errorInfo
                 ui_debug "$errorInfo"
-                ui_error "Uninstall $portname @${version}_${revision}${variant} failed: $result"
-                catch {mportclose $workername}
-                return 1
+                # replaced_by can mean that we try to uninstall all versions of the old port, so handle errors due to dependents
+                if {$result != "Please uninstall the ports that depend on $portname first." && ![ui_isset ports_processall]} {
+                    ui_error "Uninstall $portname @${version}_${revision}${variant} failed: $result"
+                    catch {mportclose $workername}
+                    return 1
+                }
             }
         }
     }
@@ -2668,13 +2788,20 @@
         set options(ports_nodeps) 1
 
         registry::open_dep_map
-        set deplist [registry::list_dependents $portname]
+        set deplist [registry::list_dependents $newname]
+        if {$portname != $newname} {
+            set deplist [concat $deplist [registry::list_dependents $portname]]
+        }
 
         if { [llength deplist] > 0 } {
             foreach dep $deplist {
                 set mpname [lindex $dep 2]
                 if {![llength [array get depscache port:${mpname}]]} {
-                    macports::upgrade $mpname port:${mpname} $globalvarlist $variationslist [array get options] depscache
+                    set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
+                    if {$status != 0 && ![ui_isset ports_processall]} {
+                        catch {mportclose $workername}
+                        return $status
+                    }
                 }
             }
         }
@@ -2683,14 +2810,15 @@
 
     # close the port handle
     mportclose $workername
+    return 0
 }
 
 # upgrade_dependencies: helper proc for upgrade
 # Calls upgrade on each dependency listed in the PortInfo.
 # Uses upvar to access the variables.
-proc macports::_upgrade_dependencies {portinfoname depscachename globalvarlistname variationslistname optionsname} {
+proc macports::_upgrade_dependencies {portinfoname depscachename variationslistname optionsname} {
     upvar $portinfoname portinfo $depscachename depscache \
-          $globalvarlistname globalvarlist $variationslistname variationslist \
+          $variationslistname variationslist \
           $optionsname options
 
     # If we're following dependents, we only want to follow this port's
@@ -2705,21 +2833,25 @@
     set saved_do_dependents [info exists options(ports_do_dependents)]
     unset -nocomplain options(ports_do_dependents)
 
+    set status 0
     # each dep type is upgraded
     foreach dtype {depends_fetch depends_extract depends_build depends_lib depends_run} {
         if {[info exists portinfo($dtype)]} {
             foreach i $portinfo($dtype) {
                 set d [lindex [split $i :] end]
                 if {![llength [array get depscache port:${d}]] && ![llength [array get depscache $i]]} {
-                    upgrade $d $i $globalvarlist $variationslist [array get options] depscache
+                    set status [macports::_upgrade $d $i $variationslist [array get options] depscache]
+                    if {$status != 0 && ![ui_isset ports_processall]} break
                 }
             }
         }
+        if {$status != 0 && ![ui_isset ports_processall]} break
     }
     # restore dependent-following to its former value
     if {$saved_do_dependents} {
         set options(ports_do_dependents) yes
     }
+    return $status
 }
 
 # mportselect

Copied: branches/gsoc09-logging/base/src/macports1.0/sysctl.c (from rev 55505, trunk/base/src/macports1.0/sysctl.c)
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/sysctl.c	                        (rev 0)
+++ branches/gsoc09-logging/base/src/macports1.0/sysctl.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,87 @@
+/*
+ * sysctl.c
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include "sysctl.h"
+
+/*
+ * Read-only wrapper for sysctlbyname(3). Only works for values of type CTLTYPE_INT and CTLTYPE_QUAD.
+ */
+int SysctlCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+    const char error_message[] = "sysctl failed: ";
+    Tcl_Obj *tcl_result;
+    int res;
+    char *name;
+    int value;
+    Tcl_WideInt long_value;
+    size_t len = sizeof(value);
+
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "name");
+        return TCL_ERROR;
+    }
+
+    name = Tcl_GetString(objv[1]);
+    res = sysctlbyname(name, &value, &len, NULL, 0);
+    if (res == -1 && errno != ENOMEM && errno != ERANGE) {
+        tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
+        Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(strerror(errno), -1));
+        Tcl_SetObjResult(interp, tcl_result);
+        return TCL_ERROR;
+    } else if (res == -1) {
+        len = sizeof(long_value);
+        res = sysctlbyname(name, &long_value, &len, NULL, 0);
+        if (res == -1) {
+            tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
+            Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(strerror(errno), -1));
+            Tcl_SetObjResult(interp, tcl_result);
+            return TCL_ERROR;
+        }
+        tcl_result = Tcl_NewWideIntObj(long_value);
+    } else {
+        tcl_result = Tcl_NewIntObj(value);
+    }
+    
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
+}

Copied: branches/gsoc09-logging/base/src/macports1.0/sysctl.h (from rev 55505, trunk/base/src/macports1.0/sysctl.h)
===================================================================
--- branches/gsoc09-logging/base/src/macports1.0/sysctl.h	                        (rev 0)
+++ branches/gsoc09-logging/base/src/macports1.0/sysctl.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,34 @@
+/*
+ * sysctl.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Read-only wrapper for sysctlbyname(3) */
+int SysctlCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);

Modified: branches/gsoc09-logging/base/src/pextlib1.0/Makefile
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/Makefile	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/Makefile	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,9 +1,10 @@
-OBJS=		Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
-		fs-traverse.o strcasecmp.o vercomp.o filemap.o \
-		sha1cmd.o curl.o rmd160cmd.o readline.o uid.o\
-		tracelib.o tty.o get_systemconfiguration_proxies.o\
-		sysctl.o readdir.o pipe.o
-SHLIB_NAME=	Pextlib${SHLIB_SUFFIX}
+OBJS= \
+	Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
+	fs-traverse.o strcasecmp.o vercomp.o filemap.o \
+	sha1cmd.o curl.o rmd160cmd.o readline.o uid.o \
+	tracelib.o tty.o readdir.o pipe.o flock.o \
+	system.o
+SHLIB_NAME= Pextlib${SHLIB_SUFFIX}
 INSTALLDIR= ${DESTDIR}${datadir}/macports/Tcl/pextlib1.0
 
 include ../../Mk/macports.autoconf.mk
@@ -11,9 +12,6 @@
 
 CFLAGS+= ${CURL_CFLAGS} ${MD5_CFLAGS} ${READLINE_CFLAGS}
 LIBS+= ${CURL_LIBS} ${MD5_LIBS} ${READLINE_LIBS}
-ifeq ($(OBJC_RUNTIME), APPLE_RUNTIME)
-   LIBS+= -framework CoreFoundation -framework SystemConfiguration
-endif
 
 .PHONY: test
 

Modified: branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.c
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -52,20 +52,8 @@
 #include <limits.h>
 #endif
 
-#if HAVE_PATHS_H
-#include <paths.h>
-#endif
-
-#ifndef _PATH_DEVNULL
-#define _PATH_DEVNULL   "/dev/null"
-#endif
-
 #include <pwd.h>
 
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -92,6 +80,8 @@
 
 #include <tcl.h>
 
+#include "Pextlib.h"
+
 #include "md5cmd.h"
 #include "sha1cmd.h"
 #include "rmd160cmd.h"
@@ -104,11 +94,11 @@
 #include "uid.h"
 #include "tracelib.h"
 #include "tty.h"
-#include "get_systemconfiguration_proxies.h"
-#include "sysctl.h"
 #include "strsed.h"
 #include "readdir.h"
 #include "pipe.h"
+#include "flock.h"
+#include "system.h"
 
 #if HAVE_CRT_EXTERNS_H
 #include <crt_externs.h>
@@ -127,8 +117,6 @@
 char *fgetln(FILE *stream, size_t *len);
 #endif
 
-#define CBUFSIZ 30
-
 static char *
 ui_escape(const char *source)
 {
@@ -196,322 +184,6 @@
 	return rval;
 }
 
-struct linebuf {
-	size_t len;
-	char *line;
-};
-
-int SystemCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-	char *buf;
-	struct linebuf circbuf[CBUFSIZ];
-	size_t linelen;
-	char *args[4];
-	char *cmdstring;
-	FILE *pdes;
-	int fdset[2], nullfd;
-	int fline, pos, ret;
-	int osetsid = 0;
-	pid_t pid;
-	Tcl_Obj *errbuf;
-	Tcl_Obj *tcl_result;
-	int read_failed, status;
-
-	/* usage: system [-notty] command */
-	if (objc == 2) {
-		cmdstring = Tcl_GetString(objv[1]);
-	} else if (objc == 3) {
-		char *arg = Tcl_GetString(objv[1]);
-		cmdstring = Tcl_GetString(objv[2]);
-
-		if (strcmp(arg, "-notty") == 0) {
-			osetsid = 1;
-		} else {
-			tcl_result = Tcl_NewStringObj("bad option ", -1);
-			Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(arg, -1));
-			Tcl_SetObjResult(interp, tcl_result);
-			return TCL_ERROR;
-		}
-	} else {
-		Tcl_WrongNumArgs(interp, 1, objv, "command");
-		return TCL_ERROR;
-	}
-
-	/*
-	 * Fork a child to run the command, in a popen() like fashion -
-	 * popen() itself is not used because stderr is also desired.
-	 */
-	if (pipe(fdset) != 0) {
-		return TCL_ERROR;
-	}
-
-	pid = fork();
-	switch (pid) {
-	case -1: /* error */
-		return TCL_ERROR;
-		break;
-	case 0: /* child */
-		close(fdset[0]);
-
-		if ((nullfd = open(_PATH_DEVNULL, O_RDONLY)) == -1)
-			_exit(1);
-		dup2(nullfd, STDIN_FILENO);
-		dup2(fdset[1], STDOUT_FILENO);
-		dup2(fdset[1], STDERR_FILENO);
-		/* drop the controlling terminal if requested */
-		if (osetsid) {
-			if (setsid() == -1)
-				_exit(1);
-		}
-		/* XXX ugly string constants */
-		args[0] = "sh";
-		args[1] = "-c";
-		args[2] = cmdstring;
-		args[3] = NULL;
-		execve("/bin/sh", args, environ);
-		_exit(1);
-		break;
-	default: /* parent */
-		break;
-	}
-
-	close(fdset[1]);
-
-	/* read from simulated popen() pipe */
-	read_failed = 0;
-	pos = 0;
-	bzero(circbuf, sizeof(circbuf));
-	pdes = fdopen(fdset[0], "r");
-	while ((buf = fgetln(pdes, &linelen)) != NULL) {
-		char *sbuf;
-		int slen;
-
-		/*
-		 * Allocate enough space to insert a terminating
-		 * '\0' if the line is not terminated with a '\n'
-		 */
-		if (buf[linelen - 1] == '\n')
-			slen = linelen;
-		else
-			slen = linelen + 1;
-
-		if (circbuf[pos].len == 0)
-			sbuf = malloc(slen);
-		else {
-			sbuf = realloc(circbuf[pos].line, slen);
-		}
-
-		if (sbuf == NULL) {
-			read_failed = 1;
-			break;
-		}
-
-		memcpy(sbuf, buf, linelen);
-		/* terminate line with '\0',replacing '\n' if it exists */
-		sbuf[slen - 1] = '\0';
-
-		circbuf[pos].line = sbuf;
-		circbuf[pos].len = slen;
-
-		if (pos++ == CBUFSIZ - 1) {
-			pos = 0;
-		}
-
-		if (ui_info(interp, sbuf) != TCL_OK) {
-			read_failed = 1;
-			break;
-		}
-	}
-	fclose(pdes);
-
-	status = TCL_ERROR;
-
-	if (wait(&ret) == pid && WIFEXITED(ret) && !read_failed) {
-		/* Normal exit, and reading from the pipe didn't fail. */
-		if (WEXITSTATUS(ret) == 0) {
-			status = TCL_OK;
-		} else {
-			/* Copy the contents of the circular buffer to errbuf */
-		  	Tcl_Obj* errorCode;
-			errbuf = Tcl_NewStringObj(NULL, 0);
-			for (fline = pos; pos < fline + CBUFSIZ; pos++) {
-				if (circbuf[pos % CBUFSIZ].len == 0)
-				continue; /* skip empty lines */
-
-				/* Append line, minus trailing NULL */
-				Tcl_AppendToObj(errbuf, circbuf[pos % CBUFSIZ].line,
-						circbuf[pos % CBUFSIZ].len - 1);
-
-				/* Re-add previously stripped newline */
-				Tcl_AppendToObj(errbuf, "\n", 1);
-			}
-
-			/* set errorCode [list CHILDSTATUS <pid> <code>] */
-			errorCode = Tcl_NewListObj(0, NULL);
-			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
-			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(pid));
-			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));
-			Tcl_SetObjErrorCode(interp, errorCode);
-
-			/* set result */
-			tcl_result = Tcl_NewStringObj("shell command \"", -1);
-			Tcl_AppendToObj(tcl_result, cmdstring, -1);
-			Tcl_AppendToObj(tcl_result, "\" returned error ", -1);
-			Tcl_AppendObjToObj(tcl_result, Tcl_NewIntObj(WEXITSTATUS(ret)));
-			Tcl_AppendToObj(tcl_result, "\nCommand output: ", -1);
-			Tcl_AppendObjToObj(tcl_result, errbuf);
-			Tcl_SetObjResult(interp, tcl_result);
-		}
-	}
-
-	/* Cleanup. */
-	close(fdset[0]);
-	for (fline = 0; fline < CBUFSIZ; fline++) {
-		if (circbuf[fline].len != 0) {
-			free(circbuf[fline].line);
-		}
-	}
-
-	return status;
-}
-
-int FlockCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-	static const char errorstr[] = "use one of \"-shared\", \"-exclusive\", or \"-unlock\", and optionally \"-noblock\"";
-	int operation = 0, fd, i, ret;
-	int errnoval = 0;
-	int oshared = 0, oexclusive = 0, ounlock = 0, onoblock = 0;
-#if defined(HAVE_LOCKF) && !defined(HAVE_FLOCK)
-	off_t curpos;
-#endif
-	char *res;
-	Tcl_Channel channel;
-	ClientData handle;
-
-	if (objc < 3 || objc > 4) {
-		Tcl_WrongNumArgs(interp, 1, objv, "channelId switches");
-		return TCL_ERROR;
-	}
-
-    	if ((channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), NULL)) == NULL)
-		return TCL_ERROR;
-
-	if (Tcl_GetChannelHandle(channel, TCL_READABLE|TCL_WRITABLE, &handle) != TCL_OK) {
-		Tcl_SetResult(interp, "error getting channel handle", TCL_STATIC);
-		return TCL_ERROR;
-	}
-	fd = (int)(intptr_t)handle;
-
-	for (i = 2; i < objc; i++) {
-		char *arg = Tcl_GetString(objv[i]);
-		if (!strcmp(arg, "-shared")) {
-		  oshared = 1;
-		} else if (!strcmp(arg, "-exclusive")) {
-		  oexclusive = 1;
-		} else if (!strcmp(arg, "-unlock")) {
-		  ounlock = 1;
-		} else if (!strcmp(arg, "-noblock")) {
-		  onoblock = 1;
-		}
-	}
-
-	/* verify the arguments */
-
-	if((oshared + oexclusive + ounlock) != 1) {
-	  /* only one of the options should have been specified */
-	  Tcl_SetResult(interp, (void *) &errorstr, TCL_STATIC);
-	  return TCL_ERROR;
-	}
-
-	if(onoblock && ounlock) {
-	  /* should not be specified together */
-	  Tcl_SetResult(interp, "-noblock cannot be used with -unlock", TCL_STATIC);
-	  return TCL_ERROR;
-	}
-	  
-#if HAVE_FLOCK
-	/* prefer flock if present */
-	if(oshared) operation |= LOCK_SH;
-
-	if(oexclusive) operation |= LOCK_EX;
-
-	if(ounlock) operation |= LOCK_UN;
-
-	if(onoblock) operation |= LOCK_NB;
-
-	ret = flock(fd, operation);
-	if(ret == -1) {
-	  errnoval = errno;
-	}
-#else
-#if HAVE_LOCKF
-	if(ounlock) operation = F_ULOCK;
-
-	/* lockf semantics don't map to shared locks. */
-	if(oshared || oexclusive) {
-	  if(onoblock) {
-	    operation = F_TLOCK;
-	  } else {
-	    operation = F_LOCK;
-	  }
-	}
-
-	curpos = lseek(fd, 0, SEEK_CUR);
-	if(curpos == -1) {
-		Tcl_SetResult(interp, (void *) "Seek error", TCL_STATIC);
-		return TCL_ERROR;
-	}
-
-	ret = lockf(fd, operation, 0); /* lock entire file */
-
-	curpos = lseek(fd, curpos, SEEK_SET);
-	if(curpos == -1) {
-		Tcl_SetResult(interp, (void *) "Seek error", TCL_STATIC);
-		return TCL_ERROR;
-	}
-
-	if(ret == -1) {
-	  errnoval = errno;
-	  if((oshared || oexclusive)) {
-	    /* map the errno val to what we would expect for flock */
-	    if(onoblock && errnoval == EAGAIN) {
-	      /* on some systems, EAGAIN=EWOULDBLOCK, but lets be safe */
-	      errnoval = EWOULDBLOCK;
-	    } else if(errnoval == EINVAL) {
-	      errnoval = EOPNOTSUPP;
-	    }
-	  }
-	}
-#else
-#error no available locking implementation
-#endif /* HAVE_LOCKF */
-#endif /* HAVE_FLOCK */
-
-	if (ret != 0)
-	{
-		switch(errnoval) {
-			case EAGAIN:
-				res = "EAGAIN";
-				break;
-			case EBADF:
-				res = "EBADF";
-				break;
-			case EINVAL:
-				res = "EINVAL";
-				break;
-			case EOPNOTSUPP:
-				res = "EOPNOTSUPP";
-				break;
-			default:
-				res = strerror(errno);
-				break;
-		}
-		Tcl_SetResult(interp, (void *) res, TCL_STATIC);
-		return TCL_ERROR;
-	}
-	return TCL_OK;
-}
-
 int StrsedCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	char *pattern, *string, *res;
@@ -680,11 +352,11 @@
 	int cur;
 
 	cur = MIN_USABLE_UID;
-	
+
 	while (getpwuid(cur) != NULL) {
 		cur++;
 	}
-	
+
 	tcl_result = Tcl_NewIntObj(cur);
 	Tcl_SetObjResult(interp, tcl_result);
 	return TCL_OK;
@@ -703,7 +375,7 @@
 	while (getgrgid(cur) != NULL) {
 		cur++;
 	}
-	
+
 	tcl_result = Tcl_NewIntObj(cur);
 	Tcl_SetObjResult(interp, tcl_result);
 	return TCL_OK;
@@ -768,15 +440,15 @@
 int CreateSymlinkCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
     char *value, *target;
-    
+
     if (objc != 3) {
         Tcl_WrongNumArgs(interp, 1, objv, "value target");
         return TCL_ERROR;
     }
-    
+
     value = Tcl_GetString(objv[1]);
     target = Tcl_GetString(objv[2]);
-    
+
     if (symlink(value, target) != 0) {
         Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
         return TCL_ERROR;
@@ -800,7 +472,7 @@
     int listLength;
     Tcl_Obj **listArray;
     int loopCounter;
-    
+
     if (objc != 2) {
         Tcl_WrongNumArgs(interp, 1, objv, "name");
         return TCL_ERROR;
@@ -926,11 +598,10 @@
 	Tcl_CreateObjCommand(interp, "symlink", CreateSymlinkCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "unsetenv", UnsetEnvCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "lchown", lchownCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "sysctl", SysctlCmd, NULL, NULL);
-	
+
 	Tcl_CreateObjCommand(interp, "readline", ReadlineCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "rl_history", RLHistoryCmd, NULL, NULL);
-	
+
 	Tcl_CreateObjCommand(interp, "getuid", getuidCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "geteuid", geteuidCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "getgid", getgidCmd, NULL, NULL);
@@ -944,11 +615,10 @@
 	Tcl_CreateObjCommand(interp, "uname_to_gid", uname_to_gidCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "name_to_gid", name_to_gidCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "gid_to_name", gid_to_nameCmd, NULL, NULL);
-	
+
 	Tcl_CreateObjCommand(interp, "tracelib", TracelibCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "isatty", IsattyCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "get_systemconfiguration_proxies", GetSystemConfigurationProxiesCmd, NULL, NULL);
 
 	if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
 		return TCL_ERROR;

Copied: branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.h (from rev 55505, trunk/base/src/pextlib1.0/Pextlib.h)
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.h	                        (rev 0)
+++ branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,33 @@
+/*
+ * Pextlib.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int ui_info(Tcl_Interp *, char *);

Copied: branches/gsoc09-logging/base/src/pextlib1.0/flock.c (from rev 55505, trunk/base/src/pextlib1.0/flock.c)
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/flock.c	                        (rev 0)
+++ branches/gsoc09-logging/base/src/pextlib1.0/flock.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,185 @@
+/*
+ * flock.c
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
+#include <errno.h>
+#include <inttypes.h>
+#include <string.h>
+
+#include <tcl.h>
+
+#include "flock.h"
+
+int
+FlockCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	static const char errorstr[] = "use one of \"-shared\", \"-exclusive\", or \"-unlock\", and optionally \"-noblock\"";
+	int operation = 0, fd, i, ret;
+	int errnoval = 0;
+	int oshared = 0, oexclusive = 0, ounlock = 0, onoblock = 0;
+#if defined(HAVE_LOCKF) && !defined(HAVE_FLOCK)
+	off_t curpos;
+#endif
+	char *res;
+	Tcl_Channel channel;
+	ClientData handle;
+
+	if (objc < 3 || objc > 4) {
+		Tcl_WrongNumArgs(interp, 1, objv, "channelId switches");
+		return TCL_ERROR;
+	}
+
+    	if ((channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), NULL)) == NULL)
+		return TCL_ERROR;
+
+	if (Tcl_GetChannelHandle(channel, TCL_READABLE|TCL_WRITABLE, &handle) != TCL_OK) {
+		Tcl_SetResult(interp, "error getting channel handle", TCL_STATIC);
+		return TCL_ERROR;
+	}
+	fd = (int)(intptr_t)handle;
+
+	for (i = 2; i < objc; i++) {
+		char *arg = Tcl_GetString(objv[i]);
+		if (!strcmp(arg, "-shared")) {
+		  oshared = 1;
+		} else if (!strcmp(arg, "-exclusive")) {
+		  oexclusive = 1;
+		} else if (!strcmp(arg, "-unlock")) {
+		  ounlock = 1;
+		} else if (!strcmp(arg, "-noblock")) {
+		  onoblock = 1;
+		}
+	}
+
+	/* verify the arguments */
+
+	if((oshared + oexclusive + ounlock) != 1) {
+	  /* only one of the options should have been specified */
+	  Tcl_SetResult(interp, (void *) &errorstr, TCL_STATIC);
+	  return TCL_ERROR;
+	}
+
+	if(onoblock && ounlock) {
+	  /* should not be specified together */
+	  Tcl_SetResult(interp, "-noblock cannot be used with -unlock", TCL_STATIC);
+	  return TCL_ERROR;
+	}
+	  
+#if HAVE_FLOCK
+	/* prefer flock if present */
+	if(oshared) operation |= LOCK_SH;
+
+	if(oexclusive) operation |= LOCK_EX;
+
+	if(ounlock) operation |= LOCK_UN;
+
+	if(onoblock) operation |= LOCK_NB;
+
+	ret = flock(fd, operation);
+	if(ret == -1) {
+	  errnoval = errno;
+	}
+#else
+#if HAVE_LOCKF
+	if(ounlock) operation = F_ULOCK;
+
+	/* lockf semantics don't map to shared locks. */
+	if(oshared || oexclusive) {
+	  if(onoblock) {
+	    operation = F_TLOCK;
+	  } else {
+	    operation = F_LOCK;
+	  }
+	}
+
+	curpos = lseek(fd, 0, SEEK_CUR);
+	if(curpos == -1) {
+		Tcl_SetResult(interp, (void *) "Seek error", TCL_STATIC);
+		return TCL_ERROR;
+	}
+
+	ret = lockf(fd, operation, 0); /* lock entire file */
+
+	curpos = lseek(fd, curpos, SEEK_SET);
+	if(curpos == -1) {
+		Tcl_SetResult(interp, (void *) "Seek error", TCL_STATIC);
+		return TCL_ERROR;
+	}
+
+	if(ret == -1) {
+	  errnoval = errno;
+	  if((oshared || oexclusive)) {
+	    /* map the errno val to what we would expect for flock */
+	    if(onoblock && errnoval == EAGAIN) {
+	      /* on some systems, EAGAIN=EWOULDBLOCK, but lets be safe */
+	      errnoval = EWOULDBLOCK;
+	    } else if(errnoval == EINVAL) {
+	      errnoval = EOPNOTSUPP;
+	    }
+	  }
+	}
+#else
+#error no available locking implementation
+#endif /* HAVE_LOCKF */
+#endif /* HAVE_FLOCK */
+
+	if (ret != 0)
+	{
+		switch(errnoval) {
+			case EAGAIN:
+				res = "EAGAIN";
+				break;
+			case EBADF:
+				res = "EBADF";
+				break;
+			case EINVAL:
+				res = "EINVAL";
+				break;
+			case EOPNOTSUPP:
+				res = "EOPNOTSUPP";
+				break;
+			default:
+				res = strerror(errno);
+				break;
+		}
+		Tcl_SetResult(interp, (void *) res, TCL_STATIC);
+		return TCL_ERROR;
+	}
+	return TCL_OK;
+}

Copied: branches/gsoc09-logging/base/src/pextlib1.0/flock.h (from rev 55505, trunk/base/src/pextlib1.0/flock.h)
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/flock.h	                        (rev 0)
+++ branches/gsoc09-logging/base/src/pextlib1.0/flock.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,33 @@
+/*
+ * flock.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int FlockCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);

Deleted: branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.c
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,175 +0,0 @@
-/*
- * get_systemconfiguration_proxies.c
- * $Id$
- *
- * Copyright (c) 2008-2009, The MacPorts Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of MacPorts Team nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "get_systemconfiguration_proxies.h"
-
-
-#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
-#include <CoreFoundation/CoreFoundation.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-int appendProxyInformationForKeys( CFDictionaryRef proxies, Tcl_Obj *tclList, const char *listKey, const void *proxyEnabledKey, const void *proxyHostKey, const void *proxyPortKey );
-char *cfStringToCStringASCII( CFStringRef cfString );
-
-#endif   /* HAVE_FRAMEWORK_SYSTEMCONFIGURATION */
-
-
-/**
- *
- * Query SystemConfiguration for proxy information, returning this
- * information in a Tcl list ready to be 'array set' (key, name pairs).
- *
- * Synopsis: array set someArray get_systemconfiguration_proxies
- */
-int GetSystemConfigurationProxiesCmd( ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED )
-{
-    int cmdResult = TCL_OK;
-#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
-    CFDictionaryRef proxies = SCDynamicStoreCopyProxies( NULL );
-    if( proxies != NULL )
-    {
-        Tcl_Obj *proxyList = Tcl_NewListObj( 0, NULL );
-        if( appendProxyInformationForKeys( proxies, proxyList, "proxy_http", kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort ) == 0 &&
-            appendProxyInformationForKeys( proxies, proxyList, "proxy_https", kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort ) == 0 &&
-            appendProxyInformationForKeys( proxies, proxyList, "proxy_ftp", kSCPropNetProxiesFTPEnable, kSCPropNetProxiesFTPProxy, kSCPropNetProxiesFTPPort ) == 0 )
-        {
-            CFArrayRef exceptionsCFArray = CFDictionaryGetValue( proxies, kSCPropNetProxiesExceptionsList );
-            if( exceptionsCFArray != NULL )
-            {
-                CFStringRef exceptionsCFString = CFStringCreateByCombiningStrings( kCFAllocatorDefault, exceptionsCFArray, CFSTR( "," ) );
-                char *exceptionsString = cfStringToCStringASCII( exceptionsCFString );
-                if( exceptionsString != NULL )
-                {
-                    Tcl_Obj *exceptionsKey = Tcl_NewStringObj( "proxy_skip", 10 );
-                    Tcl_Obj *exceptionsTclString = Tcl_NewStringObj( exceptionsString, strlen( exceptionsString ) );
-                    Tcl_ListObjAppendElement( interp, proxyList, exceptionsKey );
-                    Tcl_ListObjAppendElement( interp, proxyList, exceptionsTclString );
-                    free( exceptionsString );
-                }
-                else
-                    cmdResult = TCL_ERROR;
-                CFRelease( exceptionsCFString );
-            }
-            Tcl_SetObjResult( interp, proxyList );
-        }
-        else
-            cmdResult = TCL_ERROR;
-        CFRelease( proxies );
-    }
-    if( cmdResult == TCL_ERROR )
-        Tcl_SetResult( interp, (char *) Tcl_PosixError( interp ), TCL_STATIC );
-#endif
-   return cmdResult;
-}
-
-
-#ifdef HAVE_FRAMEWORK_SYSTEMCONFIGURATION
-/**
- *
- * Extract the proxy information (given by proxyEnabledKey, proxyHostKey,
- * and proxyPortKey) from the proxies dictionary, then append listKey and
- * the pertinent proxy information to the Tcl list.
- *
- * Returns 0 on success; -1 on failure
- */
-int appendProxyInformationForKeys( CFDictionaryRef proxies, Tcl_Obj *tclList, const char *listKey, const void *proxyEnabledKey, const void *proxyHostKey, const void *proxyPortKey )
-{
-    int result = 0;
-    CFNumberRef proxyEnabledNumber = CFDictionaryGetValue( proxies, proxyEnabledKey );
-    int proxyEnabled = 0;
-    if( proxyEnabledNumber != NULL &&
-        CFNumberGetValue( proxyEnabledNumber, kCFNumberIntType, &proxyEnabled ) &&
-        proxyEnabled )
-    {
-        CFStringRef proxyHostString = CFDictionaryGetValue( proxies, proxyHostKey );
-        char *hostname = NULL;
-        if( proxyHostString != NULL &&
-            ( hostname = cfStringToCStringASCII( proxyHostString ) ) != NULL )
-        {
-            CFNumberRef proxyPortNumber = CFDictionaryGetValue( proxies, proxyPortKey );
-            int proxyPort = 0;
-            if( proxyPortNumber != NULL &&
-                CFNumberGetValue( proxyPortNumber, kCFNumberIntType, &proxyPort ) &&
-                proxyPort > 0 )
-            {
-                /*
-                 * We are adding :<port>\0 to the end, which is up to 7
-                 * bytes additional (up to 5 for the port)
-                 */
-                int newLength = strlen( hostname ) + 7;
-                char *hostnameAndPort = calloc( 1, newLength );
-                if( hostnameAndPort != NULL )
-                {
-                    Tcl_Obj *hostnameAndPortTcl;
-                    Tcl_Obj *listKeyTcl = Tcl_NewStringObj( listKey, strlen( listKey ) );
-                    Tcl_ListObjAppendElement( NULL, tclList, listKeyTcl );
-                    snprintf( hostnameAndPort, newLength, "%s:%d", hostname, proxyPort );
-                    hostnameAndPortTcl = Tcl_NewStringObj( hostnameAndPort, strlen( hostnameAndPort ) );
-                    Tcl_ListObjAppendElement( NULL, tclList, hostnameAndPortTcl );
-                    free( hostnameAndPort );
-                }
-                else
-                    result = -1;
-            }
-            else
-                result = -1;
-        }
-        else
-            result = -1;
-    }
-
-    return result;
-}
-
-
-/**
- *
- * Convert a CFStringRef to an ASCII-encoded C string; be sure to free()
- * the returned string when done with it.
- */
-char *cfStringToCStringASCII( CFStringRef cfString )
-{
-    int strLen = CFStringGetMaximumSizeForEncoding( CFStringGetLength( cfString ), kCFStringEncodingASCII ) + 1;
-    char *cString = calloc( 1, strLen );
-    if( cString != NULL )
-        CFStringGetCString( cfString, cString, strLen, kCFStringEncodingASCII );
-
-   return cString;
-}
-
-#endif
-

Deleted: branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.h
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.h	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/get_systemconfiguration_proxies.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,41 +0,0 @@
-/* 
- * get_systemconfiguration_proxies.h 
- * $Id$ 
- * 
- * Copyright (c) 2008-2009, The MacPorts Project. 
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- * 3. Neither the name of MacPorts Team nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
- *  
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE. 
- */ 
-
-#ifndef _GETSYSTEMCONFIGURATIONPROXIES_H
-#define _GETSYSTEMCONFIGURATIONPROXIES_H
-
-#include <tcl.h> 
-
-int GetSystemConfigurationProxiesCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ); 
-
-#endif   /* _GETSYSTEMCONFIGURATIONPROXIES_H */
-

Modified: branches/gsoc09-logging/base/src/pextlib1.0/strsed.h
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/strsed.h	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/strsed.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1 +1,33 @@
+/*
+ * strsed.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 char *strsed(char *, char *, int *);


Property changes on: branches/gsoc09-logging/base/src/pextlib1.0/strsed.h
___________________________________________________________________
Added: svn:keywords
   + Id

Deleted: branches/gsoc09-logging/base/src/pextlib1.0/sysctl.c
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/sysctl.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/sysctl.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,75 +0,0 @@
-/*
- * sysctl.c
- * $Id$
- *
- * Copyright (c) 2009 The MacPorts Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The MacPorts Project nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <tcl.h>
-
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#include "sysctl.h"
-
-/*
- * Read-only wrapper for sysctlbyname(3). Only works for values of type CTLTYPE_INT.
- */
-int SysctlCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
-{
-    const char error_message[] = "sysctl failed: ";
-    Tcl_Obj *tcl_result;
-    int res;
-    char *name;
-    int value;
-    size_t len = sizeof(value);
-
-    if (objc != 2) {
-        Tcl_WrongNumArgs(interp, 1, objv, "name");
-        return TCL_ERROR;
-    }
-
-    name = Tcl_GetString(objv[1]);
-    res = sysctlbyname(name, &value, &len, NULL, 0);
-    if (res == -1) {
-        tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
-        Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(strerror(errno), -1));
-        Tcl_SetObjResult(interp, tcl_result);
-        return TCL_ERROR;
-    }
-
-    tcl_result = Tcl_NewIntObj(value);
-    Tcl_SetObjResult(interp, tcl_result);
-    return TCL_OK;
-}

Deleted: branches/gsoc09-logging/base/src/pextlib1.0/sysctl.h
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/sysctl.h	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/sysctl.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -1,34 +0,0 @@
-/*
- * sysctl.h
- * $Id$
- *
- * Copyright (c) 2009 The MacPorts Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The MacPorts Project nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Read-only wrapper for sysctlbyname(3) */
-int SysctlCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);

Copied: branches/gsoc09-logging/base/src/pextlib1.0/system.c (from rev 55505, trunk/base/src/pextlib1.0/system.c)
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/system.c	                        (rev 0)
+++ branches/gsoc09-logging/base/src/pextlib1.0/system.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,241 @@
+/*
+ * system.c
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "system.h"
+#include "Pextlib.h"
+
+#if HAVE_CRT_EXTERNS_H
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+extern char **environ;
+#endif
+
+#ifndef _PATH_DEVNULL
+#define _PATH_DEVNULL "/dev/null"
+#endif
+
+#define CBUFSIZ 30
+
+struct linebuf {
+	size_t len;
+	char *line;
+};
+
+int SystemCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	char *buf;
+	struct linebuf circbuf[CBUFSIZ];
+	size_t linelen;
+	char *args[4];
+	char *cmdstring;
+	FILE *pdes;
+	int fdset[2], nullfd;
+	int fline, pos, ret;
+	int osetsid = 0;
+	pid_t pid;
+	Tcl_Obj *errbuf;
+	Tcl_Obj *tcl_result;
+	int read_failed, status;
+
+	/* usage: system [-notty] command */
+	if (objc == 2) {
+		cmdstring = Tcl_GetString(objv[1]);
+	} else if (objc == 3) {
+		char *arg = Tcl_GetString(objv[1]);
+		cmdstring = Tcl_GetString(objv[2]);
+
+		if (strcmp(arg, "-notty") == 0) {
+			osetsid = 1;
+		} else {
+			tcl_result = Tcl_NewStringObj("bad option ", -1);
+			Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(arg, -1));
+			Tcl_SetObjResult(interp, tcl_result);
+			return TCL_ERROR;
+		}
+	} else {
+		Tcl_WrongNumArgs(interp, 1, objv, "command");
+		return TCL_ERROR;
+	}
+
+	/*
+	 * Fork a child to run the command, in a popen() like fashion -
+	 * popen() itself is not used because stderr is also desired.
+	 */
+	if (pipe(fdset) != 0) {
+		return TCL_ERROR;
+	}
+
+	pid = fork();
+	switch (pid) {
+	case -1: /* error */
+		return TCL_ERROR;
+		break;
+	case 0: /* child */
+		close(fdset[0]);
+
+		if ((nullfd = open(_PATH_DEVNULL, O_RDONLY)) == -1)
+			_exit(1);
+		dup2(nullfd, STDIN_FILENO);
+		dup2(fdset[1], STDOUT_FILENO);
+		dup2(fdset[1], STDERR_FILENO);
+		/* drop the controlling terminal if requested */
+		if (osetsid) {
+			if (setsid() == -1)
+				_exit(1);
+		}
+		/* XXX ugly string constants */
+		args[0] = "sh";
+		args[1] = "-c";
+		args[2] = cmdstring;
+		args[3] = NULL;
+		execve("/bin/sh", args, environ);
+		_exit(1);
+		break;
+	default: /* parent */
+		break;
+	}
+
+	close(fdset[1]);
+
+	/* read from simulated popen() pipe */
+	read_failed = 0;
+	pos = 0;
+	bzero(circbuf, sizeof(circbuf));
+	pdes = fdopen(fdset[0], "r");
+	while ((buf = fgetln(pdes, &linelen)) != NULL) {
+		char *sbuf;
+		int slen;
+
+		/*
+		 * Allocate enough space to insert a terminating
+		 * '\0' if the line is not terminated with a '\n'
+		 */
+		if (buf[linelen - 1] == '\n')
+			slen = linelen;
+		else
+			slen = linelen + 1;
+
+		if (circbuf[pos].len == 0)
+			sbuf = malloc(slen);
+		else {
+			sbuf = realloc(circbuf[pos].line, slen);
+		}
+
+		if (sbuf == NULL) {
+			read_failed = 1;
+			break;
+		}
+
+		memcpy(sbuf, buf, linelen);
+		/* terminate line with '\0',replacing '\n' if it exists */
+		sbuf[slen - 1] = '\0';
+
+		circbuf[pos].line = sbuf;
+		circbuf[pos].len = slen;
+
+		if (pos++ == CBUFSIZ - 1) {
+			pos = 0;
+		}
+
+		if (ui_info(interp, sbuf) != TCL_OK) {
+			read_failed = 1;
+			break;
+		}
+	}
+	fclose(pdes);
+
+	status = TCL_ERROR;
+
+	if (wait(&ret) == pid && WIFEXITED(ret) && !read_failed) {
+		/* Normal exit, and reading from the pipe didn't fail. */
+		if (WEXITSTATUS(ret) == 0) {
+			status = TCL_OK;
+		} else {
+			/* Copy the contents of the circular buffer to errbuf */
+		  	Tcl_Obj* errorCode;
+			errbuf = Tcl_NewStringObj(NULL, 0);
+			for (fline = pos; pos < fline + CBUFSIZ; pos++) {
+				if (circbuf[pos % CBUFSIZ].len == 0)
+				continue; /* skip empty lines */
+
+				/* Append line, minus trailing NULL */
+				Tcl_AppendToObj(errbuf, circbuf[pos % CBUFSIZ].line,
+						circbuf[pos % CBUFSIZ].len - 1);
+
+				/* Re-add previously stripped newline */
+				Tcl_AppendToObj(errbuf, "\n", 1);
+			}
+
+			/* set errorCode [list CHILDSTATUS <pid> <code>] */
+			errorCode = Tcl_NewListObj(0, NULL);
+			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
+			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(pid));
+			Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));
+			Tcl_SetObjErrorCode(interp, errorCode);
+
+			/* set result */
+			tcl_result = Tcl_NewStringObj("shell command \"", -1);
+			Tcl_AppendToObj(tcl_result, cmdstring, -1);
+			Tcl_AppendToObj(tcl_result, "\" returned error ", -1);
+			Tcl_AppendObjToObj(tcl_result, Tcl_NewIntObj(WEXITSTATUS(ret)));
+			Tcl_AppendToObj(tcl_result, "\nCommand output: ", -1);
+			Tcl_AppendObjToObj(tcl_result, errbuf);
+			Tcl_SetObjResult(interp, tcl_result);
+		}
+	}
+
+	/* Cleanup. */
+	close(fdset[0]);
+	for (fline = 0; fline < CBUFSIZ; fline++) {
+		if (circbuf[fline].len != 0) {
+			free(circbuf[fline].line);
+		}
+	}
+
+	return status;
+}

Copied: branches/gsoc09-logging/base/src/pextlib1.0/system.h (from rev 55505, trunk/base/src/pextlib1.0/system.h)
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/system.h	                        (rev 0)
+++ branches/gsoc09-logging/base/src/pextlib1.0/system.h	2009-08-12 12:26:30 UTC (rev 55506)
@@ -0,0 +1,33 @@
+/*
+ * system.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The MacPorts Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int SystemCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);

Modified: branches/gsoc09-logging/base/src/pextlib1.0/xinstall.c
===================================================================
--- branches/gsoc09-logging/base/src/pextlib1.0/xinstall.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/pextlib1.0/xinstall.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -70,6 +70,8 @@
 
 #include <tcl.h>
 
+#include "Pextlib.h"
+
 #if HAVE_PATHS_H
 #include <paths.h>
 #endif
@@ -139,8 +141,6 @@
 static int	trymmap(int);
 static void	usage(Tcl_Interp *interp);
 
-extern int	ui_info(Tcl_Interp *interp, char *mesg);
-
 int
 InstallCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {

Modified: branches/gsoc09-logging/base/src/port/port-help.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port/port-help.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port/port-help.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -42,10 +42,6 @@
 --all         Removes everything from above
 }
 
-set porthelp(compact) {
-Compact the given ports (unimplemented)
-}
-
 set porthelp(configure) {
 Configure the given ports
 }
@@ -273,10 +269,6 @@
 Unarchive the given ports
 }
 
-set porthelp(uncompact) {
-Uncompact a port (unimplemented)
-}
-
 set porthelp(uninstall) {
 Uninstall the given ports
 }
@@ -285,10 +277,17 @@
 
 set porthelp(upgrade) {
 Upgrades the given ports to the latest version. Respects global options
--n, -R, -u, and -f (see the port man page).  Note that in selecting variants
+-n, -R, and -u (see the port man page).  Note that in selecting variants
 to use in the upgraded build of the port, the order of precedence is variants
 specified on the command line, then variants active in the latest installed
 version of the port, then the variants.conf file.
+
+--force             Ignore circumstances that would normally cause ports to be
+                    skipped (e.g. not outdated).
+--enforce-variants  If the installed variants do not match those requested,
+                    upgrade even if the port is not outdated.
+--no-replace        Do not replace one port with another according to the
+                    replaced_by field
 }
 
 set porthelp(url) {

Modified: branches/gsoc09-logging/base/src/port/port.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port/port.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port/port.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -259,6 +259,7 @@
     #   name
     #   version         (version_revision)
     #   variants array  (variant=>+-)
+    #   requested_variants array  (variant=>+-)
     #   options array   (key=>value)
     #   fullname        (name/version_revision+-variants)
 
@@ -267,6 +268,7 @@
     if {![info exists port(name)]}      { set port(name) "" }
     if {![info exists port(version)]}   { set port(version) "" }
     if {![info exists port(variants)]}  { set port(variants) "" }
+    if {![info exists port(requested_variants)]}  { set port(requested_variants) "" }
     if {![info exists port(options)]}   { set port(options) [array get global_options] }
 
     # If neither portname nor url is specified, then default to the current port
@@ -299,7 +301,8 @@
     foreach portentry $ports {
         array set port $portentry
         if ([info exists overrides(version)])   { set port(version) $overrides(version) }
-        if ([info exists overrides(variants)])  { set port(variants) $overrides(variants)   }
+        if ([info exists overrides(variants)])  { set port(variants) $overrides(variants) }
+        if ([info exists overrides(requested_variants)])  { set port(requested_variants) $overrides(requested_variants) }
         if ([info exists overrides(options)])   { set port(options) $overrides(options) }
         add_to_portlist portlist [array get port]
     }
@@ -363,6 +366,8 @@
             set portversion $portspec(version)
             array unset variations
             array set variations $portspec(variants)
+            array unset requested_variations
+            array set requested_variations $portspec(requested_variants)
             array unset options
             array set options $portspec(options)
         }
@@ -879,7 +884,7 @@
     set url ""
     set name ""
     set version ""
-    array unset variants
+    array unset requested_variants
     array unset options
     
     set token [lookahead]
@@ -973,11 +978,12 @@
             advance
             set name [url_to_portname $token]
             if {$name != ""} {
-                parsePortSpec version variants options
+                parsePortSpec version requested_variants options
                 add_to_portlist reslist [list url $token \
                   name $name \
                   version $version \
-                  variants [array get variants] \
+                  requested_variants [array get requested_variants] \
+                  variants [array get requested_variants] \
                   options [array get options]]
             } else {
                 ui_error "Can't open URL '$token' as a port"
@@ -988,11 +994,12 @@
 
         default             { # Treat anything else as a portspec (portname, version, variants, options
             # or some combination thereof).
-            parseFullPortSpec url name version variants options
+            parseFullPortSpec url name version requested_variants options
             add_to_portlist reslist [list url $url \
               name $name \
               version $version \
-              variants [array get variants] \
+              requested_variants [array get requested_variants] \
+              variants [array get requested_variants] \
               options [array get options]]
             set el 1
         }
@@ -1012,7 +1019,12 @@
     
     array unset overrides
     if {$version != ""} { set overrides(version) $version }
-    if {[array size variants]} { set overrides(variants) [array get variants] }
+    if {[array size variants]} {
+        # we always record the requested variants separately,
+        # but requested ones always override existing ones
+        set overrides(requested_variants) [array get variants]
+        set overrides(variants) [array get variants]
+    }
     if {[array size options]} { set overrides(options) [array get options] }
 
     add_ports_to_portlist reslist $ports [array get overrides]
@@ -1331,6 +1343,7 @@
             return 1
         }
     }
+    return 0
 }
 
 
@@ -1566,11 +1579,13 @@
             maintainers Maintainers
             license     License
             conflicts   "Conflicts with"
+            replaced_by "Replaced by"
         }
 
         # Wrap-length map for pretty printing
         array set pretty_wrap {
             heading 0
+            replaced_by 22
             variants 22
             depends_fetch 22
             depends_extract 22
@@ -1634,7 +1649,9 @@
         set opts_todo [array names options ports_info_*]
         set fields_tried {}
         if {![llength $opts_todo]} {
-            set opts_todo {ports_info_heading ports_info_variants 
+            set opts_todo {ports_info_heading
+                ports_info_replaced_by
+                ports_info_variants 
                 ports_info_skip_line
                 ports_info_long_description ports_info_homepage 
                 ports_info_skip_line ports_info_depends_fetch
@@ -1830,6 +1847,7 @@
         return 1
     }
 
+    set status 0
     foreachport $portlist {
         if {$porturl eq ""} {
             # Look up the port.
@@ -1847,6 +1865,16 @@
             array set portinfo [lindex $result 1]
             set porturl $portinfo(porturl)
         }
+        
+        # Add any global_variations to the variations
+        # specified for the port
+        array unset merged_variations
+        array set merged_variations [array get variations]
+        foreach { variation value } [array get global_variations] { 
+            if { ![info exists merged_variations($variation)] } { 
+                set merged_variations($variation) $value 
+            } 
+        }
 
         # Open the Portfile associated with this port.
         if {[catch {set mport [mportopen $porturl [array get options] \
@@ -1880,6 +1908,7 @@
             }
         }
     }
+    return $status
 }
 
 
@@ -2064,31 +2093,22 @@
 
 
 proc action_upgrade { action portlist opts } {
-    global global_variations
     if {[require_portlist portlist]} {
         return 1
     }
     # shared depscache for all ports in the list
     array set depscache {}
+    set status 0
     foreachport $portlist {
-        if {![registry::entry_exists_for_name $portname]} {
-            ui_error "$portname is not installed"
-            return 1
-        }
         if {![info exists depscache(port:$portname)]} {
-            # Global variations will have to be merged into the specified
-            # variations, but perhaps after the installed variations are
-            # merged. So we pass them into upgrade.
-            
-            # First filter out implicit variants from the explicitly set/unset variants.
-            set global_variations_list [mport_filtervariants [array get global_variations] yes]
-            set variations_list [mport_filtervariants [array get variations] yes]
-            
-            macports::upgrade $portname "port:$portname" $global_variations_list $variations_list [array get options] depscache
+            set status [macports::upgrade $portname "port:$portname" [array get requested_variations] [array get options] depscache]
+            if {$status != 0 && ![macports::ui_isset ports_processall]} {
+                return $status
+            }
         }
     }
 
-    return 0
+    return $status
 }
 
 
@@ -2113,40 +2133,6 @@
 }
 
 
-proc action_compact { action portlist opts } {
-    set status 0
-    if {[require_portlist portlist]} {
-        return 1
-    }
-    foreachport $portlist {
-        if { [catch {portimage::compact $portname [composite_version $portversion [array get variations]]} result] } {
-            global errorInfo
-            ui_debug "$errorInfo"
-            break_softcontinue "port compact failed: $result" 1 status
-        }
-    }
-
-    return $status
-}
-
-
-proc action_uncompact { action portlist opts } {
-    set status 0
-    if {[require_portlist portlist]} {
-        return 1
-    }
-    foreachport $portlist {
-        if { [catch {portimage::uncompact $portname [composite_version $portversion [array get variations]]} result] } {
-            global errorInfo
-            ui_debug "$errorInfo"
-            break_softcontinue "port uncompact failed: $result" 1 status
-        }
-    }
-    
-    return $status
-}
-
-
 proc action_dependents { action portlist opts } {
     if {[require_portlist portlist]} {
         return 1
@@ -2155,6 +2141,7 @@
 
     registry::open_dep_map
 
+    set status 0
     foreachport $portlist {
         set composite_version [composite_version $portversion [array get variations]]
         if { [catch {set ilist [registry::installed $portname $composite_version]} result] } {
@@ -2182,7 +2169,7 @@
             ui_msg "$portname has no dependents!"
         }
     }
-    return 0
+    return $status
 }
 
 
@@ -2200,6 +2187,10 @@
     }
 
     foreachport $portlist {
+        if {![registry::entry_exists_for_name $portname]} {
+            ui_info "$portname is already uninstalled"
+            continue
+        }
         if { [catch {portuninstall::uninstall $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
             global errorInfo
             ui_debug "$errorInfo"
@@ -2207,7 +2198,7 @@
         }
     }
 
-    return 0
+    return $status
 }
 
 
@@ -2331,6 +2322,10 @@
             array set portinfo [lindex $res 1]
             
             # Get information about latest available version and revision
+            if {![info exists portinfo(version)]} {
+                ui_warn "$portname has no version field"
+                continue
+            }
             set latest_version $portinfo(version)
             set latest_revision 0
             if {[info exists portinfo(revision)] && $portinfo(revision) > 0} { 
@@ -2948,12 +2943,13 @@
             set porturl $portinfo(porturl)
         }
         
-        # Add any global_variations to the variations
-        # specified for the port
-        foreach { variation value } [array get global_variations] {
-            if { ![info exists variations($variation)] } {
-                set variations($variation) $value
-            }
+        # use existing variants iff none were explicitly requested
+        if {[array get requested_variations] == "" && [array get variations] != ""} {
+            array unset requested_variations
+            array set requested_variations [array get variations]
+            set filtered_variations [mport_filtervariants [array get variations] no]
+        } else {
+            set filtered_variations [mport_filtervariants [array get requested_variations] yes]
         }
         # Filter out implicit variants from the explicitly set/unset variants.
         # Except we need to keep them for some targets to work right...
@@ -2961,18 +2957,25 @@
             distfiles -
             mirror {}
             default {
-                set variationslist [mport_filtervariants [array get variations] yes]
-                array unset variations
-                array set variations $variationslist
+                array unset requested_variations
+                array set requested_variations $filtered_variations
             }
         }
+        
+        # Add any global_variations to the variations
+        # specified for the port
+        foreach { variation value } [array get global_variations] {
+            if { ![info exists requested_variations($variation)] } {
+                set requested_variations($variation) $value
+            }
+        }
 
         # If version was specified, save it as a version glob for use
         # in port actions (e.g. clean).
         if {[string length $portversion]} {
             set options(ports_version_glob) $portversion
         }
-        if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
+        if {[catch {set workername [mportopen $porturl [array get options] [array get requested_variations]]} result]} {
             global errorInfo
             ui_debug "$errorInfo"
             break_softcontinue "Unable to open port: $result" 1 status
@@ -3082,8 +3085,6 @@
     \
     version     [list action_version        [action_args_const none]] \
     platform    [list action_platform       [action_args_const none]] \
-    compact     [list action_compact        [action_args_const ports]] \
-    uncompact   [list action_uncompact      [action_args_const ports]] \
     \
     uninstall   [list action_uninstall      [action_args_const ports]] \
     \
@@ -3185,7 +3186,7 @@
                  depends description epoch fullname heading homepage index license
                  line long_description
                  maintainer maintainers name platform platforms portdir pretty
-                 revision variant variants version}
+                 replaced_by revision variant variants version}
     search      {case-sensitive category categories depends_fetch
                  depends_extract depends_build depends_lib depends_run
                  depends description epoch exact glob homepage line
@@ -3199,6 +3200,7 @@
     lint        {nitpick}
     select      {list set show}
     log         {{phase 1} {verbosity 1}}
+    upgrade     {force enforce-variants no-replace}
 }
 
 global cmd_implied_options
@@ -3311,11 +3313,6 @@
                         # Ignore errors while processing within a command
                         set ui_options(ports_processall) yes
                     }
-                    x {
-                        # Exit with error from any command while in batch/interactive mode
-                        set ui_options(ports_exit) yes
-                    }
-
                     f {
                         set global_options(ports_force) yes
                     }
@@ -3387,7 +3384,7 @@
     set action_status 0
 
     # Process an action if there is one
-    while {$action_status == 0 && [moreargs]} {
+    while {($action_status == 0 || [macports::ui_isset ports_processall]) && [moreargs]} {
         set action [lookahead]
         advance
         
@@ -3470,11 +3467,6 @@
 
         # semaphore to exit
         if {$action_status == -999} break
-
-        # If we're not in exit mode then ignore the status from the command
-        if { ![macports::ui_isset ports_exit] } {
-            set action_status 0
-        }
     }
     
     return $action_status
@@ -3597,7 +3589,7 @@
 
     # Main command loop
     set exit_status 0
-    while { $exit_status == 0 } {
+    while { $exit_status == 0 || [macports::ui_isset ports_processall] } {
 
         # Calculate our prompt
         if { $noisy } {
@@ -3617,11 +3609,9 @@
         set exit_status [process_cmd $line]
         
         # Check for semaphore to exit
-        if {$exit_status == -999} break
-        
-        # Ignore status unless we're in error-exit mode
-        if { ![macports::ui_isset ports_exit] } {
+        if {$exit_status == -999} {
             set exit_status 0
+            break
         }
     }
 
@@ -3663,16 +3653,10 @@
             close $in
         }
 
-        # Check for semaphore to exit
-        if {$exit_status == -999} {
-            set exit_status 0
-            break
+        # Exit on first failure unless -p was given
+        if {$exit_status != 0 && ![macports::ui_isset ports_processall]} {
+            return $exit_status
         }
-
-        # Ignore status unless we're in error-exit mode
-        if { ![macports::ui_isset ports_exit] } {
-            set exit_status 0
-        }
     }
 
     return $exit_status
@@ -3758,16 +3742,11 @@
 if { [llength $remaining_args] > 0 } {
 
     # If there are remaining arguments, process those as a command
-
-    # Exit immediately, by default, unless we're going to be processing command files
-    if {![info exists ui_options(ports_commandfiles)]} {
-        set ui_options(ports_exit) yes
-    }
     set exit_status [process_cmd $remaining_args]
 }
 
 # Process any prescribed command files, including standard input
-if { $exit_status == 0 && [info exists ui_options(ports_commandfiles)] } {
+if { ($exit_status == 0 || [macports::ui_isset ports_processall]) && [info exists ui_options(ports_commandfiles)] } {
     set exit_status [process_command_files $ui_options(ports_commandfiles)]
 }
 

Modified: branches/gsoc09-logging/base/src/port/portindex.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port/portindex.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port/portindex.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -60,15 +60,15 @@
             set portinfo(portarchive) [file join [file dirname $portdir] [file tail $portdir]].tgz
             cd [file join $directory [file dirname $portinfo(portdir)]]
             puts "Archiving port $portinfo(name) to [file join $outdir $portinfo(portarchive)]"
-            set tar [findBinary tar $macports::autoconf::tar_path]
-            set gzip [findBinary gzip $macports::autoconf::gzip_path]
+            set tar [macports::findBinary tar $macports::autoconf::tar_path]
+            set gzip [macports::findBinary gzip $macports::autoconf::gzip_path]
             if {[catch {exec $tar -cf - [file tail $portdir] | $gzip -c >[file join $outdir $portinfo(portarchive)]} result]} {
                 puts stderr "Failed to create port archive $portinfo(portarchive): $result"
                 exit 1
             }
         }
 
-        set keepkeys {categories depends_fetch depends_extract depends_build depends_lib depends_run description epoch homepage long_description maintainers name platforms revision variants version portdir}
+        set keepkeys {categories depends_fetch depends_extract depends_build depends_lib depends_run description epoch homepage long_description maintainers name platforms revision variants version portdir portarchive replaced_by}
         foreach availkey [array names portinfo] {
             if {[lsearch -exact ${keepkeys} $availkey] == -1} {
                 unset portinfo($availkey)

Modified: branches/gsoc09-logging/base/src/port1.0/portbuild.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portbuild.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portbuild.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -119,11 +119,14 @@
     set jobs $buildmakejobs
     # if set to '0', use the number of cores for the number of jobs
     if {$jobs == 0} {
-        if {[catch {set jobs [sysctl hw.activecpu]}]} {
+        if {[catch {set jobs [sysctl hw.activecpu]}] || [catch {set memsize [sysctl hw.memsize]}]} {
             set jobs 2
             ui_warn "failed to determine the number of available CPUs (probably not supported on this platform)"
             ui_warn "defaulting to $jobs jobs, consider setting buildmakejobs to a nonzero value in macports.conf"
         }
+        if {$jobs > $memsize / 1000000000 + 1} {
+            set jobs [expr $memsize / 1000000000 + 1]
+        }
     }
     if {![string is integer -strict $jobs] || $jobs <= 1} {
         set jobs 1

Modified: branches/gsoc09-logging/base/src/port1.0/portclean.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portclean.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portclean.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -245,7 +245,7 @@
             set file [file tail $path]
             # Make sure file is truly a port archive file, and not
             # and accidental match with some other file that might exist.
-            if {[regexp "^$name-\[-_a-zA-Z0-9\.\]+_\[0-9\]*\[+-_a-zA-Z0-9\]*\[\.\][option os.arch]\[\.\]\[a-z\]+\$" $file]} {
+            if {[regexp "^$name-\[-_a-zA-Z0-9\.\]+_\[0-9\]*\[+-_a-zA-Z0-9\]*\[\.\][option os.arch]\[\.\]\[a-z2\]+\$" $file]} {
                 if {[file isfile $path]} {
                     ui_debug "Removing archive: $path"
                     if {[catch {delete $path} result]} {

Modified: branches/gsoc09-logging/base/src/port1.0/portconfigure.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portconfigure.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portconfigure.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -62,14 +62,56 @@
 option_proc use_autoconf    portconfigure::set_configure_type
 option_proc use_xmkmf       portconfigure::set_configure_type
 
+option_proc autoreconf.cmd  portconfigure::set_configure_type
+option_proc automake.cmd    portconfigure::set_configure_type
+option_proc autoconf.cmd    portconfigure::set_configure_type
+option_proc xmkmf.cmd       portconfigure::set_configure_type
+
+##
+# Local helper proc
+proc portconfigure::add_build_dep { type dep } {
+    global ${type}.cmd option_defaults
+
+    if {![info exists ${type}.cmd] || (
+        ([info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == $option_defaults(${type}.cmd)) ||
+        (![info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == "${type}")
+        )} {
+            eval depends_build-append $dep
+    }
+}
+
+##
+# Adds dependencies for the binaries which will be called, but only if it is
+# the default. If .cmd was overwritten the port has to care for deps itself.
 proc portconfigure::set_configure_type {option action args} {
-    if {[string equal ${action} "set"] && [tbool args]} {
+    global autoreconf.cmd automake.cmd autoconf.cmd xmkmf.cmd
+
+    array set configure_map {
+        autoconf    {port:autoconf port:automake port:libtool}
+        xmkmf       port:imake
+    }
+
+    if {[string equal ${action} "set"]} {
         switch $option {
+            autoreconf.cmd  -
+            automake.cmd    -
+            autoconf.cmd {
+                eval depends_build-delete $configure_map(autoconf)
+            }
+            xmkmf.cmd {
+                depends_build-delete $configure_map(xmkmf)
+            }
             use_xmkmf {
-                depends_build-append port:imake
+                if {[tbool args]} {
+                    depends_build-append $configure_map(xmkmf)
+                }
             }
             default {
-                depends_build-append port:autoconf port:automake port:libtool
+                # strip "use_"
+                set type [string range $option 4 end]
+                if {[tbool args]} {
+                    add_build_dep $type $configure_map(autoconf)
+                }
             }
         }
     }
@@ -109,9 +151,12 @@
 default configure.pkg_config        {}
 default configure.pkg_config_path   {}
 
-options configure.build_arch configure.archflags
+options configure.build_arch
 default configure.build_arch {${build_arch}}
-default configure.archflags  {[portconfigure::configure_get_archflags]}
+foreach tool {cc cxx objc f77 f90 fc} {
+    options configure.${tool}_archflags
+    default configure.${tool}_archflags  "\[portconfigure::configure_get_archflags $tool\]"
+}
 
 options configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags
 default configure.universal_archs       {${universal_archs}}
@@ -139,10 +184,7 @@
 set_ui_prefix
 
 proc portconfigure::configure_start {args} {
-    global UI_PREFIX configure.compiler configure.optflags configure.archflags
-    global configure.march configure.mtune configure.universal_cflags
-    global configure.universal_cxxflags configure.universal_cppflags 
-    global configure.universal_ldflags configure.universal_args
+    global UI_PREFIX configure.compiler
     
     ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option name]]"
 
@@ -167,32 +209,10 @@
         default { return -code error "Invalid value for configure.compiler" }
     }
     ui_debug "Using compiler '$name'"
-    
-    # add in extra CFLAGS etc
-    if {[variant_exists universal] && [variant_isset universal]} {
-        foreach flag {cflags objcflags fflags f90flags fcflags} {
-            eval configure.${flag}-append ${configure.universal_cflags}
-        }
-        eval configure.cxxflags-append ${configure.universal_cxxflags}
-        eval configure.cppflags-append ${configure.universal_cppflags}
-        eval configure.ldflags-append ${configure.universal_ldflags}
-        eval configure.pre_args-append ${configure.universal_args}
-    } else {
-        foreach flag {cflags cxxflags objcflags fflags f90flags fcflags} {
-            eval configure.${flag}-append ${configure.archflags}
-            if {${configure.march} != {}} {
-                configure.${flag}-append "-march=${configure.march}"
-            }
-            if {${configure.mtune} != {}} {
-                configure.${flag}-append "-mtune=${configure.mtune}"
-            }
-        }
-        eval configure.ldflags-append ${configure.archflags}
-    }
 }
 
 # internal function to determine the compiler flags to select an arch
-proc portconfigure::configure_get_archflags {args} {
+proc portconfigure::configure_get_archflags {tool} {
     global configure.build_arch configure.m32 configure.m64 configure.compiler
     set flags ""
     if {[tbool configure.m64]} {
@@ -200,7 +220,7 @@
     } elseif {[tbool configure.m32]} {
         set flags "-m32"
     } elseif {${configure.build_arch} != ""} {
-        if {[arch_flag_supported]} {
+        if {[arch_flag_supported] && $tool == "cc" || $tool == "cxx" || $tool == "objc"} {
             set flags "-arch ${configure.build_arch}"
         } elseif {${configure.build_arch} == "x86_64" || ${configure.build_arch} == "ppc64"} {
             set flags "-m64"
@@ -324,6 +344,7 @@
                 cc   { set ret /usr/bin/gcc-4.2 }
                 objc { set ret /usr/bin/gcc-4.2 }
                 cxx  { set ret /usr/bin/g++-4.2 }
+                cpp  { set ret /usr/bin/cpp-4.2 }
             }
         }
         llvm-gcc-4.2 {
@@ -435,9 +456,15 @@
 proc portconfigure::configure_main {args} {
     global [info globals]
     global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf
-    global configure.env configure.pipe configure.cflags configure.cppflags configure.cxxflags configure.objcflags configure.ldflags configure.libs configure.fflags configure.f90flags configure.fcflags configure.classpath
+    global configure.env configure.pipe configure.libs configure.classpath configure.universal_args
     global configure.perl configure.python configure.ruby configure.install configure.awk configure.bison configure.pkg_config configure.pkg_config_path
-    global configure.ccache configure.distcc configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc configure.javac
+    global configure.ccache configure.distcc configure.cpp configure.javac configure.march configure.mtune
+    foreach tool {cc cxx objc f77 f90 fc} {
+        global configure.${tool} configure.${tool}_archflags
+    }
+    foreach flags {cflags cppflags cxxflags objcflags ldflags fflags f90flags fcflags} {
+        global configure.${flags} configure.universal_${flags}
+    }
     
     if {[tbool use_autoreconf]} {
         if {[catch {command_exec autoreconf} result]} {
@@ -490,7 +517,6 @@
 
         # Append configure flags.
         append_list_to_environment_value configure "CC" ${filter}${configure.cc}
-        append_list_to_environment_value configure "CPP" ${filter}${configure.cpp}
         append_list_to_environment_value configure "CXX" ${filter}${configure.cxx}
         append_list_to_environment_value configure "OBJC" ${filter}${configure.objc}
         append_list_to_environment_value configure "FC" ${configure.fc}
@@ -515,6 +541,27 @@
         append_list_to_environment_value configure "BISON" ${configure.bison}
         append_list_to_environment_value configure "PKG_CONFIG" ${configure.pkg_config}
         append_list_to_environment_value configure "PKG_CONFIG_PATH" ${configure.pkg_config_path}
+        
+        # add extra flags that are conditional on whether we're building universal
+        if {[variant_exists universal] && [variant_isset universal]} {
+            foreach flags {CFLAGS OBJCFLAGS} {
+                append_list_to_environment_value configure $flags ${configure.universal_cflags}
+            }
+            append_list_to_environment_value configure "CXXFLAGS" ${configure.universal_cxxflags}
+            append_list_to_environment_value configure "CPPFLAGS" ${configure.universal_cppflags}
+            append_list_to_environment_value configure "LDFLAGS" ${configure.universal_ldflags}
+            eval configure.pre_args-append ${configure.universal_args}
+        } else {
+            foreach {tool flags} {cc CFLAGS cxx CXXFLAGS objc OBJCFLAGS f77 FFLAGS f90 F90FLAGS fc FCFLAGS} {
+                append_list_to_environment_value configure $flags [set configure.${tool}_archflags]
+                if {${configure.march} != {}} {
+                    append_list_to_environment_value configure $flags "-march=${configure.march}"
+                }
+                if {${configure.mtune} != {}} {
+                    append_list_to_environment_value configure $flags "-mtune=${configure.mtune}"
+                }
+            }
+        }
 
         # Execute the command (with the new environment).
         if {[catch {command_exec configure} result]} {

Modified: branches/gsoc09-logging/base/src/port1.0/portdestroot.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portdestroot.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portdestroot.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -88,7 +88,7 @@
 
 proc portdestroot::destroot_start {args} {
     global UI_PREFIX prefix name porturl destroot os.platform destroot.clean portsharepath
-    global destroot.umask destroot.asroot macportsuser euid egid usealtworkpath altprefix
+    global destroot.umask destroot.asroot macportsuser euid egid
     global applications_dir frameworks_dir
     variable oldmask
 
@@ -109,14 +109,6 @@
         return -code error "You cannot run this port without root privileges. You need to re-run with 'sudo port'.";
     }
 
-    if {[info exists usealtworkpath] && $usealtworkpath == "yes"} {
-        # rewrite destroot.args
-        set argprefix "=[option prefix]"
-        set newargprefix "=${altprefix}[option prefix]"
-        set newdestrootargs [string map [list $argprefix $newargprefix] [option destroot.args]]
-        option destroot.args $newdestrootargs
-    }
-
     # end gsoc08-privileges
 
     set oldmask [umask ${destroot.umask}]

Modified: branches/gsoc09-logging/base/src/port1.0/portfetch.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portfetch.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portfetch.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -84,12 +84,13 @@
 default cvs.args ""
 default cvs.post_args {"${cvs.module}"}
 
-default svn.cmd {[findBinary svn $portutil::autoconf::svn_path]}
+# we want the svn port so we know --trust-server-cert will work
+default svn.cmd {${prefix}/bin/svn}
 default svn.dir {${workpath}}
 default svn.method {export}
 default svn.revision ""
 default svn.env {}
-default svn.pre_args {"--non-interactive"}
+default svn.pre_args {"--non-interactive --trust-server-cert"}
 default svn.args ""
 default svn.post_args {"${svn.url}"}
 
@@ -165,7 +166,7 @@
                 depends_fetch-append bin:cvs:cvs
             }
             svn {
-                depends_fetch-append bin:svn:subversion
+                depends_fetch-append port:subversion
             }
             git {
                 depends_fetch-append bin:git:git-core
@@ -648,8 +649,8 @@
 
                     # Special hack to check for sourceforge mirrors, which don't return a proper error code on failure
                     if {![string equal $effectiveURL $file_url] &&
-                        [string match "*sourceforge*" $file_url] &&
-                        [string match "*failedmirror*" $effectiveURL]} {
+                        [string match "http://*sourceforge.net/*" $file_url] &&
+                        [string match "http://*sourceforge.net/projects/*/files/" $effectiveURL]} {
 
                         # *SourceForge hackage in effect*
                         # The url seen by curl seems to have been a redirect to the sourceforge mirror page
@@ -703,19 +704,9 @@
 # Initialize fetch target and call checkfiles.
 proc portfetch::fetch_init {args} {
     global distfiles distname distpath all_dist_files dist_subdir fetch.type fetch_init_done
-    global altprefix usealtworkpath
     variable fetch_urls
 
     if {[info exists distpath] && [info exists dist_subdir] && ![info exists fetch_init_done]} {
-
-        # start gsoc08-privileges
-        if {[info exists usealtworkpath] && $usealtworkpath == "yes"} {
-            # I have removed ![file writable $distpath] from the if condition as
-            # the writable condition seems to get confused by effective uids.
-            set distpath "$altprefix/[ string range $distpath 1 end ]"
-            ui_debug "Going to use $distpath for fetch."
-        }
-        # end gsoc08-privileges
         set distpath ${distpath}/${dist_subdir}
         set fetch_init_done yes
     }

Modified: branches/gsoc09-logging/base/src/port1.0/portlint.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portlint.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portlint.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -328,6 +328,13 @@
             ui_info "OK: Found optional variable: $opt_var"
         }
     }
+    
+    if {[info exists name]} {
+        if {[regexp {[^[:alnum:]_.-]} $name]} {
+            ui_error "Port name '$name' contains unsafe characters. Names should only contain alphanumeric characters, underscores, dashes or dots."
+            incr errors
+        }
+    }
 
     if {[info exists platforms]} {
         foreach platform $platforms {
@@ -440,6 +447,22 @@
         }
     }
 
+    # Check for multiple dependencies
+    foreach deptype {depends_extract depends_lib depends_build depends_run} {
+        if {[info exists $deptype]} {
+            array set depwarned {}
+            foreach depspec [set $deptype] {
+                if {![info exists depwarned($depspec)]
+                        && [llength [lsearch -exact -all [set $deptype] $depspec]] > 1} {
+                    ui_warn "Dependency $depspec specified multiple times in $deptype"
+                    incr warnings
+                    # Report each depspec only once
+                    set depwarned($depspec) yes
+                }
+            }
+        }
+    }
+
     if {[regexp "^(.+)nomaintainer(@macports.org)?(.+)$" $maintainers] } {
         ui_error "Using nomaintainer together with other maintainer"
         incr errors

Modified: branches/gsoc09-logging/base/src/port1.0/portmain.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portmain.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portmain.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -45,19 +45,18 @@
 
 # define options
 options prefix macportsuser name version revision epoch categories maintainers
-options long_description description homepage license provides conflicts
+options long_description description homepage license provides conflicts replaced_by
 options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
 options universal_variant os.universal_supported
 options copy_log_files
+options compiler.cpath compiler.library_path
 # Export options via PortInfo
-options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts
+options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts replaced_by
 
 # Assign option procedure to default_variants
 option_proc default_variants handle_default_variants
 
-default distpath {[file join $portdbpath distfiles]}
 default workpath {[getportworkpath_from_buildpath $portbuildpath]}
-default worksymlink {[file join $portpath work]}
 default prefix /opt/local
 default applications_dir /Applications/MacPorts
 default frameworks_dir {${prefix}/Library/Frameworks}
@@ -83,7 +82,7 @@
 # Platform Settings
 set os_arch $tcl_platform(machine)
 if {$os_arch == "Power Macintosh"} { set os_arch "powerpc" }
-if {$os_arch == "i586" || $os_arch == "i686"} { set os_arch "i386" }
+if {$os_arch == "i586" || $os_arch == "i686" || $os_arch == "x86_64"} { set os_arch "i386" }
 set os_version $tcl_platform(osVersion)
 set os_major [lindex [split $os_version .] 0]
 set os_platform [string tolower $tcl_platform(os)]
@@ -113,6 +112,9 @@
 
 default universal_variant yes
 
+default compiler.cpath {${prefix}/include}
+default compiler.library_path {${prefix}/lib}
+
 # Select implicit variants
 if {[info exists os.platform] && ![info exists variations(${os.platform})]} { variant_set ${os.platform}}
 if {[info exists os.arch] && ![info exists variations(${os.arch})]} { variant_set ${os.arch} }
@@ -124,10 +126,46 @@
     option os.universal_supported yes
 }
 
+# start gsoc08-privileges
+
 # Record initial euid/egid
 set euid [geteuid]
 set egid [getegid]
 
+# if unable to write to workpath, implies running without either root privileges
+# or a shared directory owned by the group so use ~/.macports
+if { $euid != 0 && (([info exists workpath] && [file exists $workpath] && ![file writable $workpath]) || ([info exists portdbpath] && ![file writable [file join $portdbpath build]])) } {
+
+    set username [uid_to_name [getuid]]
+
+    # set global variable indicating to other functions to use ~/.macports as well
+    set usealtworkpath yes
+
+    # do tilde expansion manually - Tcl won't expand tildes automatically for curl, etc.
+    if {[info exists env(HOME)]} {
+        # HOME environment var is set, use it.
+        set userhome "$env(HOME)"
+    } else {
+        # the environment var isn't set, expand ~user instead
+        set userhome [file normalize "~${username}"]
+    }
+
+    # set alternative prefix global variable
+    set altprefix [file join $userhome .macports]
+
+    default worksymlink {[file join ${altprefix}${portpath} work]}
+    default distpath {[file join ${altprefix}${portdbpath} distfiles]}
+    set portbuildpath "${altprefix}${portbuildpath}"
+
+    ui_debug "Going to use alternate build prefix: $altprefix"
+    ui_debug "workpath = $workpath"
+} else {
+    set usealtworkpath no
+    default worksymlink {[file join $portpath work]}
+    default distpath {[file join $portdbpath distfiles]}
+}
+# end gsoc08-privileges
+
 proc portmain::main {args} {
     return 0
 }

Modified: branches/gsoc09-logging/base/src/port1.0/porttrace.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/porttrace.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/porttrace.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -44,7 +44,7 @@
         if {[catch {package require Thread} error]} {
             ui_warn "trace requires Tcl Thread package ($error)"
         } else {
-            global env trace_fifo trace_sandboxbounds portpath distpath
+            global env trace_fifo trace_sandboxbounds portpath distpath altprefix
             # Create a fifo.
             # path in unix socket limited to 109 chars
             # # set trace_fifo "$workpath/trace_fifo"

Modified: branches/gsoc09-logging/base/src/port1.0/portutil.tcl
===================================================================
--- branches/gsoc09-logging/base/src/port1.0/portutil.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/port1.0/portutil.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -358,6 +358,12 @@
     if {[option macosx_deployment_target] ne ""} {
         set ${command}.env_array(MACOSX_DEPLOYMENT_TARGET) [option macosx_deployment_target]
     }
+    if {[option compiler.cpath] ne ""} {
+        set ${command}.env_array(CPATH) [join [option compiler.cpath] :]
+    }
+    if {[option compiler.library_path] ne ""} {
+        set ${command}.env_array(LIBRARY_PATH) [join [option compiler.library_path] :]
+    }
 
     # Debug that.
     ui_debug "Environment: [environment_array_to_string ${command}.env_array]"
@@ -911,7 +917,7 @@
             return -code error "reinplace copy failed"
         }
 
-        eval file attributes {$file} $attributes
+        fileAttrsAsRoot $file $attributes
 
         file delete "$tmpfile"
     }
@@ -1219,7 +1225,9 @@
 
     if {$procedure != ""} {
         set targetname [ditem_key $ditem name]
-        if { [tbool ${targetname}.asroot] } {
+        set target [ditem_key $ditem provides]
+        global ${target}.asroot
+        if { [tbool ${target}.asroot] } {
             elevateToRoot $targetname
         }
 
@@ -1502,83 +1510,41 @@
 # open file to store name of completed targets
 proc open_statefile {args} {
     global workpath worksymlink place_worksymlink name portpath ports_ignore_older
-    global altprefix usealtworkpath env applications_dir portbuildpath distpath
+    global usealtworkpath altprefix env applications_dir portbuildpath
 
-    # start gsoc08-privileges
-    if { ![file exists $workpath] } {
-        if {[catch {set result [file mkdir $workpath]} result]} {
-            global errorInfo
-            ui_debug "mkdir $workpath: $errorInfo"
-        }
+    if {![file isdirectory $workpath]} {
+        file mkdir $workpath
+        chownAsRoot $portbuildpath
     }
-
-    # if unable to write to workpath, implies running without either root privileges
-    # or a shared directory owned by the group so use ~/.macports
-    if { ![file writable $workpath] } {
-
-        set userid [getuid]
-        set username [uid_to_name $userid]
-
-        if { $userid !=0 } {
-            ui_msg "MacPorts running without privileges.\
-                    You may be unable to complete certain actions (eg install)."
-        }
-
-        # set global variable indicating to other functions to use ~/.macports as well
-        set usealtworkpath yes
-
-        # do tilde expansion manually - tcl won't expand tildes automatically for curl, etc.
-        if {[info exists env(HOME)]} {
-            # HOME environment var is set, use it.
-            set userhome "$env(HOME)"
-        } else {
-            # the environment var isn't set, expand ~user instead
-            set userhome [file normalize "~${username}"]
-        }
-
-        # set alternative prefix global variables
-        set altprefix "$userhome/.macports"
-
-        # get alternative paths
-        set newworkpath "$altprefix$workpath"
-        set newworksymlink "$altprefix$worksymlink"
-        set newportbuildpath "$altprefix$portbuildpath"
-        set newdistpath "$altprefix$distpath"
-
-        set sourcepath [string map {"work" ""} $worksymlink]
-        set newsourcepath "$altprefix/[ string range $sourcepath 1 end ]"
-
+    
+    if { [getuid] != 0 } {
+        ui_msg "MacPorts running without privileges.\
+                You may be unable to complete certain actions (eg install)."
+    }
+    
+    # de-escalate privileges if MacPorts was started with sudo
+    dropPrivileges
+    
+    if {$usealtworkpath} {
+        set newsourcepath "$altprefix/$portpath"
+    
         # copy Portfile (and patch files) if not there already
         # note to maintainers/devs: the original portfile in /opt/local is ALWAYS the one that will be
         #    read by macports. The copying of the portfile is done to preserve the symlink provided
         #    historically by macports from the portfile directory to the work directory.
         #    It is NOT read by MacPorts.
-        if {![file exists ${newsourcepath}Portfile] } {
+        if {![file exists ${newsourcepath}/Portfile] } {
             file mkdir $newsourcepath
             ui_debug "$newsourcepath created"
-            ui_debug "Going to copy: ${sourcepath}Portfile"
-            file copy ${sourcepath}Portfile $newsourcepath
-            if {[file exists ${sourcepath}files] } {
-                ui_debug "Going to copy: ${sourcepath}files"
-                file copy ${sourcepath}files $newsourcepath
+            ui_debug "Going to copy: ${portpath}/Portfile"
+            file copy ${portpath}/Portfile $newsourcepath
+            if {[file exists ${portpath}/files] } {
+                ui_debug "Going to copy: ${portpath}/files"
+                file copy ${portpath}/files $newsourcepath
             }
         }
-
-        set workpath $newworkpath
-        set worksymlink $newworksymlink
-        set portbuildpath $newportbuildpath
-        set distpath $newdistpath
-
-        ui_debug "Going to use $newworkpath for statefile."
-    } else {
-        set usealtworkpath no
     }
-    # end gsoc08-privileges
 
-    if {![file isdirectory $workpath]} {
-        file mkdir $workpath
-    }
-
     # flock Portfile
     set statefile [file join $workpath .macports.${name}.state]
     if {[file exists $statefile]} {
@@ -1586,21 +1552,21 @@
             return -code error "$statefile is not writable - check permission on port directory"
         }
         if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
-            ui_msg "Portfile changed since last build; discarding previous state."
-            #file delete $statefile
-            delete [file join $workpath]
-            file mkdir [file join $workpath]
+            if {!([info exists ports_dryrun] && $ports_dryrun == "yes")} {
+                ui_msg "Portfile changed since last build; discarding previous state."
+                delete $workpath
+                file mkdir $workpath
+            } else {
+                ui_msg "Portfile changed since last build but not discarding previous state (dry run)"
+            }
         }
     }
-    chownAsRoot $workpath
 
     # Create a symlink to the workpath for port authors
     if {[tbool place_worksymlink] && ![file isdirectory $worksymlink]} {
         ui_debug "Attempting ln -sf $workpath $worksymlink"
         ln -sf $workpath $worksymlink
     }
-    # de-escalate privileges - only run if MacPorts was started with sudo
-    dropPrivileges
 
     set fd [open $statefile a+]
     if {[catch {flock $fd -exclusive -noblock} result]} {
@@ -1640,28 +1606,40 @@
     flush $fd
 }
 
-# check_statefile_variants
+##
 # Check that recorded selection of variants match the current selection
-proc check_statefile_variants {variations fd} {
+#
+# @param variations input array name of new variants
+# @param oldvariations output array name of old variants
+# @param fd file descriptor of the state file
+# @return 0 if variants match, 1 otherwise
+proc check_statefile_variants {variations oldvariations fd} {
     upvar $variations upvariations
+    upvar $oldvariations upoldvariations
 
+    array set upoldvariations {}
+
+    seek $fd 0 end
+    if {[tell $fd] == 0} {
+        # Statefile is empty, skipping further tests
+        return 0
+    }
+
     seek $fd 0
     while {[gets $fd line] >= 0} {
         if {[regexp "variant: (.*)" $line match name]} {
-            set oldvariations([string range $name 1 end]) [string range $name 0 0]
+            set upoldvariations([string range $name 1 end]) [string range $name 0 0]
         }
     }
 
     set mismatch 0
-    if {[array size oldvariations] > 0} {
-        if {[array size oldvariations] != [array size upvariations]} {
-            set mismatch 1
-        } else {
-            foreach key [array names upvariations *] {
-                if {![info exists oldvariations($key)] || $upvariations($key) != $oldvariations($key)} {
+    if {[array size upoldvariations] != [array size upvariations]} {
+        set mismatch 1
+    } else {
+        foreach key [array names upvariations *] {
+            if {![info exists upoldvariations($key)] || $upvariations($key) != $upoldvariations($key)} {
                 set mismatch 1
                 break
-                }
             }
         }
     }
@@ -1848,8 +1826,9 @@
 
         set state_fd [open_statefile]
 
-        if {[check_statefile_variants upvariations $state_fd]} {
-            ui_error "Requested variants do not match original selection.\nPlease perform 'port clean $portname' or specify the force option."
+        array set oldvariations {}
+        if {[check_statefile_variants upvariations oldvariations $state_fd]} {
+            ui_error "Requested variants \"[canonicalize_variants [array get upvariations]]\" do not match original selection \"[canonicalize_variants [array get oldvariations]]\".\nPlease use the same variants again, perform 'port clean $portname' or specify the force option (-f)."
             set result 1
         } elseif {!([info exists ports_dryrun] && $ports_dryrun == "yes")} {
             # Write variations out to the statefile
@@ -1864,35 +1843,25 @@
     return $result
 }
 
-proc default_universal_variant_allowed {args} {
-
+# add the default universal variant if appropriate
+proc universal_setup {args} {
     if {[variant_exists universal]} {
         ui_debug "universal variant already exists, so not adding the default one"
-        return no
     } elseif {[exists universal_variant] && ![option universal_variant]} {
         ui_debug "'universal_variant no' specified, so not adding the default universal variant"
-        return no
     } elseif {[exists use_xmkmf] && [option use_xmkmf]} {
         ui_debug "using xmkmf, so not adding the default universal variant"
-        return no
     } elseif {[exists use_configure] && ![option use_configure] && ![exists xcode.project]} {
         # Allow +universal if port uses xcode portgroup.
         ui_debug "not using configure, so not adding the default universal variant"
-        return no
     } elseif {![exists os.universal_supported] || ![option os.universal_supported]} {
         ui_debug "OS doesn't support universal builds, so not adding the default universal variant"
-        return no
     } else {
         ui_debug "adding the default universal variant"
-        return yes
+        variant universal {}
     }
 }
 
-proc add_default_universal_variant {args} {
-    # Declare default universal variant (all the magic happens in portconfigure now)
-    variant universal {}
-}
-
 # Target class definition.
 
 # constructor for target object
@@ -2364,6 +2333,26 @@
 }
 
 ##
+# Change attributes of file while running as root
+#
+# @param file the file in question
+# @param attributes the attributes for the file
+proc fileAttrsAsRoot {file attributes} {
+    global euid macportsuser
+    if {[getuid] == 0 && [geteuid] != 0} {
+        # Started as root, but not root now
+        seteuid $euid
+        ui_debug "euid changed to: [geteuid]"
+        ui_debug "setting attributes on $file"
+        eval file attributes {$file} $attributes
+        seteuid [name_to_uid "$macportsuser"]
+        ui_debug "euid changed to: [geteuid]"
+    } else {
+        eval file attributes {$file} $attributes
+    }
+}
+
+##
 # Elevate privileges back to root.
 #
 # @param action the action for which privileges are being elevated

Modified: branches/gsoc09-logging/base/src/programs/daemondo/Makefile.in
===================================================================
--- branches/gsoc09-logging/base/src/programs/daemondo/Makefile.in	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/programs/daemondo/Makefile.in	2009-08-12 12:26:30 UTC (rev 55506)
@@ -8,7 +8,8 @@
 mandir=		@mandir@
 mandircat8=	${mandir}/cat8
 
-CFLAGS_QUICHEEATERS	= -W -Wall -Wno-unused-parameter
+CFLAGS_QUICHEEATERS	= -W -Wall
+CPPFLAGS	+= -I../..
 SRCS		= main.c
 OBJS		= main.o
 LIBS		= -framework CoreFoundation \
@@ -32,7 +33,7 @@
 distclean: clean
 	rm -f Makefile
 
-install:
+install: daemondo
 	${INSTALL} -o ${DSTUSR} -g ${DSTGRP} -m 555 ${PROGRAM} ${DESTDIR}${bindir}
 
 test:

Modified: branches/gsoc09-logging/base/src/programs/daemondo/main.c
===================================================================
--- branches/gsoc09-logging/base/src/programs/daemondo/main.c	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/programs/daemondo/main.c	2009-08-12 12:26:30 UTC (rev 55506)
@@ -47,7 +47,11 @@
     
         com.apple.system.config.network_change
 */
-    
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdio.h>
 #include <unistd.h>
 #include <signal.h>
@@ -707,7 +711,7 @@
 
 
 void
-ScheduledRestartCallback(CFRunLoopTimerRef timer, void *info)
+ScheduledRestartCallback(CFRunLoopTimerRef timer UNUSED, void *info UNUSED)
 {
     if (verbosity >= 3)
         LogMessage("Scheduled restart time has arrived.\n");
@@ -759,9 +763,9 @@
 
 void
 DynamicStoreChanged(
-                    SCDynamicStoreRef   store,
+                    SCDynamicStoreRef   store UNUSED,
                     CFArrayRef          changedKeys,
-                    void                *info
+                    void                *info UNUSED
                     )
 {
     if (verbosity >= 3)
@@ -789,7 +793,7 @@
 
 
 void
-PowerCallBack(void *x, io_service_t y, natural_t messageType, void *messageArgument)
+PowerCallBack(void *x UNUSED, io_service_t y UNUSED, natural_t messageType, void *messageArgument)
 {
     switch (messageType)
     {
@@ -814,11 +818,11 @@
 
 void
 NotificationCenterCallback(
-                                CFNotificationCenterRef center, 
-                                void *observer, 
-                                CFStringRef name, 
-                                const void *object, 
-                                CFDictionaryRef userInfo)
+                                CFNotificationCenterRef center UNUSED,
+                                void *observer UNUSED,
+                                CFStringRef name,
+                                const void *object UNUSED,
+                                CFDictionaryRef userInfo UNUSED)
 {
     if (verbosity >= 3)
     {
@@ -832,7 +836,7 @@
 
 
 void
-SignalCallback(CFMachPortRef port, void *msg, CFIndex size, void *info)
+SignalCallback(CFMachPortRef port UNUSED, void *msg, CFIndex size UNUSED, void *info UNUSED)
 {
     mach_msg_header_t* hdr = (mach_msg_header_t*)msg;
     switch (hdr->msgh_id)
@@ -865,8 +869,8 @@
 }
 
 
-void KQueueCallBack (CFSocketRef socketRef, CFSocketCallBackType type,
-             CFDataRef address, const void *data, void *context)
+void KQueueCallBack (CFSocketRef socketRef, CFSocketCallBackType type UNUSED,
+             CFDataRef address UNUSED, const void *data UNUSED, void *context UNUSED)
 {
     int fd = CFSocketGetNative(socketRef);
     

Modified: branches/gsoc09-logging/base/src/registry1.0/portimage.tcl
===================================================================
--- branches/gsoc09-logging/base/src/registry1.0/portimage.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/registry1.0/portimage.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -55,9 +55,6 @@
 # will also remove all of the references of the files from the registry's 
 # file_map
 #
-# Compacting and Uncompacting of port images to save space will be implemented
-# at some point.
-#
 # For the creating and removing of links during activation and deactivation,
 # code very similar to what is used in portinstall is used.
 #
@@ -85,13 +82,8 @@
 	set version [lindex $ilist 1]
 	set revision [lindex $ilist 2]
 	set	variants [lindex $ilist 3]
-	
-    if {$v != ""} {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
-    } else {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
-    }
 
+	# if another version of this port is active, deactivate it first
 	set ilist [registry::installed $name]
 	if { [llength $ilist] > 1 } {
 		foreach i $ilist {
@@ -101,10 +93,16 @@
 			set	ivariants [lindex $i 3]
 			set iactive [lindex $i 4]
 			if { ![string equal ${iversion}_${irevision}${ivariants} ${version}_${revision}${variants}] && $iactive == 1 } {
-				return -code error "Image error: Another version of this port ($iname @${iversion}_${irevision}${ivariants}) is already active."
+				deactivate $iname ${iversion}_${irevision}${ivariants} $optionslist
 			}
 		}
 	}
+	
+    if {$v != ""} {
+        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
+    } else {
+        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
+    }
 
 	set ref [registry::open_entry $name $version $revision $variants]
 	
@@ -114,9 +112,6 @@
 	if { [registry::property_retrieve $ref active] != 0 } {
 		return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
 	} 
-	if { [registry::property_retrieve $ref compact] != 0 } {
-		return -code error "Image error: ${name} @${version}_${revision}${variants} is compactd."
-	} 
 
 	set imagedir [registry::property_retrieve $ref imagedir]
 
@@ -179,10 +174,7 @@
 	}
 	if { [registry::property_retrieve $ref active] != 1 } {
 		return -code error "Image error: ${name} @${fqversion} is not active."
-	} 
-	if { [registry::property_retrieve $ref compact] != 0 } {
-		return -code error "Image error: ${name} @${fqversion} is compactd."
-	} 
+	}
 
 	set imagedir [registry::property_retrieve $ref imagedir]
 
@@ -203,20 +195,6 @@
 
 }
 
-proc compact {name v} {
-	global UI_PREFIX
-
-	return -code error "Image error: compact/uncompact not yet implemented."
-
-}
-
-proc uncompact {name v} {
-	global UI_PREFIX
-
-	return -code error "Image error: compact/uncompact not yet implemented."
-
-}
-
 proc _check_registry {name v} {
 	global UI_PREFIX
 

Modified: branches/gsoc09-logging/base/src/registry1.0/registry.tcl
===================================================================
--- branches/gsoc09-logging/base/src/registry1.0/registry.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/registry1.0/registry.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -66,7 +66,6 @@
 			set imagedir [file join ${macports::registry.path} software ${name} ${version}_${revision}${variants}]
 			property_store $ref imagedir $imagedir
 			property_store $ref active 0
-			property_store $ref compact 0
 		}
 
 		return $ref

Modified: branches/gsoc09-logging/base/src/registry2.0/portimage.tcl
===================================================================
--- branches/gsoc09-logging/base/src/registry2.0/portimage.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/registry2.0/portimage.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -57,9 +57,6 @@
 # will also remove all of the references of the files from the registry's
 # file_map
 #
-# Compacting and Uncompacting of port images to save space will be implemented
-# at some point.
-#
 # For the creating and removing of links during activation and deactivation,
 # code very similar to what is used in portinstall is used.
 #
@@ -114,11 +111,6 @@
         if { [string equal [$requested state] "active"] } {
             return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
         }
-
-        # compaction is not yet supported
-        #if { [$requested compact] != 0 } {
-        #    return -code error "Image error: ${name} @${version}_${revision}${variants} is compacted."
-        #}
     }
 
     _activate_contents $port $force
@@ -166,11 +158,6 @@
         return -code error "Image error: ${name} @${specifier} is not active."
     }
 
-    # compaction not yet supported
-    #if { [registry::property_retrieve $ref compact] != 0 } {
-    #    return -code error "Image error: ${name} @${specifier} is compacted."
-    #}
-
     registry::check_dependents $port $force
 
     set imagedir [$requested imagedir]
@@ -180,18 +167,6 @@
     $requested state imaged
 }
 
-proc compact {name v} {
-    global UI_PREFIX
-
-    throw registry::image-error "Image error: compact/uncompact not yet implemented."
-}
-
-proc uncompact {name v} {
-    global UI_PREFIX
-
-    throw registry::image-error "Image error: compact/uncompact not yet implemented."
-}
-
 proc _check_registry {name specifier} {
     global UI_PREFIX
 

Modified: branches/gsoc09-logging/base/src/upgrade_sources_conf_default.tcl
===================================================================
--- branches/gsoc09-logging/base/src/upgrade_sources_conf_default.tcl	2009-08-12 11:49:26 UTC (rev 55505)
+++ branches/gsoc09-logging/base/src/upgrade_sources_conf_default.tcl	2009-08-12 12:26:30 UTC (rev 55506)
@@ -41,15 +41,26 @@
          } elseif {[regexp {rsync://rsync\.(macports|darwinports)\.org/(release|dpupdate)/d?ports} $url]} {
             set addDefault true
          } elseif {[regexp {file://(/.+)} $url -> filepath]} {
-            if {[file exists [file join ${filepath} .svn]] && ![catch {set svnChannel [open "|svn info ${filepath}" r]}]} {
-               set svnURL {}
-               while {[gets $svnChannel svnLine] >= 0} {
-                  regexp {^URL: (.*)} $svnLine -> svnURL
+            if {[file exists [file join ${filepath} .svn]]} {
+               if {![catch {set svnChannel [open "|svn info ${filepath}" r]} err]} {
+                  set svnURL {}
+                  while {[gets $svnChannel svnLine] >= 0} {
+                     regexp {^URL: (.*)} $svnLine -> svnURL
+                  }
+                  if {[catch {close $svnChannel} err]} {
+                     if {![string match "*This client is too old to work with working copy*" $err]} {
+                        return -code error $err
+                     } else {
+                        puts $err
+                        puts "WARNING: Unable to check svn URL for '$filepath' as it has been checked out with a newer Subversion client; please manually verify $sourcesConf!"
+                     }
+                  }
+                  if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
+                     set addDefault true
+                  }
+               } else {
+                  return -code error $err
                }
-               close $svnChannel
-               if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
-                  set addDefault true
-               }
             }
          }
          if {$addDefault} {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090812/847447ec/attachment-0001.html>


More information about the macports-changes mailing list