[52318] branches/universal-sanity/base

toby at macports.org toby at macports.org
Sat Jun 13 20:38:59 PDT 2009


Revision: 52318
          http://trac.macports.org/changeset/52318
Author:   toby at macports.org
Date:     2009-06-13 20:38:59 -0700 (Sat, 13 Jun 2009)
Log Message:
-----------
merge from trunk

Modified Paths:
--------------
    branches/universal-sanity/base/src/macports1.0/macports.tcl
    branches/universal-sanity/base/src/pextlib1.0/tracelib.c
    branches/universal-sanity/base/src/port/port.tcl
    branches/universal-sanity/base/src/port1.0/portlivecheck.tcl
    branches/universal-sanity/base/src/port1.0/porttrace.tcl
    branches/universal-sanity/base/src/port1.0/portutil.tcl
    branches/universal-sanity/base/src/registry1.0/portuninstall.tcl

Property Changed:
----------------
    branches/universal-sanity/base/


Property changes on: branches/universal-sanity/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:51872-52079
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:51872-52317
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/universal-sanity/base/src/macports1.0/macports.tcl
===================================================================
--- branches/universal-sanity/base/src/macports1.0/macports.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/macports1.0/macports.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -1958,16 +1958,11 @@
 #                  dependencies ports.
 # accDeps -> accumulator for recursive calls
 # return 0 if everything was ok, an non zero integer otherwise.
-proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1} {accDepsFlag 0}} {
+proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1}} {
 
     array set portinfo [mportinfo $mport]
     set depends {}
     set deptypes {}
-    if {$accDepsFlag == 0} {
-        array set accDeps {}
-    } else {
-        upvar accDeps accDeps
-    }
 
     # progress indicator
     if {![macports::ui_isset ports_debug]} {
@@ -2019,53 +2014,46 @@
     }
 
     set subPorts {}
+    set options [ditem_key $mport options]
+    set variations [ditem_key $mport variations]
 
     foreach depspec $depends {
-        # grab the portname portion of the depspec
-        set dep_portname [lindex [split $depspec :] end]
+        # Is that dependency satisfied or this port installed?
+        # If we don't skip or if it is not, add it to the list.
+        if {!$skipSatisfied || ![_mportispresent $mport $depspec]} {
+            # grab the portname portion of the depspec
+            set dep_portname [lindex [split $depspec :] end]
 
-        # Find the porturl
-        if {[catch {set res [mportlookup $dep_portname]} error]} {
-            global errorInfo
-            ui_debug "$errorInfo"
-            ui_error "Internal error: port lookup failed: $error"
-            return 1
-        }
+            # Find the porturl
+            if {[catch {set res [mportlookup $dep_portname]} error]} {
+                global errorInfo
+                ui_debug "$errorInfo"
+                ui_error "Internal error: port lookup failed: $error"
+                return 1
+            }
 
-        array unset portinfo
-        array set portinfo [lindex $res 1]
-        if {[info exists portinfo(porturl)]} {
-            set porturl $portinfo(porturl)
-        } else {
-            if {$skipSatisfied && [registry::entry_exists_for_name $dep_portname]} {
-                ui_warn "Dependency '$dep_portname' is installed but not present in the index"
-            } else {
+            array unset portinfo
+            array set portinfo [lindex $res 1]
+            if {![info exists portinfo(porturl)]} {
                 ui_error "Dependency '$dep_portname' not found."
                 return 1
             }
-        }
 
-        # Is that dependency satisfied or this port installed?
-        # If we don't skip or if it is not, add it to the list.
-        if {!$skipSatisfied || ![_mportispresent $mport $depspec]} {
-            set options [ditem_key $mport options]
-            set variations [ditem_key $mport variations]
-            # Figure out the subport.
-            set subport [mportopen $porturl $options $variations]
-            
-            # Append the sub-port's provides to the port's requirements list.
-            ditem_append_unique $mport requires "[ditem_key $subport provides]"
-
-            if {$recurseDeps} {
-                # Skip the port if it's already in the accumulated list.
-                if {![info exists accDeps($dep_portname)]} {
-                    # Add it to the list
-                    set accDeps($dep_portname) 1
-
-                    # We'll recursively iterate on it.
+            # Figure out the subport. Check the open_mports list first, since
+            # we potentially leak mport references if we mportopen each time,
+            # because mportexec only closes each open mport once.
+            set subport [dlist_search $macports::open_mports porturl $portinfo(porturl)]
+            if {$subport == {}} {
+                # We haven't opened this one yet.
+                set subport [mportopen $portinfo(porturl) $options $variations]
+                if {$recurseDeps} {
+                    # Add to the list we need to recurse on.
                     lappend subPorts $subport
                 }
             }
+
+            # Append the sub-port's provides to the port's requirements list.
+            ditem_append_unique $mport requires "[ditem_key $subport provides]"
         }
     }
 
@@ -2073,7 +2061,7 @@
     if {$recurseDeps} {
         foreach subport $subPorts {
             # Sub ports should be installed (all dependencies must be satisfied).
-            set res [mportdepends $subport "" $recurseDeps $skipSatisfied 1]
+            set res [mportdepends $subport "" $recurseDeps $skipSatisfied]
             if {$res != 0} {
                 return $res
             }

Modified: branches/universal-sanity/base/src/pextlib1.0/tracelib.c
===================================================================
--- branches/universal-sanity/base/src/pextlib1.0/tracelib.c	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/pextlib1.0/tracelib.c	2009-06-14 03:38:59 UTC (rev 52318)
@@ -82,6 +82,10 @@
 	}
 	
 	name=strdup(Tcl_GetString(objv[2]));
+	if (!name) {
+	    Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
+	    return TCL_ERROR;
+	}
 	
 	return TCL_OK;
 }
@@ -107,8 +111,12 @@
 	
 	len=strlen(Tcl_GetString(objv[2]))+2;
 	sandbox=(char*)malloc(len);
+	if (!sandbox) {
+	    Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
+	    return TCL_ERROR;
+	}
 	memset(sandbox, 0, len);
-	strcpy(sandbox, Tcl_GetString(objv[2]));
+	strlcpy(sandbox, Tcl_GetString(objv[2]), len);
 	for(t=sandbox;(t=strchr(t+1, ':'));)
 	{
 		/* : -> \0 */
@@ -210,10 +218,23 @@
 	{
 		char * t, * _;
 		
-		filemap=(char*)malloc(1024);
+		size_t remaining = 1024;
+		filemap=(char*)malloc(remaining);
+		if (!filemap) {
+		    ui_warn("send_file_map: memory allocation failed");
+	        return;
+		}
 		t=filemap;
 		
-		#define append_allow(path, resolution) do{strcpy(t, path); t+=strlen(t)+1; *t++=resolution; *t++=0;}while(0);
+		#define append_allow(path, resolution) do { strlcpy(t, path, remaining); \
+		                                            if (remaining < (strlen(t)+3)) \
+		                                                remaining=0; \
+		                                            else \
+		                                                remaining-=strlen(t)+3; \
+		                                            t+=strlen(t)+1; \
+		                                            *t++=resolution; \
+		                                            *t++=0; \
+		                                          } while(0);
 		if(enable_fence)
 		{
 			for(_=sandbox; *_; _+=strlen(_)+1)
@@ -226,22 +247,25 @@
 			/* If there is no SDK we will allow everything in /usr /System/Library etc, else add binaries to allow, and redirect root to SDK. */
 			if(sdk&&*sdk)
 			{
-				char buf[260]="/Developer/SDKs/";
-				strcat(buf, sdk);
+				char buf[260];
+				buf[0] = '\0';
+				strlcat(buf, Tcl_GetVar(interp, "macports::developer_dir", TCL_GLOBAL_ONLY), 260);
+				strlcat(buf, "/SDKs/", 260);
+				strlcat(buf, sdk, 260);
 			
 				append_allow("/usr/bin", 0);
 				append_allow("/usr/sbin", 0);
 				append_allow("/usr/libexec/gcc", 0);
 				append_allow("/System/Library/Perl", 0);
 				append_allow("/", 1);
-				strcpy(t-1, buf);
+				strlcpy(t-1, buf, remaining);
 				t+=strlen(t)+1;
 			}else
 			{
 				append_allow("/usr", 0);
 				append_allow("/System/Library", 0);
 				append_allow("/Library", 0);
-				append_allow("/Developer", 0);
+				append_allow(Tcl_GetVar(interp, "macports::developer_dir", TCL_GLOBAL_ONLY), 0);
 			}
 		}else
 			append_allow("/", 0);
@@ -267,42 +291,40 @@
 {
 	char * port=0;
 	size_t len=1;
-	char resolution; 
+	char resolution='!';
+		
+	Tcl_SetVar(interp, "path", path, 0);
+	Tcl_Eval(interp, "registry::file_registered $path");
+	port=strdup(Tcl_GetStringResult(interp));
+	if (!port) {
+		ui_warn("dep_check: memory allocation failed");
+	    return;
+	}
+	Tcl_UnsetVar(interp, "path", 0);
 	
-	/* If there aren't deps then allow anything. (Useful for extract) */
-	if(!depends)
-		resolution='+';
-	else
+	if(*port!='0'||port[1])
 	{
-		resolution='!';
-		
-		Tcl_SetVar(interp, "path", path, 0);
-		Tcl_Eval(interp, "registry::file_registered $path");
-		port=strdup(Tcl_GetStringResult(interp));
-		Tcl_UnsetVar(interp, "path", 0);
+		char * t;
 	
-		if(*port!='0'||port[1])
+		t=depends;
+		for(;*t;t+=strlen(t)+1)
 		{
-			char * t;
-		
-			t=depends;
-			for(;*t;t+=strlen(t)+1)
+			if(!strcmp(t, port))
 			{
-				if(!strcmp(t, port))
-				{
-					resolution='+';
-					break;
-				}
+				resolution='+';
+				break;
 			}
-		}else if(*port=='0'&&!port[1])
-			strcpy(port, "*unknown*");
+		}
 	}
 	
-	if(resolution!='+')
-		ui_info("trace: access denied to %s (%s)", path, port);
+	if(resolution!='+') {
+	    if(*port=='0'&&!port[1])
+		    ui_info("trace: access denied to %s (*unknown*)", path);
+		else
+		    ui_info("trace: access denied to %s (%s)", path, port);
+    }
 
-	if(port)
-		free(port);
+	free(port);
 	
 	if(send(sock, &len, sizeof(len), 0)==-1)
 		ui_warn("tracelib send failed");
@@ -374,7 +396,7 @@
 
 	
 	sun.sun_family=AF_UNIX;
-	strcpy(sun.sun_path, name);
+	strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
 	if(bind(sock, (struct sockaddr*)&sun, sizeof(sun))==-1)
 	{
 		Tcl_SetResult(interp, "Cannot bind socket", TCL_STATIC);
@@ -518,8 +540,12 @@
 	d=Tcl_GetString(objv[2]);
 	l=strlen(d);
 	depends=malloc(l+2);
+	if (!depends) {
+	    Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
+	    return TCL_ERROR;
+	}
 	depends[l+1]=0;
-	strcpy(depends, d);
+	strlcpy(depends, d, l+2);
 	for(t=depends;*t;++t)
 		if(*t==' ')
 			*t++=0;

Modified: branches/universal-sanity/base/src/port/port.tcl
===================================================================
--- branches/universal-sanity/base/src/port/port.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/port/port.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -1833,10 +1833,14 @@
         return 1
     }
     foreachport $portlist {
-        if { [catch {portimage::activate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
-            global errorInfo
-            ui_debug "$errorInfo"
-            break_softcontinue "port activate failed: $result" 1 status
+        if {![macports::global_option_isset ports_dryrun]} {
+            if { [catch {portimage::activate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
+                global errorInfo
+                ui_debug "$errorInfo"
+                break_softcontinue "port activate failed: $result" 1 status
+            }
+        } else {
+            ui_msg "Skipping activate $portname (dry run)"
         }
     }
     
@@ -1850,10 +1854,14 @@
         return 1
     }
     foreachport $portlist {
-        if { [catch {portimage::deactivate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
-            global errorInfo
-            ui_debug "$errorInfo"
-            break_softcontinue "port deactivate failed: $result" 1 status
+        if {![macports::global_option_isset ports_dryrun]} {
+            if { [catch {portimage::deactivate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
+                global errorInfo
+                ui_debug "$errorInfo"
+                break_softcontinue "port deactivate failed: $result" 1 status
+            }
+        } else {
+            ui_msg "Skipping deactivate $portname (dry run)"
         }
     }
     

Modified: branches/universal-sanity/base/src/port1.0/portlivecheck.tcl
===================================================================
--- branches/universal-sanity/base/src/port1.0/portlivecheck.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/port1.0/portlivecheck.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -126,6 +126,10 @@
     if {${livecheck.name} eq "default"} {
         set livecheck.name $name
     }
+    # If livecheck.distname is still "default", set it to $name.
+    if {${livecheck.distname} eq "default"} {
+        set livecheck.distname $name
+    }
     if {[lsearch -exact [split $available_types "|"] ${livecheck.type}] != -1} {
         # Load the defaults from _resources/port1.0/livecheck/${livecheck.type}.tcl.
         set defaults_file "$types_dir/${livecheck.type}.tcl"

Modified: branches/universal-sanity/base/src/port1.0/porttrace.tcl
===================================================================
--- branches/universal-sanity/base/src/port1.0/porttrace.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/port1.0/porttrace.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -44,7 +44,7 @@
         if {[catch {package require Thread} error]} {
             ui_warn "trace requires Tcl Thread package ($error)"
         } else {
-            global env trace_fifo trace_sandboxbounds portpath
+            global env trace_fifo trace_sandboxbounds portpath distpath
             # Create a fifo.
             # path in unix socket limited to 109 chars
             # # set trace_fifo "$workpath/trace_fifo"
@@ -78,7 +78,7 @@
             # /Library/Caches/com.apple.Xcode
             # $CCACHE_DIR
             # $HOMEDIR/.ccache
-            set trace_sandboxbounds "/tmp:/private/tmp:/var/tmp:/private/var/tmp:/dev/:/etc/passwd:/etc/groups:/etc/localtime:/Library/Caches/com.apple.Xcode:$env(HOME)/.ccache:${workpath}:$portpath"
+            set trace_sandboxbounds "/tmp:/private/tmp:/var/tmp:/private/var/tmp:/dev/:/etc/passwd:/etc/groups:/etc/localtime:/Library/Caches/com.apple.Xcode:$env(HOME)/.ccache:${workpath}:${portpath}:${distpath}"
             if {[info exists env(TMPDIR)]} {
                 set trace_sandboxbounds "${trace_sandboxbounds}:$env(TMPDIR)"
             }
@@ -104,6 +104,7 @@
     global env
     if [info exists env(DARWINTRACE_SANDBOX_BOUNDS)] {
         unset env(DARWINTRACE_SANDBOX_BOUNDS)
+        unsetenv DARWINTRACE_SANDBOX_BOUNDS
     }
 }
 
@@ -147,11 +148,9 @@
     global os.platform
     if {${os.platform} == "darwin"} {
         global env trace_fifo
-        unset env(DYLD_INSERT_LIBRARIES)
-        unset env(DYLD_FORCE_FLAT_NAMESPACE)
-        unset env(DARWINTRACE_LOG)
-        if [info exists env(DARWINTRACE_SANDBOX_BOUNDS)] {
-            unset env(DARWINTRACE_SANDBOX_BOUNDS)
+        foreach var {DYLD_INSERT_LIBRARIES DYLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG DARWINTRACE_SANDBOX_BOUNDS} {
+            array unset env $var
+            unsetenv $var
         }
 
         #kill socket

Modified: branches/universal-sanity/base/src/port1.0/portutil.tcl
===================================================================
--- branches/universal-sanity/base/src/port1.0/portutil.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/port1.0/portutil.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -1268,7 +1268,6 @@
                     # outside the sandbox.
                     if {$target != "activate"
                       && $target != "archive"
-                      && $target != "fetch"
                       && $target != "install"} {
                         porttrace::trace_enable_fence
                     }

Modified: branches/universal-sanity/base/src/registry1.0/portuninstall.tcl
===================================================================
--- branches/universal-sanity/base/src/registry1.0/portuninstall.tcl	2009-06-14 03:34:34 UTC (rev 52317)
+++ branches/universal-sanity/base/src/registry1.0/portuninstall.tcl	2009-06-14 03:38:59 UTC (rev 52318)
@@ -124,10 +124,18 @@
 
 	set installtype [registry::property_retrieve $ref installtype]
 	if { $installtype == "image" && [registry::property_retrieve $ref active] == 1} {
-		#return -code error [msgcat::mc "Registry Error: ${portname} ${version}_${revision}${variants} is active."]
-		portimage::deactivate $portname ${version}_${revision}${variants} $optionslist
+		if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
+			ui_msg "For $portname @${version}_${revision}${variants}: skipping deactivate (dry run)"
+		} else {
+			portimage::deactivate $portname ${version}_${revision}${variants} $optionslist
+		}
 	}
 
+	if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
+		ui_msg "For $portname @${version}_${revision}${variants}: skipping uninstall (dry run)"
+		return 0
+	}
+	
 	ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s_%s%s"] $portname $version $revision $variants]"
 
 	# Look to see if the port has registered an uninstall procedure
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090613/c448686d/attachment-0001.html>


More information about the macports-changes mailing list