[52364] branches/gsoc09-gui/MacPorts_Framework

juanger at macports.org juanger at macports.org
Sun Jun 14 20:25:43 PDT 2009


Revision: 52364
          http://trac.macports.org/changeset/52364
Author:   juanger at macports.org
Date:     2009-06-14 20:25:43 -0700 (Sun, 14 Jun 2009)
Log Message:
-----------
Trying to get PKGPath working without breaking the tests

Modified Paths:
--------------
    branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
    branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
    branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.h
    branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
    branches/gsoc09-gui/MacPorts_Framework/MPMacPortsTest.m
    branches/gsoc09-gui/MacPorts_Framework/MPPortManipulationTest.m
    branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj

Added Paths:
-----------
    branches/gsoc09-gui/MacPorts_Framework/Tests-Info.plist

Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h	2009-06-15 03:25:43 UTC (rev 52364)
@@ -52,7 +52,6 @@
 
 #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"
 #define MPFrameworkErrorDomain	@"MacPortsFrameworkErrorDomain"
@@ -85,9 +84,6 @@
 #define MPTRACE					@"ports_trace"
 
 
-
-
-
 /*!
  @class MPInterpreter
  @abstract Tcl interpreter object
@@ -104,6 +100,11 @@
 	
 }
 
++(NSString*) PKGPath;
+
++(void) setPKGPath:(NSString*)newPath;
+
+
 //Internal methods
 -(BOOL) setOptionsForNewTclPort:(NSArray *)options;
 

Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m	2009-06-15 03:25:43 UTC (rev 52364)
@@ -38,14 +38,14 @@
 #include "MPHelperCommon.h"
 #include "MPHelperNotificationsProtocol.h"
 static AuthorizationRef internalMacPortsAuthRef;
+static NSString* PKGPath = @"/Library/Tcl";
 
 
-
 #pragma mark -
 
 @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;
 	NSMutableString *msg;
@@ -164,6 +164,14 @@
 //tool
 static NSString * tclInterpreterPkgPath = nil;
 
++(NSString*) PKGPath {
+	return PKGPath;
+}
+
++(void) setPKGPath:(NSString*)newPath {
+	PKGPath = newPath;
+}
+
 #pragma mark -
 #pragma mark Internal Methods
 //Internal method for initializing actual C Tcl interpreter
@@ -184,7 +192,7 @@
 	}
 	
 	if (path == nil)
-		path = MP_DEFAULT_PKG_PATH;
+		path = PKGPath;
 	
 	
 	NSString * mport_fastload = [[@"source [file join \"" stringByAppendingString:path]
@@ -247,7 +255,7 @@
 	Tcl_DeleteInterp(_interpreter);
 	
 	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];
 	
@@ -261,7 +269,6 @@
 
 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
 	if (self = [super init]) {
-		
 		[self initTclInterpreter:&_interpreter withPath:path];
 		
 		//set port options maybe I should do this elsewhere?
@@ -284,27 +291,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 ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil
+			|| [PKGPath isNotEqualTo:path] ) {
 			[[self alloc] initWithPkgPath:path portOptions:options]; // assignment not done here
 		}
 	}

Modified: branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.h	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.h	2009-06-15 03:25:43 UTC (rev 52364)
@@ -76,18 +76,11 @@
 	
 }
 
-+ (void) initialize;
-+ (void) setPKGPath:(NSString *) path;
-
 /*!
  @brief Returns an MPMacPorts object that represents the MacPorts system on user's machine.
  */
 + (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;
 - (BOOL) setPortOptions:(NSArray *)options;

Modified: branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m	2009-06-15 03:25:43 UTC (rev 52364)
@@ -36,23 +36,13 @@
 #import "MPMacPorts.h"
 #import "MPNotifications.h"
 
-static NSString* PKGPath;
 
 @implementation MPMacPorts
 
-+ (void) initialize {
-	PKGPath = MP_DEFAULT_PKG_PATH;
-}
-
-+ (void) setPKGPath: (NSString*) path {
-	PKGPath = path;
-}
-
 - (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 {
 	if (self = [super init]) {
 		interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path portOptions:nil];
@@ -62,31 +52,22 @@
 }
 
 + (MPMacPorts *)sharedInstance {
-	return [self sharedInstanceWithPkgPath:PKGPath];
+	return [self sharedInstanceWithPkgPath:[MPInterpreter PKGPath] portOptions:nil];
 }
 
-+ (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options {
-	return [self sharedInstanceWithPkgPath:PKGPath portOptions:options];
-}
-
 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
 	@synchronized(self) {
-		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
+		if ([path isEqual:nil]) {
+			path = [MPInterpreter PKGPath];
+		}
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil
+		|| [[MPInterpreter PKGPath] isNotEqualTo:path] ) {
 			[[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
-		}
-	}
-	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
-}
-
 - (BOOL) setPortOptions:(NSArray *)options {
 	return [interpreter setOptionsForNewTclPort:options];
 }

Modified: branches/gsoc09-gui/MacPorts_Framework/MPMacPortsTest.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPMacPortsTest.m	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPMacPortsTest.m	2009-06-15 03:25:43 UTC (rev 52364)
@@ -65,7 +65,7 @@
 
 //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");
 }
 
@@ -74,7 +74,14 @@
 	STAssertNotNil(searchResults, @"This dictionary should have at least %d key value pairs", [searchResults count]);
 }
 
+-(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;
 	[testPort sync:&syncError];

Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortManipulationTest.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortManipulationTest.m	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortManipulationTest.m	2009-06-15 03:25:43 UTC (rev 52364)
@@ -18,9 +18,11 @@
 -(BOOL) installUninstallManipulation:(NSString *)portName {
 	BOOL ret = NO;
 	
+	MPMacPorts * port = [MPMacPorts sharedInstanceWithPkgPath:@"/Users/juanger/local/macportsbuild/branch-unprivileged/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];
 	
@@ -41,7 +43,7 @@
 			//I guess we should just return here
 			return ret;
 		}
-		
+		NSLog(@"Uninstallation Successful.");
 		//Uninstallation was successful ... now check registry to make sure its gone
 		installed = [[registry installed:portName] count];
 		if (installed > 0) { //Uh oh ... is this suppose to happen?
@@ -67,9 +69,11 @@
 			//I guess we should just return here
 			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);
 			//for now return
@@ -124,7 +128,7 @@
 //	//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];

Modified: branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2009-06-15 03:13:42 UTC (rev 52363)
+++ branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2009-06-15 03:25:43 UTC (rev 52364)
@@ -115,6 +115,7 @@
 		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>"; };
 		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>"; };
 		481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MPMutableDictionary.m; sourceTree = "<group>"; };
@@ -257,6 +258,7 @@
 				6EB6FC900E45DEA80057962C /* Foundation.framework */,
 				6ECD970D0E465C7800488335 /* Security.framework */,
 				6EE93E780E495B3100AECE9E /* Tcl.framework */,
+				21067BB50FE5B25800CAD732 /* Tests-Info.plist */,
 			);
 			name = "MacPorts Foundation";
 			sourceTree = "<group>";
@@ -822,6 +824,7 @@
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
 				INFOPLIST_FILE = "Test-Info.plist";
 				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
+				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = (
 					"-framework",
 					Cocoa,

Added: branches/gsoc09-gui/MacPorts_Framework/Tests-Info.plist
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/Tests-Info.plist	                        (rev 0)
+++ branches/gsoc09-gui/MacPorts_Framework/Tests-Info.plist	2009-06-15 03:25:43 UTC (rev 52364)
@@ -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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090614/b337bc86/attachment.html>


More information about the macports-changes mailing list