[69978] branches/gsoc10-gui/MacPorts_Framework/MPPort.m

tzikis at macports.org tzikis at macports.org
Sat Jul 24 17:27:20 PDT 2010


Revision: 69978
          http://trac.macports.org/changeset/69978
Author:   tzikis at macports.org
Date:     2010-07-24 17:27:16 -0700 (Sat, 24 Jul 2010)
Log Message:
-----------
The framework now has the ability to check for default_variants, by using the system() command to invoke port variants. It is very slow, and left only as a reference

Modified Paths:
--------------
    branches/gsoc10-gui/MacPorts_Framework/MPPort.m

Modified: branches/gsoc10-gui/MacPorts_Framework/MPPort.m
===================================================================
--- branches/gsoc10-gui/MacPorts_Framework/MPPort.m	2010-07-24 22:37:19 UTC (rev 69977)
+++ branches/gsoc10-gui/MacPorts_Framework/MPPort.m	2010-07-25 00:27:16 UTC (rev 69978)
@@ -126,11 +126,32 @@
 	
 	//Code for fetching default variants
 	if ([self objectForKey:@"default_variants"] != nil) {
-		NSLog(@"Default Variants str: %@", string);
+		//NSLog(@"Default Variants str: %@", string);
 		[self setObject:[self objectForKey:@"default_variants"] forKey:@"default_variantsAsString"];
 		[self setObject:[interpreter arrayFromTclListAsString:[self objectForKey:@"default_variants"]] forKey:@"default_variants"];
 	}
+	 
+	NSMutableArray *default_variants= [NSMutableArray arrayWithCapacity:10];
+	char port_command[256];
+	strcpy(port_command, "port variants ");
+	strcat(port_command, [[self objectForKey:@"name"] cStringUsingEncoding: NSASCIIStringEncoding]);
+	strcat(port_command, " | grep \"\\[+]\" | sed 's/.*\\]//; s/:.*//' >> mpfw_default_variants");
 	
+	system(port_command);
+	FILE * file = fopen("mpfw_default_variants", "r");
+	char buffer[256];
+	while(!feof(file))
+	{
+		char * temp = fgets(buffer,256,file);
+		if(temp == NULL) continue;
+		buffer[strlen(buffer)-1]='\0';
+		//printf("default variants: %s\n", buffer);
+		[default_variants addObject:[NSString stringWithCString:buffer]];
+    }
+	[self setObject:default_variants forKey: @"default_variants"];
+	fclose(file);
+	//unlink("mpfw_default_variants");
+	
 	@try {
 		if ([[self valueForKey:@"description"] characterAtIndex:0] == '{') {
 			[self setValue:[self valueForKey:@"description"] forKey:@"description"];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100724/5ff0e264/attachment.html>


More information about the macports-changes mailing list