Index: contrib/MacPorts_Framework/BetterAuthorizationSampleLib.c
===================================================================
--- contrib/MacPorts_Framework/BetterAuthorizationSampleLib.c	(revision 40518)
+++ contrib/MacPorts_Framework/BetterAuthorizationSampleLib.c	(revision 65491)
@@ -48,4 +48,5 @@
 // "BetterAuthorizationSampleLib.h".
 
+
 #define BAS_PRIVATE 1
 
@@ -78,5 +79,5 @@
 enum {
     kIdleTimeoutInSeconds     = 120,        // if we get no requests in 2 minutes, we quit
-    kWatchdogTimeoutInSeconds = 65          // any given request must be completely in 65 seconds
+    kWatchdogTimeoutInSeconds = 500000      // any given request must be completed in ~5 days (is this ok?)
 };
 
@@ -94,10 +95,10 @@
 //    can be sent as an architecture-neutral uint32_t.
 
-#define kBASMaxNumberOfKBytes			(1024 * 1024)
+#define kBASMaxNumberOfKBytes           (1024 * 1024)
 
 // A hard-wired file system path for the UNIX domain socket; %s is the placeholder 
 // for the bundle ID (in file system representation).
 
-#define kBASSocketPathFormat			"/var/run/%s.socket"
+#define kBASSocketPathFormat            "/var/run/%s.socket"
 
 // The key used to get our describe our socket in the launchd property list file.
@@ -118,7 +119,7 @@
             break
     switch (errNum) {
-		case noErr:
-			retval = 0;
-			break;
+        case noErr:
+            retval = 0;
+            break;
         case kENORSRCErr:
             retval = ESRCH;                 // no ENORSRC on Mac OS X, so use ESRCH
@@ -129,7 +130,7 @@
         CASE(EDEADLK);
         CASE(EAGAIN);
-		case kEOPNOTSUPPErr:
-			retval = ENOTSUP;
-			break;
+        case kEOPNOTSUPPErr:
+            retval = ENOTSUP;
+            break;
         CASE(EPROTO);
         CASE(ETIME);
@@ -146,10 +147,10 @@
         default:
             if ( (errNum <= kEPERMErr) && (errNum >= kENOMSGErr) ) {
-				retval = (-3200 - errNum) + 1;				// OT based error
+                retval = (-3200 - errNum) + 1;              // OT based error
             } else if ( (errNum >= errSecErrnoBase) && (errNum <= (errSecErrnoBase + ELAST)) ) {
-                retval = (int) errNum - errSecErrnoBase;	// POSIX based error
+                retval = (int) errNum - errSecErrnoBase;    // POSIX based error
             } else {
-				retval = (int) errNum;						// just return the value unmodified
-			}
+                retval = (int) errNum;                      // just return the value unmodified
+            }
     }
     #undef CASE
@@ -1921,37 +1922,43 @@
     // We install the job disabled, then enable it as the last step.
 
-    "	<key>Disabled</key>\n"
-    "	<true/>\n"
+    "   <key>Disabled</key>\n"
+    "   <true/>\n"
 
     // Use the bundle identifier as the job label.
 
-    "	<key>Label</key>\n"
-    "	<string>%s</string>\n"
+    "   <key>Label</key>\n"
+    "   <string>%s</string>\n"
 
     // Use launch on demaind.
 
-    "	<key>OnDemand</key>\n"
-    "	<true/>\n"
-
-	// We don't want our helper tool to be respawned every 10 seconds
-	// after a faliure ... hopefully this won't ALSO prevent us from
-	// rerunning the helper tool without rebooting the machine
-//	"	<key>LaunchOnlyOnce</key>\n"
-//	"	<true/>\n"
-
-    // There are no program arguments, other that the path to the helper tool itself.
+    "   <key>OnDemand</key>\n"
+    "   <true/>\n"
+
+    // We don't want our helper tool to be respawned every 10 seconds
+    // after a faliure ... hopefully this won't ALSO prevent us from
+    // rerunning the helper tool without rebooting the machine
+    "   <key>LaunchOnlyOnce</key>\n"
+    "   <true/>\n"
+
+    // There are no program arguments, other that the path to the helper tool itself
+    // but we must force it to run using the i386 binary if the Framework is
+    // being used as a i386 binary.
     //
     // IMPORTANT
     // kBASToolPathFormat embeds a %s
 
-    "	<key>ProgramArguments</key>\n"
-    "	<array>\n"
-    "		<string>" kBASToolPathFormat "</string>\n"
-    "	</array>\n"
+    "   <key>ProgramArguments</key>\n"
+    "   <array>\n"
+#ifdef __i386__
+    "       <string>/usr/bin/arch</string>\n"
+    "       <string>-i386</string>\n"
+#endif
+    "       <string>" kBASToolPathFormat "</string>\n"
+    "   </array>\n"
 
     // The tool is required to check in with launchd.
 
-    "	<key>ServiceIPC</key>\n"
-    "	<true/>\n"
+    "   <key>ServiceIPC</key>\n"
+    "   <true/>\n"
 
     // This specifies the UNIX domain socket used to launch the tool, including 
@@ -1961,18 +1968,18 @@
     // kBASSocketPathFormat embeds a %s
 
-    "	<key>Sockets</key>\n"
-    "	<dict>\n"
-    "		<key>" kLaunchDSocketDictKey "</key>\n"
-    "		<dict>\n"
-    "			<key>SockFamily</key>\n"
-    "			<string>Unix</string>\n"
-    "			<key>SockPathMode</key>\n"
-    "			<integer>438</integer>\n"
-    "			<key>SockPathName</key>\n"
-    "			<string>" kBASSocketPathFormat "</string>\n"
-    "			<key>SockType</key>\n"
-    "			<string>Stream</string>\n"
-    "		</dict>\n"
-    "	</dict>\n"
+    "   <key>Sockets</key>\n"
+    "   <dict>\n"
+    "       <key>" kLaunchDSocketDictKey "</key>\n"
+    "       <dict>\n"
+    "           <key>SockFamily</key>\n"
+    "           <string>Unix</string>\n"
+    "           <key>SockPathMode</key>\n"
+    "           <integer>438</integer>\n"
+    "           <key>SockPathName</key>\n"
+    "           <string>" kBASSocketPathFormat "</string>\n"
+    "           <key>SockType</key>\n"
+    "           <string>Stream</string>\n"
+    "       </dict>\n"
+    "   </dict>\n"
     "</dict>\n"
     "</plist>\n"
@@ -2461,2 +2468,22 @@
     return retval;
 }
+
+extern void BASTerminateCommand (
+                           AuthorizationRef			auth, 
+                           const char *				bundleID, 
+                           const char *             installToolPath
+)
+// Terminate the HelperTool.
+{
+    // Pre-conditions
+    
+    assert(auth != NULL);
+    assert(bundleID != NULL);
+    assert(installToolPath != NULL);
+    
+    // Run the install tool as root using AuthorizationExecuteWithPrivileges.   
+    RunInstallToolAsRoot(auth, installToolPath, kBASInstallToolTerminateCommand, bundleID, NULL);
+    
+    return;
+}
+
Index: contrib/MacPorts_Framework/BetterAuthorizationSampleLib.h
===================================================================
--- contrib/MacPorts_Framework/BetterAuthorizationSampleLib.h	(revision 40518)
+++ contrib/MacPorts_Framework/BetterAuthorizationSampleLib.h	(revision 65491)
@@ -739,4 +739,10 @@
 );
 
+extern void BASTerminateCommand(
+    AuthorizationRef			auth, 
+    const char *				bundleID, 
+    const char *                installToolPath
+);
+
 /////////////////////////////////////////////////////////////////
 #pragma mark ***** Utility Routines
@@ -764,4 +770,5 @@
     #define kBASInstallToolInstallCommand "install"
     #define kBASInstallToolEnableCommand  "enable"
+    #define kBASInstallToolTerminateCommand  "terminate"
 
 	// Magic values used to bracket the process ID returned by the install tool.
Index: contrib/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c
===================================================================
--- contrib/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c	(revision 40518)
+++ contrib/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c	(revision 65491)
@@ -396,4 +396,22 @@
 }
 
+static int TerminateCommand(
+    const char					*bundleID
+)
+// Utility function to call through to RunLaunchCtl in order to terminate a job
+// given by the path contructed from the (const char *) bundleID.
+{
+	int		err;
+	char	plistPath[PATH_MAX];
+	
+	// Pre-condition.
+	assert(bundleID != NULL);
+	
+	(void) snprintf(plistPath, sizeof(plistPath), kBASPlistPathFormat, bundleID);
+	err = RunLaunchCtl(false, "unload", plistPath);
+    
+	return err;
+}
+
 int main(int argc, char **argv)
 {
@@ -454,8 +472,15 @@
 				err = EINVAL;
 			}
-		} else {
-			fprintf(stderr, "usage2\n");
-			err = EINVAL;
-		}
+		} else if (strcmp(argv[1], kBASInstallToolTerminateCommand) == 0) {
+            if (argc == 3) {
+				err = TerminateCommand(argv[2]);
+			} else {
+				fprintf(stderr, "usage4\n");
+				err = EINVAL;
+			}
+        } else {
+            fprintf(stderr, "usage2\n");
+            err = EINVAL;
+        }
 	}
 
Index: contrib/MacPorts_Framework/Info.plist
===================================================================
--- contrib/MacPorts_Framework/Info.plist	(revision 40518)
+++ contrib/MacPorts_Framework/Info.plist	(revision 65491)
@@ -20,7 +20,14 @@
 	<string>Randall Wood</string>
 	<key>CFBundleVersion</key>
-	<string>1.0</string>
+	<string>1.1</string>
 	<key>NSPrincipalClass</key>
 	<string></string>
+	<key>LSMinimumSystemVersionByArchitecture</key>
+	<dict>
+		<key>i386</key>
+		<string>10.4.0</string>
+		<key>x86_64</key>
+		<string>10.6.0</string>
+	</dict>
 </dict>
 </plist>
Index: contrib/MacPorts_Framework/MPHelperTool.m
===================================================================
--- contrib/MacPorts_Framework/MPHelperTool.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPHelperTool.m	(revision 65491)
@@ -54,5 +54,4 @@
 
 
-
 //According to the docs all I need is
 //the file descriptor that MPNotifications
@@ -823,10 +822,4 @@
 #pragma mark ***** Tool Infrastructure
 
-/*
- IMPORTANT
- ---------
- This array must be exactly parallel to the kMPHelperCommandSet array 
- in "MPHelperCommon.c".
- */
 
 static OSStatus DoEvaluateTclString 
@@ -985,4 +978,10 @@
 
 
+/*
+ IMPORTANT
+ ---------
+ This array must be exactly parallel to the kMPHelperCommandSet array 
+ in "MPHelperCommon.c".
+ */
 static const BASCommandProc kMPHelperCommandProcs[] = {
 DoEvaluateTclString,	
Index: contrib/MacPorts_Framework/MPInterpreter.h
===================================================================
--- contrib/MacPorts_Framework/MPInterpreter.h	(revision 40518)
+++ contrib/MacPorts_Framework/MPInterpreter.h	(revision 65491)
@@ -53,5 +53,4 @@
 #define	MPPackage				@"macports"
 #define MPPackageVersion		@"1.0"
-#define MP_DEFAULT_PKG_PATH		@"/Library/Tcl"
 #define TCL_RETURN_CODE			@"return code"
 #define TCL_RETURN_STRING		@"return string"
@@ -86,7 +85,4 @@
 
 
-
-
-
 /*!
  @class MPInterpreter
@@ -105,6 +101,16 @@
 }
 
++(NSString*) PKGPath;
+
++(void) setPKGPath:(NSString*)newPath;
+
++(void) terminateMPHelperTool;
+
++(NSTask*) task;
+
 //Internal methods
 -(BOOL) setOptionsForNewTclPort:(NSArray *)options;
+
+-(BOOL) resetTclInterpreterWithPath:(NSString *)path;
 
 /*!
@@ -199,4 +205,5 @@
 - (BOOL)checkIfAuthorized;
 -(NSString *)evaluateStringWithMPHelperTool:(NSString *)statement error:(NSError **)mportError;
+-(NSString *)evaluateStringWithMPPortProcess:(NSString *)statement error:(NSError **)mportError;
 
 @end
Index: contrib/MacPorts_Framework/MPInterpreter.m
===================================================================
--- contrib/MacPorts_Framework/MPInterpreter.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPInterpreter.m	(revision 65491)
@@ -35,10 +35,11 @@
 
 #import "MPInterpreter.h"
+#import "MPMacPorts.h"
 #include "BetterAuthorizationSampleLib.h"
 #include "MPHelperCommon.h"
 #include "MPHelperNotificationsProtocol.h"
 static AuthorizationRef internalMacPortsAuthRef;
-
-
+static NSString* PKGPath = @"/Library/Tcl";
+static NSTask* aTask;
 
 #pragma mark -
@@ -46,5 +47,5 @@
 @implementation MPInterpreter
 
-#pragma mark Notifications Code 
+#pragma mark Notifications Code
 int Notifications_Send(int objc, Tcl_Obj *CONST objv[], int global, Tcl_Interp *interpreter) {
 	NSString *name;
@@ -165,4 +166,18 @@
 static NSString * tclInterpreterPkgPath = nil;
 
++(NSString*) PKGPath {
+	return PKGPath;
+}
+
++(void) setPKGPath:(NSString*)newPath {
+    if([PKGPath isNotEqualTo:newPath]) {
+        [PKGPath release];
+        PKGPath = [newPath copy];
+        //I should check if interp is nil. *not needed now
+        MPInterpreter *interp = (MPInterpreter*) [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
+        [interp resetTclInterpreterWithPath:PKGPath];
+    }
+}
+
 #pragma mark -
 #pragma mark Internal Methods
@@ -185,5 +200,5 @@
 	
 	if (path == nil)
-		path = MP_DEFAULT_PKG_PATH;
+		path = PKGPath;
 	
 	
@@ -248,5 +263,5 @@
 	
 	if (tclInterpreterPkgPath == nil) 
-		result = [self initTclInterpreter:&_interpreter withPath:MP_DEFAULT_PKG_PATH];
+		result = [self initTclInterpreter:&_interpreter withPath:PKGPath];
 	else 
 		result = [self initTclInterpreter:&_interpreter withPath:tclInterpreterPkgPath];
@@ -260,7 +275,11 @@
 } 
 
+-(BOOL) resetTclInterpreterWithPath:(NSString*) path {
+    Tcl_DeleteInterp(_interpreter);
+    return [self initTclInterpreter:&_interpreter withPath:PKGPath];
+}
+
 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
 	if (self = [super init]) {
-		
 		[self initTclInterpreter:&_interpreter withPath:path];
 		
@@ -285,24 +304,21 @@
 #pragma mark API methods
 - (id) init {
-	return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil];
+	return [self initWithPkgPath:PKGPath portOptions:nil];
 }
 
 + (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path {
-	@synchronized(self) {
-		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
-			[[self alloc] initWithPkgPath:path portOptions:nil]; // assignment not done here
-		}
-	}
-	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
+	return [self sharedInterpreterWithPkgPath:path portOptions:nil];
 }
 
 + (MPInterpreter*)sharedInterpreter{
-	return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH];
-}
-
-
+	return [self sharedInterpreterWithPkgPath:PKGPath];
+}
 
 + (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
 	@synchronized(self) {
+        if ([PKGPath isNotEqualTo:path]) {
+            [self setPKGPath:path];
+        }
+        
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
 			[[self alloc] initWithPkgPath:path portOptions:options]; // assignment not done here
@@ -439,28 +455,22 @@
 
 - (NSString *)evaluateStringWithPossiblePrivileges:(NSString *)statement error:(NSError **)mportError {
-	
-	
-	
 	//N.B. I am going to insist that funciton users not pass in nil for the
 	//mportError parameter
-	NSString * firstResult;
-	NSString * secondResult;
-	
-	*mportError = nil;
-	firstResult = [self evaluateStringAsString:statement error:mportError];
-	
-	//Because of string results of methods like mportsync (which returns the empty string)
-	//the only way to truly check for an error is to check the mportError parameter.
-	//If it is nil then there was no error, if not we re-evaluate with privileges using
-	//the helper tool
-	
-	if ( *mportError != nil) {
-		*mportError = nil; 
-		secondResult = [self evaluateStringWithMPHelperTool:statement error:mportError];
-		
-		return secondResult;
-	}
-	
-	return firstResult;
+	NSString * result;
+	
+    [[MPNotifications sharedListener] 
+     sendIPCNotification:@"MPInfoNotification_&MP&_stdout_&MP&_None_&MP&_Starting up"];
+    
+    // Is this the best way to know if the running user can use macports without privileges?
+    if ([[NSFileManager defaultManager] isWritableFileAtPath:PKGPath]) {
+        result = [self evaluateStringWithMPPortProcess:statement error:mportError];
+    } else {
+        result = [self evaluateStringWithMPHelperTool:statement error:mportError];
+    }
+
+    [[MPNotifications sharedListener] 
+     sendIPCNotification:@"MPInfoNotification_&MP&_stdout_&MP&_None_&MP&_Shutting down"];
+    
+	return result;
 }
 
@@ -584,36 +594,8 @@
 		//a noErr then response dictionary cannot be nil since everything went ok. 
 		//Hence I'm only checking for errors WITHIN the following blocks ...
-		if (err == noErr) {
-			err = BASExecuteRequestInHelperTool(internalMacPortsAuthRef, 
-												kMPHelperCommandSet, 
-												(CFStringRef) bundleID, 
-												(CFDictionaryRef) request, 
-												&response);
-			if (err == noErr){// retrieve result here if available
-				if( response != NULL)
-					result = (NSString *) (CFStringRef) CFDictionaryGetValue(response, CFSTR(kTclStringEvaluationResult));
-			}
-			else { //If we executed unsuccessfully
-				if (mportError != NULL) {
-					NSError * undError = [[[NSError alloc] initWithDomain:NSOSStatusErrorDomain 
-																	 code:err 
-																 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
-																		   NSLocalizedString(@"Check error code for OSStatus returned",@""), 
-																		   NSLocalizedDescriptionKey,
-																		   nil]] autorelease];
-					
-					*mportError = [[[NSError alloc] initWithDomain:MPFrameworkErrorDomain 
-															  code:MPHELPINSTFAILED 
-														  userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
-																	NSLocalizedString(@"Unable to execute MPHelperTool successfuly", @""), 
-																	NSLocalizedDescriptionKey,
-																	undError, NSUnderlyingErrorKey,
-																	NSLocalizedString(@"BASExecuteRequestInHelperTool execution failed", @""),
-																	NSLocalizedFailureReasonErrorKey,
-																	nil]] autorelease];
-				}
-			}
-		}
-		else {//This means FixFaliure failed ... Report that in returned error
+        //
+        // NOTE: We don't automatically retry as the user wants to have a consistent cancel 
+        //      action (i.e. terminate the process when he wants to)
+		if (err != noErr) {//This means FixFaliure failed ... Report that in returned error
 			if (mportError != NULL) {
 				//I'm not sure of exactly how to report this error ... 
@@ -644,4 +626,77 @@
 }
 
+- (NSString *) evaluateStringWithMPPortProcess:(NSString *) statement error:(NSError **)mportError {
+    aTask = [[NSTask alloc] init];
+    NSMutableArray *args = [NSMutableArray array];
+    
+    /* set arguments */
+    [args addObject:PKGPath];
+    [aTask setCurrentDirectoryPath:[[NSBundle bundleForClass:[self class]] resourcePath]];
+    [aTask setLaunchPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"MPPortProcess" ofType:@""]];
+    [aTask setArguments:args];
+    [aTask launch];
+    
+    NSConnection *notificationsConnection = [NSConnection defaultConnection];
+    // Vending MPNotifications sharedListener
+    [notificationsConnection setRootObject:[MPNotifications sharedListener]];
+    
+    // Register the named connection
+    if ( [notificationsConnection registerName:@"MPNotifications"] ) {
+        NSLog( @"Successfully registered connection with port %@", 
+              [[notificationsConnection receivePort] description] );
+    } else {
+        NSLog( @"Name used by %@", 
+              [[[NSPortNameServer systemDefaultPortNameServer] portForName:@"MPNotifications"] description] );
+    }
+    
+    
+    id theProxy;
+    do {
+        theProxy = [NSConnection
+                       rootProxyForConnectionWithRegisteredName:@"MPPortProcess"
+                       host:nil];
+    } 
+    while (theProxy == nil);
+    
+    [theProxy evaluateString:statement];
+    [aTask waitUntilExit];
+    
+    int status = [aTask terminationStatus];
+    
+    if (status != TCL_OK) {
+        NSLog(@"Task failed. Code: %i", status);
+    }
+    [[notificationsConnection receivePort] invalidate];
+    
+    return nil;
+}
+
++ (NSTask*) task {
+    return aTask;
+}
+
++ (void) terminateMPHelperTool {
+    NSString *      bundleID;
+
+    //In order to make the framework work normally by default ... we do a bare initialization
+    //of internalMacPortsAuthRef if the delegate hasn't iniitialzed it already
+    if (internalMacPortsAuthRef == NULL) {
+        OSStatus res = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &internalMacPortsAuthRef);
+        assert(res == noErr);
+    }
+
+    NSBundle * mpBundle = [NSBundle bundleForClass:[self class]];
+    NSString * installToolPath = [mpBundle pathForResource:@"MPHelperInstallTool" ofType:nil];
+    bundleID = [mpBundle bundleIdentifier];
+
+    BASSetDefaultRules(internalMacPortsAuthRef, 
+                        kMPHelperCommandSet, 
+                        (CFStringRef) bundleID, 
+                        NULL);
+    BASTerminateCommand(internalMacPortsAuthRef, 
+                        [bundleID UTF8String], 
+                        [installToolPath UTF8String]);
+    return;
+}
 
 #pragma mark -
Index: contrib/MacPorts_Framework/MPMacPorts.h
===================================================================
--- contrib/MacPorts_Framework/MPMacPorts.h	(revision 40518)
+++ contrib/MacPorts_Framework/MPMacPorts.h	(revision 65491)
@@ -77,4 +77,8 @@
 }
 
++ (NSString*) PKGPath;
+
++ (void) setPKGPath:(NSString*)newPath;
+
 /*!
  @brief Returns an MPMacPorts object that represents the MacPorts system on user's machine.
@@ -82,8 +86,4 @@
 + (MPMacPorts *)sharedInstance;
 
-+ (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options;
-
-//Names of messages below are subject to change
-+ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path;
 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options;
 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options;
@@ -222,4 +222,5 @@
 -(BOOL) authorizationMode;
 
+- (void) cancelCurrentCommand;
 
 //Notifications stuff for private use and testing purposes
Index: contrib/MacPorts_Framework/MPMacPorts.m
===================================================================
--- contrib/MacPorts_Framework/MPMacPorts.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPMacPorts.m	(revision 65491)
@@ -40,9 +40,7 @@
 @implementation MPMacPorts
 
-
 - (id) init {
-	return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil];
-}
-
+	return [self initWithPkgPath:[MPInterpreter PKGPath] portOptions:nil];
+}
 
 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
@@ -54,25 +52,40 @@
 }
 
++(NSString*) PKGPath {
+	return [MPInterpreter PKGPath];
+}
+
++(void) setPKGPath:(NSString*)newPath {
+    [MPInterpreter setPKGPath:newPath];
+}
+
+- (void) cancelCurrentCommand {
+    if ([[NSFileManager defaultManager] isWritableFileAtPath:[MPInterpreter PKGPath]]) {
+        NSLog(@"Terminating MPPortProcess");
+        NSTask *task = [MPInterpreter task];
+        if(task != nil && [task isRunning]) {
+            [task terminate];
+        }
+    } else {
+        NSLog(@"Terminating MPHelperTool");
+        [MPInterpreter terminateMPHelperTool];
+    }
+}
+
 + (MPMacPorts *)sharedInstance {
-	return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH];
-}
-
-+ (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options {
-	return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:options];
+	return [self sharedInstanceWithPkgPath:[MPInterpreter PKGPath] portOptions:nil];
 }
 
 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
 	@synchronized(self) {
+		if ([path isEqual:nil]) {
+			path = [MPInterpreter PKGPath];
+		}
+		if ([[MPInterpreter PKGPath] isNotEqualTo:path]) {
+            [self setPKGPath:path];
+        }
+		
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
 			[[self alloc] initWithPkgPath:path portOptions:options ]; // assignment not done here
-		}
-	}
-	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
-}
-
-+ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path {
-	@synchronized(self) {
-		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
-			[[self alloc] initWithPkgPath:path portOptions:nil ]; // assignment not done here
 		}
 	}
Index: contrib/MacPorts_Framework/MPMacPortsTest.m
===================================================================
--- contrib/MacPorts_Framework/MPMacPortsTest.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPMacPortsTest.m	(revision 65491)
@@ -66,5 +66,5 @@
 //Ask Randall about what exactly port tree path is
 -(void) testPathToPortIndex {
-	NSURL *pindex = [testPort pathToPortIndex:@"file:///Users/Armahg/macportsbuild/build1/"];
+	NSURL *pindex = [testPort pathToPortIndex:@"file:///Users/juanger/local/macportsbuild/branch-unprivileged/"];
 	STAssertNotNil(pindex, @"URL for port index should not be nil");
 }
@@ -75,5 +75,12 @@
 }
 
+-(void) testPKGPathChange {
+    NSString *newPkgPath = @"/Users/juanger/local/macportsbuild/branch-unprivileged/Library/Tcl";
 
+    STAssertEqualObjects([MPInterpreter PKGPath], @"/Library/Tcl", @"Initialy, the PKGPath should be /Library/Tcl");
+
+    [MPMacPorts sharedInstanceWithPkgPath:newPkgPath portOptions:nil];
+    STAssertEqualObjects([MPInterpreter PKGPath], newPkgPath, @"The global PKGPath should change as needed");
+}
 /*-(void) testSync {
 	NSError * syncError = nil;
Index: contrib/MacPorts_Framework/MPPort.h
===================================================================
--- contrib/MacPorts_Framework/MPPort.h	(revision 40518)
+++ contrib/MacPorts_Framework/MPPort.h	(revision 65491)
@@ -141,4 +141,11 @@
 - (void)deactivateWithVersion:(NSString *)version error:(NSError**)mpError;
 
+/*!
+ @brief Upgrades an outdated MPPort.
+ @discussion Only installed and active ports
+ should be upgraded
+ */
+- (void)upgradeWithError:(NSError**)mpError;
+
 
 /*!
@@ -291,3 +298,4 @@
 //Even more generic method to execute a Tcl command with any given number of args
 - (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params error:(NSError **)execError;
+
 @end
Index: contrib/MacPorts_Framework/MPPort.m
===================================================================
--- contrib/MacPorts_Framework/MPPort.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPPort.m	(revision 65491)
@@ -99,4 +99,8 @@
 		[self setObject:[interpreter arrayFromTclListAsString:[self objectForKey:@"categories"]] forKey:@"categories"];
 	}
+	if ([self objectForKey:@"variants"] != nil) {
+		[self setObject:[self objectForKey:@"variants"] forKey:@"variantsAsString"];
+		[self setObject:[interpreter arrayFromTclListAsString:[self objectForKey:@"variants"]] forKey:@"variants"];
+	}
 	if ([self objectForKey:@"depends_build"] != nil) {
 		[self setObject:[self objectForKey:@"depends_build"] forKey:@"depends_buildAsString"];
@@ -116,6 +120,6 @@
 	
 	@try {
-		if ([[self valueForKey:@"long_description"] characterAtIndex:0] == '{') {
-			[self setValue:[self valueForKey:@"description"] forKey:@"long_description"];
+		if ([[self valueForKey:@"description"] characterAtIndex:0] == '{') {
+			[self setValue:[self valueForKey:@"description"] forKey:@"description"];
 		}
 	} 
@@ -125,5 +129,20 @@
 														  @"Localizable",
 														  [NSBundle mainBundle],
-														  @"Port has an invalid desciption or long_description key.",
+														  @"Port has an invalid desciption key.",
+														  @"Error statement for exception raised when testing description.")]
+				forKey:@"description"];
+	}
+	
+	@try {
+		if ([[self valueForKey:@"long_description"] characterAtIndex:0] == '{') {
+			[self setValue:[self valueForKey:@"long_description"] forKey:@"long_description"];
+		}
+	} 
+	@catch (NSException *e) {
+		[self setValue:[NSString stringWithFormat:
+						NSLocalizedStringWithDefaultValue(@"setPortWithTclListAsStringDescreiptionError",
+														  @"Localizable",
+														  [NSBundle mainBundle],
+														  @"Port has an invalid long_description key.",
 														  @"Error statement for exception raised when testing long_description.")]
 				forKey:@"long_description"];
@@ -212,5 +231,11 @@
 													error:execError];		
 	}
-	
+    // I must get the new state of the port from the registry
+	// instead of just [self setState:MPPortStateLearnState];
+    //NSArray *receipts  = [[[MPRegistry sharedRegistry] installed:[self name]] objectForKey:[self name]];
+    //[self setStateFromReceipts:receipts];
+    [self removeObjectForKey:@"receipts"];
+    [self setState:MPPortStateLearnState];
+    
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[self sendGlobalExecNotification:procedure withStatus:@"Finished"];
@@ -242,21 +267,12 @@
 	[[MPNotifications sharedListener] setPerformingTclCommand:target];
 	
-	if ([parentMacPortsInstance authorizationMode]) {
-		[interpreter evaluateStringWithMPHelperTool:
-		 [NSString stringWithFormat:
-		  @"set portHandle [mportopen  %@  %@  %@]; mportexec  $portHandle %@; mportclose $portHandle", 
-		  [self valueForKey:@"porturl"], opts, vrnts, target]
-												error:execError];
-	}
-	else {
-		[interpreter evaluateStringWithPossiblePrivileges:
-		 [NSString stringWithFormat:
-		  @"set portHandle [mportopen  %@  %@  %@]; mportexec  $portHandle %@; mportclose $portHandle", 
-		  [self valueForKey:@"porturl"], opts, vrnts, target]
-													error:execError];
-	}
-	
-	
-	
+    [interpreter evaluateStringWithPossiblePrivileges:
+        [NSString stringWithFormat:
+            @"set portHandle [mportopen  %@  %@  %@]; mportexec  $portHandle %@; mportclose $portHandle", 
+            [self valueForKey:@"porturl"], opts, vrnts, target]
+        error:execError];
+	
+	
+	[self setState:MPPortStateLearnState];
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[self sendGlobalExecNotification:target withStatus:@"Finished"];
@@ -332,4 +348,8 @@
 }
 
+- (void)upgradeWithError:(NSError **)mError {
+	[self execPortProc:@"mportupgrade" withOptions:nil version:@"" error:mError];
+}
+
 -(void)configureWithOptions:(NSArray *)options variants:(NSArray *)variants error:(NSError **)mError {
 	[self exec:@"configure" withOptions:options variants:variants error:mError];
@@ -384,4 +404,5 @@
 }
 
+
 # pragma mark -
 
@@ -391,5 +412,10 @@
 - (id)objectForKey:(id)aKey {
 	if ([aKey isEqualToString:@"receipts"] && ![super objectForKey:aKey]) {
-		[self setObject:[[[MPRegistry sharedRegistry] installed:[self objectForKey:@"name"]] objectForKey:[self objectForKey:@"name"]]forKey:aKey];
+        NSArray *receipts = [[[MPRegistry sharedRegistry] installed:[self objectForKey:@"name"]] objectForKey:[self objectForKey:@"name"]];
+        if (receipts == nil) {
+            return nil;
+        } else {
+            [self setObject:receipts forKey:aKey];
+        }
 	}
 	return [super objectForKey:aKey];
@@ -437,5 +463,5 @@
 
 - (void)setStateFromReceipts:(NSArray *)receipts {
-	[self setObject:receipts forKey:@"receipts"];
+    [self setObject:receipts forKey:@"receipts"];
 	[self setState:MPPortStateLearnState];
 }
Index: contrib/MacPorts_Framework/MPPortManipulationTest.m
===================================================================
--- contrib/MacPorts_Framework/MPPortManipulationTest.m	(revision 40518)
+++ contrib/MacPorts_Framework/MPPortManipulationTest.m	(revision 65491)
@@ -19,7 +19,9 @@
 	BOOL ret = NO;
 	
+	MPMacPorts * port = [MPMacPorts sharedInstanceWithPkgPath:@"/Users/juanger/Projects/gsoc09-gui/MPGUI/build/Debug-InstallMacPorts/macports-1.8/Library/Tcl"
+	 					portOptions:nil];
+	NSLog(@"PkgPath1:  %@", [MPInterpreter PKGPath]);
 	MPRegistry * registry = [MPRegistry sharedRegistry];
-	MPMacPorts * port = [MPMacPorts sharedInstance];
-	
+	NSLog(@"PkgPath2:  %@", [MPInterpreter PKGPath]);
 	// Check if portName is installed
 	unsigned int installed = [[registry installed:portName] count];
@@ -42,5 +44,5 @@
 			return ret;
 		}
-		
+		NSLog(@"Uninstallation Successful.");
 		//Uninstallation was successful ... now check registry to make sure its gone
 		installed = [[registry installed:portName] count];
@@ -68,7 +70,9 @@
 			return ret;
 		}
-		
+		NSLog(@"Installation successful");
 		//Installation was successful ... now check registry to make sure its gone
 		installed = [[registry installed:portName] count];
+        NSLog(@"%@", [registry installed]);
+        
 		if (installed == 0) { //Uh oh ... is this suppose to happen?
 			NSLog(@"%@ is not installed after successful install operation ... double check this from commandline", portName);
@@ -120,13 +124,14 @@
 //		
 //		
-//	}
+//	}	
 //	
 //	//Double check somehow
 //	MPRegistry * registry = [MPRegistry sharedRegistry];
 //	NSLog(@"\n\n Result from registry is %@ \n\n", [registry installed:[keyArray objectAtIndex:0]]);
-	
+
 	PortManipulator * pm = [[PortManipulator alloc] init];
 	STAssertTrue([pm installUninstallManipulation:@"pngcrush"] , @"This test should always return true on success");
 	[pm release];
+    
 }
 
Index: contrib/MacPorts_Framework/MPPortProcess.h
===================================================================
--- contrib/MacPorts_Framework/MPPortProcess.h	(revision 65491)
+++ contrib/MacPorts_Framework/MPPortProcess.h	(revision 65491)
@@ -0,0 +1,19 @@
+//
+//  MPPortProcess.h
+//  MacPorts.Framework
+//
+//  Created by Juan Germán Castañeda Echevarría on 7/9/09.
+//  Copyright 2009 UNAM. All rights reserved.
+//
+
+#include <tcl.h>
+
+@interface MPPortProcess : NSObject {
+    Tcl_Interp *interpreter;
+    NSString *PKGPath;
+}
+
+
+- (oneway void)evaluateString:(bycopy id)statement;
+
+@end
Index: contrib/MacPorts_Framework/MPPortProcess.m
===================================================================
--- contrib/MacPorts_Framework/MPPortProcess.m	(revision 65491)
+++ contrib/MacPorts_Framework/MPPortProcess.m	(revision 65491)
@@ -0,0 +1,104 @@
+//
+//  MPPortProcess.m
+//  MacPorts.Framework
+//
+//  Created by Juan Germán Castañeda Echevarría on 7/9/09.
+//  Copyright 2009 UNAM. All rights reserved.
+//
+
+#import "MPPortProcess.h"
+#import "SimpleLog.h"
+
+@interface MPPortProcess (PrivateMethods)
+
+- (void)initializeInterpreter;
+
+@end
+
+@implementation MPPortProcess
+
+- (id)initWithPKGPath:(NSString*)pkgPath {
+    PKGPath = pkgPath;
+    [self initializeInterpreter];
+    return self;
+}
+
+- (oneway void)evaluateString:(bycopy id)statement {
+    // TODO Handle the posible errors and notifications
+    int retCode = Tcl_Eval(interpreter, [statement UTF8String]);
+    if (retCode != TCL_OK) {
+        Tcl_Obj * interpObj = Tcl_GetObjResult(interpreter);
+        int length, errCode;
+        NSString * errString = [NSString stringWithUTF8String:Tcl_GetStringFromObj(interpObj, &length)];
+        errCode = Tcl_GetErrno();
+    
+        NSLog(@"- %@ - %i", errString, errCode);
+        exit(errCode);
+    }
+    
+    exit(retCode);
+}
+
+
+#pragma mark Private Methods
+
+- (void)initializeInterpreter {
+    // Create interpreter
+    interpreter = Tcl_CreateInterp();
+	if(interpreter == NULL) {
+		NSLog(@"Error in Tcl_CreateInterp, aborting.");
+	}
+    // Initialize interpreter
+    if(Tcl_Init(interpreter) == TCL_ERROR) {
+		NSLog(@"Error in Tcl_Init: %s", Tcl_GetStringResult(interpreter));
+		Tcl_DeleteInterp(interpreter);
+	}
+    // Load macports_fastload.tcl from PKGPath/macports1.0
+    NSString * mport_fastload = [[@"source [file join \"" stringByAppendingString:PKGPath]
+								 stringByAppendingString:@"\" macports1.0 macports_fastload.tcl]"];
+	if(Tcl_Eval(interpreter, [mport_fastload UTF8String]) == TCL_ERROR) {
+		NSLog(@"Error in Tcl_EvalFile macports_fastload.tcl: %s", Tcl_GetStringResult(interpreter));
+		Tcl_DeleteInterp(interpreter);
+	}
+    // Load notifications methods
+    Tcl_CreateObjCommand(interpreter, "simplelog", SimpleLog_Command, NULL, NULL);
+	if (Tcl_PkgProvide(interpreter, "simplelog", "1.0") != TCL_OK) {
+		NSLog(@"Error in Tcl_PkgProvide: %s", Tcl_GetStringResult(interpreter));
+	}
+    // Load portProcessInit.tcl
+    NSString *portProcessInitPath = @"portProcessInit.tcl";
+    if( Tcl_EvalFile(interpreter, [portProcessInitPath UTF8String]) == TCL_ERROR) {
+		NSLog(@"Error in Tcl_EvalFile portProcessInit.tcl: %s", Tcl_GetStringResult(interpreter));
+		Tcl_DeleteInterp(interpreter);
+	}
+}
+
+@end
+
+int main(int argc, char const * argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    
+    NSConnection *portProcessConnection; 
+    portProcessConnection = [NSConnection defaultConnection];
+    NSString *PKGPath = [[NSString alloc] initWithCString:argv[1] encoding:NSUTF8StringEncoding];
+//    NSString *portProcessInitPath = [[NSString alloc] initWithCString:argv[2] encoding:NSUTF8StringEncoding];
+    
+    MPPortProcess *portProcess = [[MPPortProcess alloc] initWithPKGPath:PKGPath];
+    
+    // Vending portProcess
+    [portProcessConnection setRootObject:portProcess];
+    
+    // Register the named connection
+    if ( [portProcessConnection registerName:@"MPPortProcess"] ) {
+        NSLog( @"Successfully registered connection with port %@", 
+              [[portProcessConnection receivePort] description] );
+    } else {
+        NSLog( @"Name used by %@", 
+              [[[NSPortNameServer systemDefaultPortNameServer] portForName:@"MPPortProcess"] description] );
+    }
+    
+    // Wait for any message
+    [[NSRunLoop currentRunLoop] run];
+  	[pool release];
+    return 0;
+}
Index: contrib/MacPorts_Framework/MPRegistry.h
===================================================================
--- contrib/MacPorts_Framework/MPRegistry.h	(revision 40518)
+++ contrib/MacPorts_Framework/MPRegistry.h	(revision 65491)
@@ -61,5 +61,5 @@
 
 /*
- @brief Calls [self installed:name version:@""]
+ @brief Calls [self installed:name withVersion:@""]
  @param name Text to match the port name
  */
Index: contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	(revision 40518)
+++ contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	(revision 65491)
@@ -22,4 +22,52 @@
 
 /* Begin PBXBuildFile section */
+		2160109C1094C66300EE9CD0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12AA60E3E7E900026773D /* Cocoa.framework */; };
+		2160109F1094C6ED00EE9CD0 /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
+		216010A21094C6FD00EE9CD0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ECD970D0E465C7800488335 /* Security.framework */; };
+		216010A31094C6FD00EE9CD0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ECD970D0E465C7800488335 /* Security.framework */; };
+		216010C51094D34500EE9CD0 /* MPRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 48F811BE0CE4636A009630DE /* MPRegistry.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010C61094D34500EE9CD0 /* MPInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 48906AFB0C4230B700A3ED8A /* MPInterpreter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010C71094D34500EE9CD0 /* MacPorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E9925B0C82C45800219DDF /* MacPorts.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010C81094D34500EE9CD0 /* MPMacPorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E993920C82CAAE00219DDF /* MPMacPorts.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010C91094D34500EE9CD0 /* MPIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 487679530C98C2EB00577C59 /* MPIndex.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010CA1094D34500EE9CD0 /* MPPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 487679670C98C55E00577C59 /* MPPort.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010CB1094D34500EE9CD0 /* MPReceipt.h in Headers */ = {isa = PBXBuildFile; fileRef = 48A866A80CD364F700B521BC /* MPReceipt.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010CC1094D34500EE9CD0 /* MPMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010CD1094D34500EE9CD0 /* MPNotifications.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E270D070E158CED00BAE687 /* MPNotifications.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		216010CE1094D34500EE9CD0 /* BetterAuthorizationSampleLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EC260710E426FC80013BC48 /* BetterAuthorizationSampleLib.h */; };
+		216010CF1094D34500EE9CD0 /* MPHelperCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EC260950E4272D20013BC48 /* MPHelperCommon.h */; };
+		216010D01094D34500EE9CD0 /* MPHelperNotificationsCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E8563B60E5DDF7000C1D73C /* MPHelperNotificationsCommon.h */; };
+		216010D11094D34500EE9CD0 /* MPHelperNotificationsProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E8563B70E5DDF7000C1D73C /* MPHelperNotificationsProtocol.h */; };
+		216010D21094D34500EE9CD0 /* MPNotifications+IPCAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE6DDCC0E6276AA00FB2115 /* MPNotifications+IPCAdditions.h */; };
+		216010D41094D34500EE9CD0 /* MPHelperInstallTool in Resources */ = {isa = PBXBuildFile; fileRef = 6EC260870E426FF10013BC48 /* MPHelperInstallTool */; };
+		216010D51094D34500EE9CD0 /* MPPortProcess in Resources */ = {isa = PBXBuildFile; fileRef = 21D9543E100940EE00DEF58A /* MPPortProcess */; };
+		216010D61094D34500EE9CD0 /* MPHelperTool in Resources */ = {isa = PBXBuildFile; fileRef = 6ED12A4A0E3E552F0026773D /* MPHelperTool */; };
+		216010D71094D34500EE9CD0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
+		216010D81094D34500EE9CD0 /* init.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 48E9939E0C82CEB000219DDF /* init.tcl */; };
+		216010D91094D34500EE9CD0 /* ToDo.txt in Resources */ = {isa = PBXBuildFile; fileRef = 6E44A00C0E2DAD66007DE8EC /* ToDo.txt */; };
+		216010DA1094D34500EE9CD0 /* interpInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 6EE93E660E493AC600AECE9E /* interpInit.tcl */; };
+		216010DB1094D34500EE9CD0 /* portProcessInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 21D954711009475200DEF58A /* portProcessInit.tcl */; };
+		216010DD1094D34500EE9CD0 /* MPInterpreter.m in Sources */ = {isa = PBXBuildFile; fileRef = 48906AFC0C4230B700A3ED8A /* MPInterpreter.m */; };
+		216010DE1094D34500EE9CD0 /* MPMacPorts.m in Sources */ = {isa = PBXBuildFile; fileRef = 48E993930C82CAAE00219DDF /* MPMacPorts.m */; };
+		216010DF1094D34500EE9CD0 /* MPIndex.m in Sources */ = {isa = PBXBuildFile; fileRef = 487679540C98C2EB00577C59 /* MPIndex.m */; };
+		216010E01094D34500EE9CD0 /* MPPort.m in Sources */ = {isa = PBXBuildFile; fileRef = 487679680C98C55E00577C59 /* MPPort.m */; };
+		216010E11094D34500EE9CD0 /* MPReceipt.m in Sources */ = {isa = PBXBuildFile; fileRef = 48A866A90CD364F700B521BC /* MPReceipt.m */; };
+		216010E21094D34500EE9CD0 /* MPMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */; };
+		216010E31094D34500EE9CD0 /* MPRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 48F811BF0CE4638C009630DE /* MPRegistry.m */; };
+		216010E41094D34500EE9CD0 /* MPNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E270D080E158CED00BAE687 /* MPNotifications.m */; };
+		216010E51094D34500EE9CD0 /* BetterAuthorizationSampleLib.c in Sources */ = {isa = PBXBuildFile; fileRef = 6EC260700E426FC80013BC48 /* BetterAuthorizationSampleLib.c */; };
+		216010E61094D34500EE9CD0 /* MPHelperCommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 6EC260960E4272D20013BC48 /* MPHelperCommon.c */; };
+		216010E71094D34500EE9CD0 /* MPHelperNotificationsCommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 6E8563B50E5DDF7000C1D73C /* MPHelperNotificationsCommon.c */; };
+		216010E81094D34500EE9CD0 /* MPNotifications+IPCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EE6DDCD0E6276AA00FB2115 /* MPNotifications+IPCAdditions.m */; };
+		216010EA1094D34500EE9CD0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12AA60E3E7E900026773D /* Cocoa.framework */; };
+		216010EB1094D34500EE9CD0 /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
+		216010EC1094D34500EE9CD0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ECD970D0E465C7800488335 /* Security.framework */; };
+		218DEE2610162091003B5A3B /* SimpleLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 218DED83101612F1003B5A3B /* SimpleLog.m */; };
+		21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EB6FC900E45DEA80057962C /* Foundation.framework */; };
+		21D954431009411400DEF58A /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
+		21D954471009412F00DEF58A /* MPPortProcess.m in Sources */ = {isa = PBXBuildFile; fileRef = 21D954461009412F00DEF58A /* MPPortProcess.m */; };
+		21D954721009475200DEF58A /* portProcessInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 21D954711009475200DEF58A /* portProcessInit.tcl */; };
+		21D9548C1009522100DEF58A /* MPPortProcess in Resources */ = {isa = PBXBuildFile; fileRef = 21D9543E100940EE00DEF58A /* MPPortProcess */; };
+		21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
 		481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		481D04A30CDAAAFD00D4A550 /* MPMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */; };
@@ -35,5 +83,4 @@
 		48A866AB0CD364F700B521BC /* MPReceipt.m in Sources */ = {isa = PBXBuildFile; fileRef = 48A866A90CD364F700B521BC /* MPReceipt.m */; };
 		48E9925C0C82C45800219DDF /* MacPorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E9925B0C82C45800219DDF /* MacPorts.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		48E992980C82C98C00219DDF /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48E992970C82C98C00219DDF /* Tcl.framework */; };
 		48E993940C82CAAE00219DDF /* MPMacPorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E993920C82CAAE00219DDF /* MPMacPorts.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		48E993950C82CAAE00219DDF /* MPMacPorts.m in Sources */ = {isa = PBXBuildFile; fileRef = 48E993930C82CAAE00219DDF /* MPMacPorts.m */; };
@@ -67,6 +114,4 @@
 		6ECD98110E484E8400488335 /* MPHelperTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ECD98100E484E8400488335 /* MPHelperTool.m */; };
 		6ECD99C60E48B91B00488335 /* MPHelperToolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ECD99C50E48B91B00488335 /* MPHelperToolTest.m */; };
-		6ED12A550E3E55DF0026773D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12A540E3E55DF0026773D /* Security.framework */; };
-		6ED12A560E3E55DF0026773D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12A540E3E55DF0026773D /* Security.framework */; };
 		6ED12AF10E3E9E210026773D /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
 		6EE6DDA40E626D4A00FB2115 /* MacPorts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* MacPorts.framework */; };
@@ -78,8 +123,35 @@
 		6EE93FAB0E495C2200AECE9E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ECD970D0E465C7800488335 /* Security.framework */; };
 		8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
-		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
+		216010BF1094D34500EE9CD0 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 6ED12A490E3E552F0026773D;
+			remoteInfo = MPHelperTool;
+		};
+		216010C11094D34500EE9CD0 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 6EC260860E426FF10013BC48;
+			remoteInfo = MPHelperInstallTool;
+		};
+		216010C31094D34500EE9CD0 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 21D9543D100940EE00DEF58A;
+			remoteInfo = MPPortProcess;
+		};
+		21D9544B1009416100DEF58A /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 21D9543D100940EE00DEF58A;
+			remoteInfo = MPPortProcess;
+		};
 		6E1AE8460E232D0700F6D7BC /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -113,7 +185,13 @@
 
 /* Begin PBXFileReference section */
-		0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
 		089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
-		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+		21067BB50FE5B25800CAD732 /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
+		216010F21094D34500EE9CD0 /* MacPorts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MacPorts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		218DED82101612F1003B5A3B /* SimpleLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLog.h; sourceTree = "<group>"; };
+		218DED83101612F1003B5A3B /* SimpleLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleLog.m; sourceTree = "<group>"; };
+		21D9543E100940EE00DEF58A /* MPPortProcess */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPPortProcess; sourceTree = BUILT_PRODUCTS_DIR; };
+		21D954461009412F00DEF58A /* MPPortProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPortProcess.m; sourceTree = "<group>"; };
+		21D954491009413800DEF58A /* MPPortProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPortProcess.h; sourceTree = "<group>"; };
+		21D954711009475200DEF58A /* portProcessInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = portProcessInit.tcl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
 		32DBCF5E0370ADEE00C91783 /* MacPorts.Framework_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacPorts.Framework_Prefix.pch; sourceTree = "<group>"; };
 		481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MPMutableDictionary.h; sourceTree = "<group>"; };
@@ -135,8 +213,7 @@
 		48A866A90CD364F700B521BC /* MPReceipt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPReceipt.m; sourceTree = "<group>"; };
 		48E9925B0C82C45800219DDF /* MacPorts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacPorts.h; sourceTree = "<group>"; };
-		48E992970C82C98C00219DDF /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = /System/Library/Frameworks/Tcl.framework; sourceTree = "<absolute>"; };
 		48E993920C82CAAE00219DDF /* MPMacPorts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMacPorts.h; sourceTree = "<group>"; };
 		48E993930C82CAAE00219DDF /* MPMacPorts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMacPorts.m; sourceTree = "<group>"; };
-		48E9939E0C82CEB000219DDF /* init.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl; sourceTree = "<group>"; };
+		48E9939E0C82CEB000219DDF /* init.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
 		48F811BE0CE4636A009630DE /* MPRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRegistry.h; sourceTree = "<group>"; };
 		48F811BF0CE4638C009630DE /* MPRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRegistry.m; sourceTree = "<group>"; };
@@ -165,5 +242,4 @@
 		6ECD99C50E48B91B00488335 /* MPHelperToolTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPHelperToolTest.m; sourceTree = "<group>"; };
 		6ED12A4A0E3E552F0026773D /* MPHelperTool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPHelperTool; sourceTree = BUILT_PRODUCTS_DIR; };
-		6ED12A540E3E55DF0026773D /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
 		6ED12AA60E3E7E900026773D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
 		6EE6DD9E0E626D2800FB2115 /* MPHelperToolIPCTester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPHelperToolIPCTester; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -171,6 +247,5 @@
 		6EE6DDCC0E6276AA00FB2115 /* MPNotifications+IPCAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPNotifications+IPCAdditions.h"; sourceTree = "<group>"; };
 		6EE6DDCD0E6276AA00FB2115 /* MPNotifications+IPCAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPNotifications+IPCAdditions.m"; sourceTree = "<group>"; };
-		6EE93E660E493AC600AECE9E /* interpInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = interpInit.tcl; sourceTree = "<group>"; };
-		6EE93E780E495B3100AECE9E /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = Library/Frameworks/Tcl.framework; sourceTree = SDKROOT; };
+		6EE93E660E493AC600AECE9E /* interpInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = interpInit.tcl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		8DC2EF5B0486A6940098B216 /* MacPorts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MacPorts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -178,4 +253,23 @@
 
 /* Begin PBXFrameworksBuildPhase section */
+		216010E91094D34500EE9CD0 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				216010EA1094D34500EE9CD0 /* Cocoa.framework in Frameworks */,
+				216010EB1094D34500EE9CD0 /* Tcl.framework in Frameworks */,
+				216010EC1094D34500EE9CD0 /* Security.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		21D9543C100940EE00DEF58A /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */,
+				21D954431009411400DEF58A /* Tcl.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		489DD8F10C94365F00595506 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
@@ -198,8 +292,8 @@
 			buildActionMask = 2147483647;
 			files = (
-				6ED12A550E3E55DF0026773D /* Security.framework in Frameworks */,
 				6ED12AF10E3E9E210026773D /* Tcl.framework in Frameworks */,
 				6EC2609E0E42950C0013BC48 /* CoreFoundation.framework in Frameworks */,
 				6EB6FC910E45DEA80057962C /* Foundation.framework in Frameworks */,
+				216010A31094C6FD00EE9CD0 /* Security.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -218,7 +312,7 @@
 			buildActionMask = 2147483647;
 			files = (
-				8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
-				48E992980C82C98C00219DDF /* Tcl.framework in Frameworks */,
-				6ED12A560E3E55DF0026773D /* Security.framework in Frameworks */,
+				2160109C1094C66300EE9CD0 /* Cocoa.framework in Frameworks */,
+				2160109F1094C6ED00EE9CD0 /* Tcl.framework in Frameworks */,
+				216010A21094C6FD00EE9CD0 /* Security.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -235,4 +329,6 @@
 				6EC260870E426FF10013BC48 /* MPHelperInstallTool */,
 				6EE6DD9E0E626D2800FB2115 /* MPHelperToolIPCTester */,
+				21D9543E100940EE00DEF58A /* MPPortProcess */,
+				216010F21094D34500EE9CD0 /* MacPorts.framework */,
 			);
 			name = Products;
@@ -242,4 +338,5 @@
 			isa = PBXGroup;
 			children = (
+				21D954381009409E00DEF58A /* MPPortProcess */,
 				6EE6DDA80E626D8000FB2115 /* IPCTesting */,
 				6ED12A460E3E54A80026773D /* MPHelperTools */,
@@ -257,5 +354,5 @@
 				6EB6FC900E45DEA80057962C /* Foundation.framework */,
 				6ECD970D0E465C7800488335 /* Security.framework */,
-				6EE93E780E495B3100AECE9E /* Tcl.framework */,
+				21067BB50FE5B25800CAD732 /* Tests-Info.plist */,
 			);
 			name = "MacPorts Foundation";
@@ -280,4 +377,5 @@
 				6E44A00C0E2DAD66007DE8EC /* ToDo.txt */,
 				6EE93E660E493AC600AECE9E /* interpInit.tcl */,
+				21D954711009475200DEF58A /* portProcessInit.tcl */,
 			);
 			name = Resources;
@@ -308,7 +406,4 @@
 			isa = PBXGroup;
 			children = (
-				6ED12A540E3E55DF0026773D /* Security.framework */,
-				48E992970C82C98C00219DDF /* Tcl.framework */,
-				1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */,
 			);
 			name = "Linked Frameworks";
@@ -318,7 +413,17 @@
 			isa = PBXGroup;
 			children = (
-				0867D69BFE84028FC02AAC07 /* Foundation.framework */,
 			);
 			name = "Other Frameworks";
+			sourceTree = "<group>";
+		};
+		21D954381009409E00DEF58A /* MPPortProcess */ = {
+			isa = PBXGroup;
+			children = (
+				21D954491009413800DEF58A /* MPPortProcess.h */,
+				21D954461009412F00DEF58A /* MPPortProcess.m */,
+				218DED82101612F1003B5A3B /* SimpleLog.h */,
+				218DED83101612F1003B5A3B /* SimpleLog.m */,
+			);
+			name = MPPortProcess;
 			sourceTree = "<group>";
 		};
@@ -395,4 +500,33 @@
 
 /* Begin PBXHeadersBuildPhase section */
+		216010C41094D34500EE9CD0 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				216010C51094D34500EE9CD0 /* MPRegistry.h in Headers */,
+				216010C61094D34500EE9CD0 /* MPInterpreter.h in Headers */,
+				216010C71094D34500EE9CD0 /* MacPorts.h in Headers */,
+				216010C81094D34500EE9CD0 /* MPMacPorts.h in Headers */,
+				216010C91094D34500EE9CD0 /* MPIndex.h in Headers */,
+				216010CA1094D34500EE9CD0 /* MPPort.h in Headers */,
+				216010CB1094D34500EE9CD0 /* MPReceipt.h in Headers */,
+				216010CC1094D34500EE9CD0 /* MPMutableDictionary.h in Headers */,
+				216010CD1094D34500EE9CD0 /* MPNotifications.h in Headers */,
+				216010CE1094D34500EE9CD0 /* BetterAuthorizationSampleLib.h in Headers */,
+				216010CF1094D34500EE9CD0 /* MPHelperCommon.h in Headers */,
+				216010D01094D34500EE9CD0 /* MPHelperNotificationsCommon.h in Headers */,
+				216010D11094D34500EE9CD0 /* MPHelperNotificationsProtocol.h in Headers */,
+				216010D21094D34500EE9CD0 /* MPNotifications+IPCAdditions.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		218DEE4010162175003B5A3B /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		6ED12AD30E3E9AE10026773D /* Headers */ = {
 			isa = PBXHeadersBuildPhase;
@@ -430,4 +564,44 @@
 
 /* Begin PBXNativeTarget section */
+		216010BD1094D34500EE9CD0 /* MacPorts-embeddable */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 216010EE1094D34500EE9CD0 /* Build configuration list for PBXNativeTarget "MacPorts-embeddable" */;
+			buildPhases = (
+				216010C41094D34500EE9CD0 /* Headers */,
+				216010D31094D34500EE9CD0 /* Resources */,
+				216010DC1094D34500EE9CD0 /* Sources */,
+				216010E91094D34500EE9CD0 /* Frameworks */,
+				2136ECA01097A29500833416 /* Install */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				216010BE1094D34500EE9CD0 /* PBXTargetDependency */,
+				216010C01094D34500EE9CD0 /* PBXTargetDependency */,
+				216010C21094D34500EE9CD0 /* PBXTargetDependency */,
+			);
+			name = "MacPorts-embeddable";
+			productInstallPath = "$(HOME)/Library/Frameworks";
+			productName = "MacPorts Foundation";
+			productReference = 216010F21094D34500EE9CD0 /* MacPorts.framework */;
+			productType = "com.apple.product-type.framework";
+		};
+		21D9543D100940EE00DEF58A /* MPPortProcess */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 21D954481009413000DEF58A /* Build configuration list for PBXNativeTarget "MPPortProcess" */;
+			buildPhases = (
+				218DEE4010162175003B5A3B /* Headers */,
+				21D9543B100940EE00DEF58A /* Sources */,
+				21D9543C100940EE00DEF58A /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = MPPortProcess;
+			productName = MPPortProcess;
+			productReference = 21D9543E100940EE00DEF58A /* MPPortProcess */;
+			productType = "com.apple.product-type.tool";
+		};
 		489DD8F30C94365F00595506 /* Test */ = {
 			isa = PBXNativeTarget;
@@ -508,5 +682,4 @@
 				8DC2EF540486A6940098B216 /* Sources */,
 				8DC2EF560486A6940098B216 /* Frameworks */,
-				6E49F4F40E00DD520030C3AF /* ShellScript */,
 			);
 			buildRules = (
@@ -515,4 +688,5 @@
 				6ED12A530E3E55A50026773D /* PBXTargetDependency */,
 				6EC2608C0E4270110013BC48 /* PBXTargetDependency */,
+				21D9544C1009416100DEF58A /* PBXTargetDependency */,
 			);
 			name = MacPorts;
@@ -541,7 +715,9 @@
 				6ED12A490E3E552F0026773D /* MPHelperTool */,
 				8DC2EF4F0486A6940098B216 /* MacPorts */,
+				216010BD1094D34500EE9CD0 /* MacPorts-embeddable */,
 				489DD8F30C94365F00595506 /* Test */,
 				DFE353650CFB8F0C003BACFC /* Docs */,
 				6EE6DD9D0E626D2800FB2115 /* MPHelperToolIPCTester */,
+				21D9543D100940EE00DEF58A /* MPPortProcess */,
 			);
 		};
@@ -549,4 +725,19 @@
 
 /* Begin PBXResourcesBuildPhase section */
+		216010D31094D34500EE9CD0 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				216010D41094D34500EE9CD0 /* MPHelperInstallTool in Resources */,
+				216010D51094D34500EE9CD0 /* MPPortProcess in Resources */,
+				216010D61094D34500EE9CD0 /* MPHelperTool in Resources */,
+				216010D71094D34500EE9CD0 /* InfoPlist.strings in Resources */,
+				216010D81094D34500EE9CD0 /* init.tcl in Resources */,
+				216010D91094D34500EE9CD0 /* ToDo.txt in Resources */,
+				216010DA1094D34500EE9CD0 /* interpInit.tcl in Resources */,
+				216010DB1094D34500EE9CD0 /* portProcessInit.tcl in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		489DD8EF0C94365F00595506 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
@@ -568,4 +759,5 @@
 			files = (
 				6EB6FA460E43ECD60057962C /* MPHelperInstallTool in Resources */,
+				21D9548C1009522100DEF58A /* MPPortProcess in Resources */,
 				6EB6FA420E43ECCE0057962C /* MPHelperTool in Resources */,
 				8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
@@ -573,4 +765,5 @@
 				6E44A00D0E2DAD66007DE8EC /* ToDo.txt in Resources */,
 				6EE93E670E493AC600AECE9E /* interpInit.tcl in Resources */,
+				21D954721009475200DEF58A /* portProcessInit.tcl in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -579,4 +772,18 @@
 
 /* Begin PBXShellScriptBuildPhase section */
+		2136ECA01097A29500833416 /* Install */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			name = Install;
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = "/usr/bin/env ruby";
+			shellScript = "# This script just copies the framework to the build directory so that it can be found by Pallet\n# in any configuration.\nrequire 'fileutils'\n\nif File.directory? \"#{ENV['SRCROOT']}/../MacPorts_Framework/build/MacPorts.framework\"\n  FileUtils.rm_rf \"#{ENV['SRCROOT']}/../MacPorts_Framework/build/MacPorts.framework\"\nend\n\nFileUtils.cp_r \"#{ENV['SRCROOT']}/../MacPorts_Framework/build/#{ENV['CONFIGURATION']}/MacPorts.framework\", \"#{ENV['SRCROOT']}/../MacPorts_Framework/build\"\n";
+		};
 		489DD8F20C94365F00595506 /* ShellScript */ = {
 			isa = PBXShellScriptBuildPhase;
@@ -592,17 +799,4 @@
 			shellPath = /bin/sh;
 			shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n\n#rm -rf notifications.dylib\n\n\n";
-		};
-		6E49F4F40E00DD520030C3AF /* ShellScript */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-			);
-			outputPaths = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "#This script is to copy the build product to a subfolder \"build\"\n#of the project directory so that whoever checks out this plugin will have\n#access to the built MacPorts.framework\n#Do I really need it since build products go to your default / project / target\n#specific Build Products path?\n\nditto $CONFIGURATION_BUILD_DIR/MacPorts.framework build/MacPorts.framework\n\n";
 		};
 		DFE353640CFB8F0C003BACFC /* ShellScript */ = {
@@ -622,4 +816,32 @@
 
 /* Begin PBXSourcesBuildPhase section */
+		216010DC1094D34500EE9CD0 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				216010DD1094D34500EE9CD0 /* MPInterpreter.m in Sources */,
+				216010DE1094D34500EE9CD0 /* MPMacPorts.m in Sources */,
+				216010DF1094D34500EE9CD0 /* MPIndex.m in Sources */,
+				216010E01094D34500EE9CD0 /* MPPort.m in Sources */,
+				216010E11094D34500EE9CD0 /* MPReceipt.m in Sources */,
+				216010E21094D34500EE9CD0 /* MPMutableDictionary.m in Sources */,
+				216010E31094D34500EE9CD0 /* MPRegistry.m in Sources */,
+				216010E41094D34500EE9CD0 /* MPNotifications.m in Sources */,
+				216010E51094D34500EE9CD0 /* BetterAuthorizationSampleLib.c in Sources */,
+				216010E61094D34500EE9CD0 /* MPHelperCommon.c in Sources */,
+				216010E71094D34500EE9CD0 /* MPHelperNotificationsCommon.c in Sources */,
+				216010E81094D34500EE9CD0 /* MPNotifications+IPCAdditions.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		21D9543B100940EE00DEF58A /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				21D954471009412F00DEF58A /* MPPortProcess.m in Sources */,
+				218DEE2610162091003B5A3B /* SimpleLog.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		489DD8F00C94365F00595506 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
@@ -682,4 +904,24 @@
 
 /* Begin PBXTargetDependency section */
+		216010BE1094D34500EE9CD0 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 6ED12A490E3E552F0026773D /* MPHelperTool */;
+			targetProxy = 216010BF1094D34500EE9CD0 /* PBXContainerItemProxy */;
+		};
+		216010C01094D34500EE9CD0 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 6EC260860E426FF10013BC48 /* MPHelperInstallTool */;
+			targetProxy = 216010C11094D34500EE9CD0 /* PBXContainerItemProxy */;
+		};
+		216010C21094D34500EE9CD0 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 21D9543D100940EE00DEF58A /* MPPortProcess */;
+			targetProxy = 216010C31094D34500EE9CD0 /* PBXContainerItemProxy */;
+		};
+		21D9544C1009416100DEF58A /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 21D9543D100940EE00DEF58A /* MPPortProcess */;
+			targetProxy = 21D9544B1009416100DEF58A /* PBXContainerItemProxy */;
+		};
 		6E1AE8470E232D0700F6D7BC /* PBXTargetDependency */ = {
 			isa = PBXTargetDependency;
@@ -719,4 +961,6 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
 				COPY_PHASE_STRIP = NO;
 				DYLIB_COMPATIBILITY_VERSION = 1;
@@ -735,5 +979,4 @@
 					"$(inherited)",
 					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
-					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
 				);
 				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
@@ -762,5 +1005,4 @@
 					"$(inherited)",
 					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
-					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)",
 				);
 				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
@@ -775,12 +1017,13 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)";
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
 				DEBUG_INFORMATION_FORMAT = stabs;
 				GCC_ENABLE_OBJC_GC = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH)";
-				PREBINDING = NO;
-				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+				ONLY_ACTIVE_ARCH = NO;
+				PREBINDING = NO;
+				SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
 				ZERO_LINK = NO;
 			};
@@ -788,4 +1031,18 @@
 		};
 		1DEB91B308733DA50010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64";
+				GCC_ENABLE_OBJC_GC = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+				SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		216010B01094C7FC00EE9CD0 /* Release-Tiger */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -793,8 +1050,289 @@
 				ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
 				GCC_ENABLE_OBJC_GC = YES;
+				GCC_VERSION = 4.0;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				PREBINDING = NO;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B11094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = MPHelperInstallTool;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B21094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = MPHelperTool;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B31094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				FRAMEWORK_VERSION = A;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = MacPorts.Framework_Prefix.pch;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
+				);
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\"";
+				PRODUCT_NAME = MacPorts;
+				WRAPPER_EXTENSION = framework;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B41094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(NATIVE_ARCH)";
+				COPY_PHASE_STRIP = YES;
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(value)",
+					"$(DEVELOPER_FRAMEWORKS_DIR_QUOTED)",
+				);
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
+				INFOPLIST_FILE = "Test-Info.plist";
+				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
+				OTHER_LDFLAGS = (
+					"-framework",
+					Cocoa,
+					"-framework",
+					SenTestingKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = Test;
+				WRAPPER_EXTENSION = octest;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B51094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				PRODUCT_NAME = Docs;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B61094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_ENABLE_OBJC_GC = required;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+				INSTALL_PATH = /usr/local/bin;
+				OTHER_LDFLAGS = (
+					"-framework",
+					Foundation,
+					"-framework",
+					AppKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = MPHelperToolIPCTester;
+				SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010B71094C7FC00EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+				INSTALL_PATH = /usr/local/bin;
+				OTHER_LDFLAGS = (
+					"-framework",
+					Foundation,
+					"-framework",
+					AppKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = MPPortProcess;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		216010EF1094D34500EE9CD0 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64";
+				CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
+				COPY_PHASE_STRIP = NO;
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				FRAMEWORK_VERSION = A;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = MacPorts.Framework_Prefix.pch;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "@executable_path/../Frameworks";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
+				);
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\"";
+				PRODUCT_NAME = MacPorts;
+				SYMROOT = build;
+				WRAPPER_EXTENSION = framework;
+				ZERO_LINK = NO;
+			};
+			name = Debug;
+		};
+		216010F01094D34500EE9CD0 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64";
+				CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				FRAMEWORK_VERSION = A;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = MacPorts.Framework_Prefix.pch;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "@executable_path/../Frameworks";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
+				);
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\"";
+				PRODUCT_NAME = MacPorts;
+				WRAPPER_EXTENSION = framework;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		216010F11094D34500EE9CD0 /* Release-Tiger */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "ppc i386 ppc64 x86_64";
+				CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				FRAMEWORK_VERSION = A;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = MacPorts.Framework_Prefix.pch;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "@executable_path/../Frameworks";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
+				);
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
+				LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SRCROOT)\"";
+				PRODUCT_NAME = MacPorts;
+				WRAPPER_EXTENSION = framework;
+				ZERO_LINK = NO;
+			};
+			name = "Release-Tiger";
+		};
+		21D95440100940EF00DEF58A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+				INSTALL_PATH = /usr/local/bin;
+				OTHER_LDFLAGS = (
+					"-framework",
+					Foundation,
+					"-framework",
+					AppKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = MPPortProcess;
+			};
+			name = Debug;
+		};
+		21D95441100940EF00DEF58A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+				INSTALL_PATH = /usr/local/bin;
+				OTHER_LDFLAGS = (
+					"-framework",
+					Foundation,
+					"-framework",
+					AppKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = MPPortProcess;
 				ZERO_LINK = NO;
 			};
@@ -820,4 +1358,5 @@
 				INFOPLIST_FILE = "Test-Info.plist";
 				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
+				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = (
 					"-framework",
@@ -1006,4 +1545,5 @@
 				1DEB91AE08733DA50010E9CD /* Debug */,
 				1DEB91AF08733DA50010E9CD /* Release */,
+				216010B31094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1015,4 +1555,25 @@
 				1DEB91B208733DA50010E9CD /* Debug */,
 				1DEB91B308733DA50010E9CD /* Release */,
+				216010B01094C7FC00EE9CD0 /* Release-Tiger */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		216010EE1094D34500EE9CD0 /* Build configuration list for PBXNativeTarget "MacPorts-embeddable" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				216010EF1094D34500EE9CD0 /* Debug */,
+				216010F01094D34500EE9CD0 /* Release */,
+				216010F11094D34500EE9CD0 /* Release-Tiger */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		21D954481009413000DEF58A /* Build configuration list for PBXNativeTarget "MPPortProcess" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				21D95440100940EF00DEF58A /* Debug */,
+				21D95441100940EF00DEF58A /* Release */,
+				216010B71094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1024,4 +1585,5 @@
 				489DD8F70C94366000595506 /* Debug */,
 				489DD8F80C94366000595506 /* Release */,
+				216010B41094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1033,4 +1595,5 @@
 				6EC260890E426FF30013BC48 /* Debug */,
 				6EC2608A0E426FF30013BC48 /* Release */,
+				216010B11094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1042,4 +1605,5 @@
 				6ED12A4C0E3E55300026773D /* Debug */,
 				6ED12A4D0E3E55300026773D /* Release */,
+				216010B21094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1051,4 +1615,5 @@
 				6EE6DDA00E626D2900FB2115 /* Debug */,
 				6EE6DDA10E626D2900FB2115 /* Release */,
+				216010B61094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
@@ -1060,4 +1625,5 @@
 				DFE353660CFB8F0C003BACFC /* Debug */,
 				DFE353670CFB8F0C003BACFC /* Release */,
+				216010B51094C7FC00EE9CD0 /* Release-Tiger */,
 			);
 			defaultConfigurationIsVisible = 0;
Index: contrib/MacPorts_Framework/SimpleLog.h
===================================================================
--- contrib/MacPorts_Framework/SimpleLog.h	(revision 65491)
+++ contrib/MacPorts_Framework/SimpleLog.h	(revision 65491)
@@ -0,0 +1,12 @@
+/*
+ *  SimpleLog.h
+ *  MacPorts.Framework
+ *
+ *  Created by Juan Germán Castañeda Echevarría on 7/21/09.
+ *  Copyright 2009 UNAM. All rights reserved.
+ *
+ */
+
+#include <tcl.h>
+
+int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
Index: contrib/MacPorts_Framework/SimpleLog.m
===================================================================
--- contrib/MacPorts_Framework/SimpleLog.m	(revision 65491)
+++ contrib/MacPorts_Framework/SimpleLog.m	(revision 65491)
@@ -0,0 +1,76 @@
+/*
+ *  SimpleLog.m
+ *  MacPorts.Framework
+ *
+ *  Created by Juan Germán Castañeda Echevarría on 7/21/09.
+ *  Copyright 2009 UNAM. All rights reserved.
+ *
+ */
+
+#include "SimpleLog.h"
+
+#define MPSEPARATOR @"_&MP&_"
+
+int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]) {
+    int tclResult = TCL_ERROR;
+	NSMutableString * data;
+	
+	++objv, --objc;
+	
+	if (objc) {
+		int tclCount;
+		const char **tclElements;
+		
+		tclResult = Tcl_SplitList(interpreter, Tcl_GetString(*objv), &tclCount, &tclElements);
+		
+		
+		if (tclResult == TCL_OK) {
+			if (tclCount > 0) {
+                NSLog([NSString stringWithUTF8String:tclElements[0]]);
+				data = [NSMutableString stringWithUTF8String:tclElements[0]];
+				[data appendString:MPSEPARATOR];
+				
+				if(tclCount > 1 && tclElements[1]) {
+                    NSLog([NSString stringWithUTF8String:tclElements[1]]);
+					[data appendString:[NSString stringWithUTF8String:tclElements[1]]];
+					[data appendString:MPSEPARATOR];
+				}
+				else {
+					[data appendString:@"None"];
+					[data appendString:MPSEPARATOR];
+				}
+				
+				if(tclCount > 2 && tclElements[2]) {
+                    NSLog([NSString stringWithUTF8String:tclElements[2]]);
+					[data appendString:[NSString stringWithUTF8String:tclElements[2]]];
+					[data appendString:MPSEPARATOR];
+				}
+				else {
+					[data appendString:@"None"];
+					[data appendString:MPSEPARATOR];
+				}
+			}
+			else {
+				data = [NSMutableString stringWithFormat:@"None%@None%@None%@", MPSEPARATOR, MPSEPARATOR, MPSEPARATOR ];
+			}
+		}
+	}
+    
+    //Now get the actual message
+    ++objv; --objc;
+    if (objc) {
+        [data appendString:[NSString stringWithUTF8String:Tcl_GetString(*objv)]];
+    }
+    else {
+        [data appendString:@"None"];
+    }
+    
+    id theProxy = [NSConnection
+                   rootProxyForConnectionWithRegisteredName:@"MPNotifications"
+                   host:nil];
+    [theProxy sendIPCNotification:data];
+    
+    NSLog(@"-----%@", data);
+    
+	return tclResult;
+}
Index: contrib/MacPorts_Framework/Tests-Info.plist
===================================================================
--- contrib/MacPorts_Framework/Tests-Info.plist	(revision 65491)
+++ contrib/MacPorts_Framework/Tests-Info.plist	(revision 65491)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1.0</string>
+</dict>
+</plist>
Index: contrib/MacPorts_Framework/init.tcl
===================================================================
--- contrib/MacPorts_Framework/init.tcl	(revision 40518)
+++ contrib/MacPorts_Framework/init.tcl	(revision 65491)
@@ -5,5 +5,5 @@
 #Set ui_options to log all messages to stdout and notify system
 #filtering is done on the Obj-C side of things
-set ui_options(ports_debug) "yes"
+# set ui_options(ports_debug) "yes"
 set ui_options(ports_verbose) "yes"
 
@@ -52,13 +52,13 @@
             } else {
                 return {}
-			}
-		}
+            }
+        }
         msg {
             if {[ui_isset ports_quiet]} {
-                return {}
-			} else {
-				return {stdout}
-			}
-		}
+              return {}
+            } else {
+              return {stdout}
+            }
+        }
         error {
         	return {stderr}
@@ -77,71 +77,80 @@
 #This is currently under works ... a reasonable solution
 #should be coming up soon
-proc ui_init {priority prefix channels message} {
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
+proc macports::ui_init {priority args} {
+    switch $priority {
+  		msg {
+  			set nottype "MPMsgNotification" 
+  		}
+  		debug {
+  			set nottype "MPDebugNotification"
+  			puts "Recieved Debug"
+  		}
+  		warn {
+  			set nottype "MPWarnNotification"
+  		}
+  		error {
+  			set nottype "MPErrorNotification"
+  			puts "Recieved Error"
+  		}
+  		info {
+  			set nottype "MPInfoNotification"
+  			puts "Recieved Info"
+  		}
+  		default {
+  			set nottype "MPDefaultNotification"
+  		}	
+  	}
+  
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels [ui_channels $priority]
-    } catch * {
+    } else {
         set channels [ui_channels_default $priority]
     }
-    
-    #set channels [ui_channels $priority]
-    
+
     # Simplify ui_$priority.
     set nbchans [llength $channels]
     if {$nbchans == 0} {
-        proc ::ui_$priority {str} [subst {
-        	notifications send $nottype "$chan $prefix" "\$str"
+        proc ::ui_$priority {args} [subst {
+          notifications send $nottype "$chan $prefix" "\$str"
         }]
     } else {
-        try {
+        if {[llength [info commands ui_prefix]] > 0} {
             set prefix [ui_prefix $priority]
-        } catch * {
+        } else {
             set prefix [ui_prefix_default $priority]
         }
-        
-        #set prefix [ui_prefix $priority]
-        
-        if {$nbchans == 1} {
-            set chan [lindex $channels 0]
-            
-            proc ::ui_$priority {str} [subst { 
-            	puts $chan "$prefix\$str"
-            	notifications send $nottype "$chan $prefix" "\$str"
-            }]
+
+        if {[llength [info commands ::ui_init]] > 0} {
+            eval ::ui_init $priority $prefix $channels $args
         } else {
-        	proc ::ui_$priority {str} [subst {
-        		foreach chan \$channels {
-        			puts $chan "$prefix\$str"
-        			notifications send $nottype "$chan $prefix" "\$str"
-        		}
-        	}]
-        }
-        
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
+            if {$nbchans == 1} {
+                set chan [lindex $channels 0]
+                proc ::ui_$priority {args} [subst {
+                  if {\[lindex \$args 0\] == "-nonewline"} {
+                    puts $chan "$prefix\[lindex \$args 1\]"
+                    notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
+                  } else {
+                    puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                    notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
+                  }
+                }]
+            } else {
+                proc ::ui_$priority {args} [subst {
+                    foreach chan \$channels {
+                      if {\[lindex \$args 0\] == "-nonewline"} {
+                        puts $chan "$prefix\[lindex \$args 1\]"
+                        notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
+                      } else {
+                        puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                        notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
+                      }
+                    }
+                }]
+            }
+        }
+
+        # Call ui_$priority
+        eval ::ui_$priority $args
     }
 }
@@ -151,5 +160,5 @@
 #and log error Information in a similar fashion to code
 #in macports.tcl.
-proc mportuninstall {portname {v ""} optionslist} {
+proc mportuninstall {portname {v ""} {optionslist ""}} {
 	if {[catch {portuninstall::uninstall $portname $v $optionslist} result]} {
 		
@@ -181,4 +190,14 @@
 }
 
+proc mportupgrade {portname} {
+    array set depscache {}
+	if {[catch {macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache} result]} {
+			
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Upgrade $portname failed: $result"
+			return 1
+	}
+}
 
 
Index: contrib/MacPorts_Framework/interpInit.tcl
===================================================================
--- contrib/MacPorts_Framework/interpInit.tcl	(revision 40518)
+++ contrib/MacPorts_Framework/interpInit.tcl	(revision 65491)
@@ -53,13 +53,13 @@
             } else {
                 return {}
-			}
-		}
+            }
+        }
         msg {
             if {[ui_isset ports_quiet]} {
-                return {}
-			} else {
-				return {stdout}
-			}
-		}
+              return {}
+            } else {
+              return {stdout}
+            }
+        }
         error {
         	return {stderr}
@@ -77,35 +77,33 @@
 #This is currently under works ... a reasonable solution
 #should be coming up soon
-proc ui_init {priority prefix channels message} {
-	#puts "INSIDE ui_init priority with prefix $prefix and message $message"
-	
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
+proc macports::ui_init {priority args} {
+    switch $priority {
+      msg {
+        set nottype "MPMsgNotification" 
+      }
+      debug {
+        set nottype "MPDebugNotification"
+        puts "Recieved Debug"
+      }
+      warn {
+        set nottype "MPWarnNotification"
+      }
+      error {
+        set nottype "MPErrorNotification"
+        puts "Recieved Error"
+      }
+      info {
+        set nottype "MPInfoNotification"
+        puts "Recieved Info"
+      }
+      default {
+        set nottype "MPDefaultNotification"
+      }
+    }
+
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels [ui_channels $priority]
-    } catch * {
+    } else {
         set channels [ui_channels_default $priority]
     }
@@ -117,33 +115,45 @@
     if {$nbchans == 0} {
         proc ::ui_$priority {str} [subst {
-        	simplelog "$nottype $chan $prefix" "\$str" 
+          simplelog "$nottype $chan $prefix" "\$str" 
         }]
     } else {
-        try {
-            set prefix [ui_prefix $priority]
-        } catch * {
-            set prefix [ui_prefix_default $priority]
-        }
-        
-        #set prefix [ui_prefix $priority]
-        
+      if {[llength [info commands ui_prefix]] > 0} {
+          set prefix [ui_prefix $priority]
+      } else {
+          set prefix [ui_prefix_default $priority]
+      }
+
+      if {[llength [info commands ::ui_init]] > 0} {
+          eval ::ui_init $priority $prefix $channels $args
+      } else {
         if {$nbchans == 1} {
-            set chan [lindex $channels 0]
-            
-            proc ::ui_$priority {str} [subst { 
-            	puts $chan "$prefix\$str"
-            	simplelog "$nottype $chan $prefix" "\$str" 
-            }]
+          set chan [lindex $channels 0]
+
+          proc ::ui_$priority {args} [subst {
+            if {\[lindex \$args 0\] == "-nonewline"} {
+              puts $chan "$prefix\[lindex \$args 1\]"
+              simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+            } else {
+              puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+              simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+            }
+          }]
         } else {
-        	proc ::ui_$priority {str} [subst {
-        		foreach chan \$channels {
-        			puts $chan "$prefix\$str"
-        			simplelog "$nottype $chan $prefix" "\$str" 
-        		}
-        	}]
-        }
-        
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
+          proc ::ui_$priority {args} [subst {
+            foreach chan \$channels {
+              if {\[lindex \$args 0\] == "-nonewline"} {
+                puts $chan "$prefix\[lindex \$args 1\]"
+                simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+              } else {
+                puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+              }
+            }
+          }]
+        }
+      }
+
+      # Call ui_$priority
+      eval ::ui_$priority $args
     }
 }
@@ -184,5 +194,14 @@
 }
 
-
+proc mportupgrade {portname} {
+    array set depscache {}
+	if {[catch {macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache} result]} {
+			
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Upgrade $portname failed: $result"
+			return 1
+	}
+}
 
 # Initialize dport
Index: contrib/MacPorts_Framework/portProcessInit.tcl
===================================================================
--- contrib/MacPorts_Framework/portProcessInit.tcl	(revision 65491)
+++ contrib/MacPorts_Framework/portProcessInit.tcl	(revision 65491)
@@ -0,0 +1,211 @@
+package require macports
+package require simplelog
+
+
+
+#Set ui_options to log all messages to stdout and notify system
+#filtering is done on the Obj-C side of things
+set ui_options(ports_debug) "yes"
+set ui_options(ports_verbose) "yes"
+
+# ui_options accessor
+proc ui_isset {val} {
+	global ui_options
+	if {[info exists ui_options($val)]} {
+		if {$ui_options($val) == "yes"} {
+			return 1
+		}
+	}
+	return 0
+}
+
+# UI Callback
+proc ui_prefix {priority} {
+    switch $priority {
+        debug {
+        	return "DEBUG: "
+        }
+        error {
+        	return "Error: "
+        }
+        warn {
+        	return "Warning: "
+        }
+        default {
+        	return ""
+        }
+    }
+}
+
+proc ui_channels {priority} {
+    global logfd
+    switch $priority {
+        debug {
+            if {[ui_isset ports_debug]} {
+            	return {stderr}
+            } else {
+            	return {}
+            }
+        }
+        info {
+            if {[ui_isset ports_verbose]} {
+                return {stdout}
+            } else {
+                return {}
+			}
+		}
+        msg {
+            if {[ui_isset ports_quiet]} {
+                return {}
+			} else {
+				return {stdout}
+			}
+		}
+        error {
+        	return {stderr}
+        }
+        default {
+        	return {stdout}
+        }
+    }
+}
+
+
+
+#Modifying UI initialization to enable notifications
+#Redefine ui_$pritority to throw global notifications
+#This is currently under works ... a reasonable solution
+#should be coming up soon
+proc macports::ui_init {priority args} {
+    switch $priority {
+  		msg {
+  			set nottype "MPMsgNotification" 
+  		}
+  		debug {
+  			set nottype "MPDebugNotification"
+  			puts "Recieved Debug"
+  		}
+  		warn {
+  			set nottype "MPWarnNotification"
+  		}
+  		error {
+  			set nottype "MPErrorNotification"
+  			puts "Recieved Error"
+  		}
+  		info {
+  			set nottype "MPInfoNotification"
+  			puts "Recieved Info"
+  		}
+  		default {
+  			set nottype "MPDefaultNotification"
+  		}	
+  	}
+  
+    # Get the list of channels.
+    if {[llength [info commands ui_channels]] > 0} {
+        set channels [ui_channels $priority]
+    } else {
+        set channels [ui_channels_default $priority]
+    }
+
+    # Simplify ui_$priority.
+    set nbchans [llength $channels]
+    if {$nbchans == 0} {
+        proc ::ui_$priority {args} [subst {
+          simplelog "$nottype $chan $prefix" "\$str"
+        }]
+    } else {
+        if {[llength [info commands ui_prefix]] > 0} {
+            set prefix [ui_prefix $priority]
+        } else {
+            set prefix [ui_prefix_default $priority]
+        }
+
+        if {[llength [info commands ::ui_init]] > 0} {
+            eval ::ui_init $priority $prefix $channels $args
+        } else {
+            if {$nbchans == 1} {
+                set chan [lindex $channels 0]
+                proc ::ui_$priority {args} [subst {
+                  if {\[lindex \$args 0\] == "-nonewline"} {
+                    puts $chan "$prefix\[lindex \$args 1\]"
+                    simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+                  } else {
+                    puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                    simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+                  }
+                }]
+            } else {
+                proc ::ui_$priority {args} [subst {
+                    foreach chan \$channels {
+                      if {\[lindex \$args 0\] == "-nonewline"} {
+                        puts $chan "$prefix\[lindex \$args 1\]"
+                        simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+                      } else {
+                        puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                        simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+                      }
+                    }
+                }]
+            }
+        }
+
+        # Call ui_$priority
+        eval ::ui_$priority $args
+    }
+}
+
+
+#Wrapping the following API routines to catch errors
+#and log error Information in a similar fashion to code
+#in macports.tcl. Note optionslist is not being used for now
+set mp_empty_list [list]
+proc mportuninstall {portname {v ""} {optionslist ""} } {
+	if {[catch {portuninstall::uninstall $portname $v [array get options]} result]} {
+		
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Uninstall $portname $v failed: $result"
+			return 1
+	}
+}
+
+proc mportactivate {portname {v ""} {optionslist ""}} {
+	if {[catch {portimage::activate $portname $v $optionslist} result]} {
+			
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Activate $portname $v failed: $result"
+			return 1
+	}
+}
+
+proc mportdeactivate {portname {v ""} {optionslist ""} } {
+	if {[catch {portimage::deactivate $portname $v $optionslist} result]} {
+			
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Deactivate $portname $v failed: $result"
+			return 1
+	}
+}
+
+proc mportupgrade {portname} {
+    array set depscache {}
+	if {[catch {macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache} result]} {
+			
+			global errorInfo
+			ui_debug "$errorInfo"
+			ui_error "Upgrade $portname failed: $result"
+			return 1
+	}
+}
+
+# Initialize dport
+# This must be done following parse of global options, as some options are
+# evaluated by dportinit.
+if {[catch {mportinit ui_options global_options global_variations} result]} {
+	global errorInfo
+	puts "$errorInfo"
+	fatal "Failed to initialize ports system, $result"
+}
