[62023] branches/images-and-archives/base

blb at macports.org blb at macports.org
Sun Dec 27 20:21:42 PST 2009


Revision: 62023
          http://trac.macports.org/changeset/62023
Author:   blb at macports.org
Date:     2009-12-27 20:21:39 -0800 (Sun, 27 Dec 2009)
Log Message:
-----------
Merge from trunk

Modified Paths:
--------------
    branches/images-and-archives/base/doc/macports.conf.5
    branches/images-and-archives/base/doc/macports.conf.in
    branches/images-and-archives/base/src/macports1.0/macports.tcl
    branches/images-and-archives/base/src/pextlib1.0/Pextlib.c
    branches/images-and-archives/base/src/pextlib1.0/curl.c
    branches/images-and-archives/base/src/pextlib1.0/filemap.c
    branches/images-and-archives/base/src/pextlib1.0/fs-traverse.c
    branches/images-and-archives/base/src/pextlib1.0/readline.c
    branches/images-and-archives/base/src/pextlib1.0/system.c
    branches/images-and-archives/base/src/pextlib1.0/tty.c
    branches/images-and-archives/base/src/pextlib1.0/uid.c
    branches/images-and-archives/base/src/registry1.0/registry.tcl

Property Changed:
----------------
    branches/images-and-archives/base/


Property changes on: branches/images-and-archives/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:50249-61426
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:50249-62022
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/images-and-archives/base/doc/macports.conf.5
===================================================================
--- branches/images-and-archives/base/doc/macports.conf.5	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/doc/macports.conf.5	2009-12-28 04:21:39 UTC (rev 62023)
@@ -51,13 +51,13 @@
 .Bl -tag -width lc
 .It Va prefix
 Sets the directory where ports are installed. Any path may be used but those with spaces and/or non ascii
-characters should be avoided, as this can broke some ports. This key is often referred to as '${prefix}'.
+characters should be avoided, as this can break some ports. This key is often referred to as '${prefix}'.
 .br
 .Ic Default:
 /opt/local
 .It Va portdbpath
-Directory where MacPorts keeps working data as downloaded sources, installed ports receipts
-and the main registry. Same path restrictions apply as for '${prefix}'.
+Directory where MacPorts keeps working data such as downloaded sources, installed ports' receipts
+and the main registry. The same path restrictions apply as for '${prefix}'.
 .br
 .Ic Default:
 ${prefix}/var/macports
@@ -104,17 +104,19 @@
 Use pipes rather than intermediate files when compiling C/C++/etc (gcc -pipe)
 .br
 .Ic Default:
-no
+yes
 .It Va buildnicevalue
 Lowered scheduling priority (0-20) to use for make when building ports
 .br
 .Ic Default:
 0
 .It Va buildmakejobs
-Number of simultaneous make jobs (commands) to use when building ports
+Number of simultaneous make jobs (commands) to use when building ports. 0 is a
+special value meaning "the number of CPU cores or the number of GB
+of physical memory plus one, whichever is less."
 .br
 .Ic Default:
-1
+0
 .It Va portautoclean
 Automatic cleaning of the build directory of a given port after it has been installed.
 .br
@@ -154,15 +156,15 @@
 .Ic Default:
 default
 .It Va destroot_umask
-Umask value to use during the destrooting or a port.
+Umask value to use during the destrooting of a port.
 .br
 .Ic Default:
 022
 .It Va rsync_server
 Default rsync server to connect to when running "selfupdate" through the
 .Nm port
-command to update your entire MacPorts
-installation (spanning both the MacPorts infrastructure and the ports tree).
+command to update your base MacPorts infrastructure. While selfupdate also
+syncs the ports tree, it uses the settings from ${sources_conf} to do so.
 .br
 .Ic Default:
 rsync.macports.org
@@ -178,7 +180,8 @@
 -rtzv --delete-after
 .It Va binpath
 Sets the directory search path for locating system executables used by MacPorts. This variable should contain
-the paths for locating utilities such as rsync, tar, cvs and others.
+the paths for locating utilities such as rsync, tar, cvs and others. Don't change this unless you understand
+and accept the consequences.
 .br
 .Ic Default:
 ${prefix}/bin:${prefix}/sbin:/bin:/sbin:/usr/bin:/usr/sbin

Modified: branches/images-and-archives/base/doc/macports.conf.in
===================================================================
--- branches/images-and-archives/base/doc/macports.conf.in	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/doc/macports.conf.in	2009-12-28 04:21:39 UTC (rev 62023)
@@ -65,8 +65,7 @@
 # Set whether to automatically execute "clean" after "install" of ports
 #portautoclean		yes
 
-# Uncomment if you dont want logs to be saved (but you will not be able to get 
-# help if something goes wrong)
+# Set to yes if you don't want logs to be deleted after successful builds
 #keeplogs no
 
 # Rsync server to fetch MacPorts sources from. Note that this is only used

Modified: branches/images-and-archives/base/src/macports1.0/macports.tcl
===================================================================
--- branches/images-and-archives/base/src/macports1.0/macports.tcl	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/macports1.0/macports.tcl	2009-12-28 04:21:39 UTC (rev 62023)
@@ -110,7 +110,7 @@
 }
 
 proc macports::init_logging {portname} {
-    global ::debuglog ::debuglogname macports::channels macports::portdbpath
+    global macports::channels macports::portdbpath
 
     if {[getuid] == 0 && [geteuid] != 0} {
         seteuid 0
@@ -118,27 +118,19 @@
     set logspath [file join $macports::portdbpath logs]
     if {([file exists $logspath] && ![file writable $logspath]) || (![file exists $logspath] && ![file writable $macports::portdbpath])} {
         ui_debug "logging disabled, can't write to $logspath"
-        return
+        return 1
     }
-    set logname [file join $logspath $portname]
-    file mkdir $logname
-    set logname [file join $logname "main.log"]
-    ui_debug "logging to $logname"
-    set ::debuglogname $logname
-
-    # Recreate the file if already exists
-    if {[file exists $::debuglogname]} {
-        file delete -force $::debuglogname
-    }
-    set ::debuglog [open $::debuglogname w]
-    puts $::debuglog "version:1"
+    macports::ch_logging $portname
     # Add our log-channel to all already initialized channels
     foreach key [array names channels] {
         set macports::channels($key) [concat $macports::channels($key) "debuglog"]
     }
+    return 0
 }
 proc macports::ch_logging {portname} {
-    global ::debuglog ::debuglogname macports::channels macports::portdbpath
+    global ::debuglog ::debuglogname macports::portdbpath
+    
+    ui_debug "Starting logging for $portname"
 
     set logname [file join $macports::portdbpath "logs/$portname"]
     file mkdir $logname
@@ -146,13 +138,44 @@
 
     set ::debuglogname $logname
  
-    # Recreate the file if already exists
-    if {[file exists $::debuglogname]} {
-        file delete -force $::debuglogname
-    }
+    # Truncate the file if already exists
     set ::debuglog [open $::debuglogname w]
     puts $::debuglog "version:1"
-} 
+}
+proc macports::push_log {portname} {
+    global ::logstack ::logenabled ::debuglog ::debuglogname
+    if {![info exists ::logenabled]} {
+        if {[macports::init_logging $portname] == 0} {
+            set ::logenabled yes
+            set ::logstack [list [list $::debuglog $::debuglogname]]
+            return
+        } else {
+            set ::logenabled no
+        }
+    }
+    if {$::logenabled} {
+        macports::ch_logging $portname
+        lappend ::logstack [list $::debuglog $::debuglogname]
+    }
+}
+proc macports::pop_log {} {
+    global ::logenabled ::logstack ::debuglog ::debuglogname
+    if {![info exists ::logenabled]} {
+        return -code error "pop_log called before push_log"
+    }
+    if {$::logenabled && [llength $::logstack] > 0} {
+        close $::debuglog
+        set ::logstack [lreplace $::logstack end end]
+        if {[llength $::logstack] > 0} {
+            set top [lindex $::logstack end]
+            set ::debuglog [lindex $top 0]
+            set ::debuglogname [lindex $top 1]
+        } else {
+            unset ::debuglog
+            unset ::debuglogname
+        }
+    }
+}
 
 proc ui_phase {phase} {
     global macports::current_stage
@@ -197,7 +220,7 @@
     }
     
     # if some priority initialized after log file is being created
-    if [info exist ::debuglog] {
+    if {[info exists ::debuglog]} {
         set channels($priority) [concat $channels($priority) "debuglog"]
     }
     # Simplify ui_$priority.
@@ -583,9 +606,9 @@
         set macports::portautoclean "yes"
         global macports::portautoclean
     }
-	# keeplogs option
+	# whether to keep logs after successful builds
    	if {![info exists keeplogs]} {
-        set macports::keeplogs "yes"
+        set macports::keeplogs "no"
         global macports::keeplogs
     }
    
@@ -1450,13 +1473,8 @@
 ### _mportexec is private; may change without notice
 
 proc _mportexec {target mport} {
-    global ::debuglog
-    if {[info exists ::debuglog]} {
-        set previouslog $::debuglog
-    }
     set portname [_mportkey $mport name]
-    ui_debug "Starting logging for $portname"
-    macports::ch_logging $portname
+    macports::push_log $portname
     # xxx: set the work path?
     set workername [ditem_key $mport workername]
     if {![catch {$workername eval check_variants variations $target} result] && $result == 0 &&
@@ -1472,15 +1490,15 @@
             catch {cd $portpath}
             $workername eval eval_targets clean
         }
-        if {[info exists previouslog]} {
-            set ::debuglog $previouslog
-        }
+        macports::pop_log
         return 0
     } else {
         # An error occurred.
-        if {[info exists previouslog]} {
-            set ::debuglog $previouslog
+        global ::debuglogname
+        if {[info exists ::debuglogname]} {
+            ui_msg "Log for $portname is at: $::debuglogname"
         }
+        macports::pop_log
         return 1
     }
 }
@@ -1495,7 +1513,9 @@
         return 1
     }
     set portname [_mportkey $mport name]
-    macports::init_logging $portname
+    if {$target != "clean"} {
+        macports::push_log $portname
+    }
 
     # Before we build the port, we must build its dependencies.
     # XXX: need a more general way of comparing against targets
@@ -1570,8 +1590,11 @@
     }
     
     global ::debuglogname
-    if {$result != 0 && ![macports::ui_isset ports_quiet] && [info exists ::debuglogname]} {
-        ui_msg "Log for $portname is at: $::debuglogname"
+    if {[info exists ::debuglogname]} {
+        if {$result != 0 && ![macports::ui_isset ports_quiet]} {
+            ui_msg "Log for $portname is at: $::debuglogname"
+        }
+        macports::pop_log
     }
 
     return $result
@@ -2561,7 +2584,7 @@
                 array set portinfo [mportinfo $workername]
                 
                 # upgrade its dependencies first
-                set status [_upgrade_dependencies portinfo depscache variationslist options]
+                set status [_upgrade_dependencies portinfo depscache variationslist options yes]
                 if {$status != 0 && ![ui_isset ports_processall]} {
                     catch {mportclose $workername}
                     return $status
@@ -2724,19 +2747,8 @@
     set revision_in_tree "$portinfo(revision)"
     set epoch_in_tree "$portinfo(epoch)"
 
-
-    # first upgrade dependencies
-    if {![info exists options(ports_nodeps)]} {
-        set status [_upgrade_dependencies portinfo depscache variationslist options]
-        if {$status != 0 && ![ui_isset ports_processall]} {
-            catch {mportclose $workername}
-            return $status
-        }
-    } else {
-        ui_debug "Not following dependencies"
-    }
-
     set epoch_override 0
+    set will_install yes
     # check installed version against version in ports
     if { ( [rpm-vercomp $version_installed $version_in_tree] > 0
             || ([rpm-vercomp $version_installed $version_in_tree] == 0
@@ -2756,36 +2768,55 @@
             } else {
                 ui_debug "No need to upgrade! $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}"
             }
-            # Check if we have to do dependents
-            if {[info exists options(ports_do_dependents)]} {
-                # We do dependents ..
-                set options(ports_nodeps) 1
+            set will_install no
+        }
+    }
 
-                registry::open_dep_map
-                set deplist [registry::list_dependents $portname]
+    set will_build no
+    # avoid building again unnecessarily
+    if {$will_install && ([info exists options(ports_upgrade_force)] || $epoch_override == 1
+        || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)])} {
+        set will_build yes
+    }
 
-                if { [llength deplist] > 0 } {
-                    foreach dep $deplist {
-                        set mpname [lindex $dep 2]
-                        if {![llength [array get depscache port:${mpname}]]} {
-                            set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
-                            if {$status != 0 && ![ui_isset ports_processall]} {
-                                catch {mportclose $workername}
-                                return $status
-                            }
+    # first upgrade dependencies
+    if {![info exists options(ports_nodeps)]} {
+        set status [_upgrade_dependencies portinfo depscache variationslist options $will_build]
+        if {$status != 0 && ![ui_isset ports_processall]} {
+            catch {mportclose $workername}
+            return $status
+        }
+    } else {
+        ui_debug "Not following dependencies"
+    }
+
+    if {!$will_install} {
+        # nothing to do for this port, so just check if we have to do dependents
+        if {[info exists options(ports_do_dependents)]} {
+            # We do dependents ..
+            set options(ports_nodeps) 1
+
+            registry::open_dep_map
+            set deplist [registry::list_dependents $portname]
+
+            if { [llength deplist] > 0 } {
+                foreach dep $deplist {
+                    set mpname [lindex $dep 2]
+                    if {![llength [array get depscache port:${mpname}]]} {
+                        set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
+                        if {$status != 0 && ![ui_isset ports_processall]} {
+                            catch {mportclose $workername}
+                            return $status
                         }
                     }
                 }
             }
-            mportclose $workername
-            return 0
         }
+        mportclose $workername
+        return 0
     }
 
-
-    # avoid building again unnecessarily
-    if {[info exists options(ports_upgrade_force)] || $epoch_override == 1
-        || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
+    if {$will_build} {
         if {[catch {set result [mportexec $workername imagefile]} result] || $result != 0} {
             if {[info exists ::errorInfo]} {
                 ui_debug "$::errorInfo"
@@ -2906,7 +2937,7 @@
 # upgrade_dependencies: helper proc for upgrade
 # Calls upgrade on each dependency listed in the PortInfo.
 # Uses upvar to access the variables.
-proc macports::_upgrade_dependencies {portinfoname depscachename variationslistname optionsname} {
+proc macports::_upgrade_dependencies {portinfoname depscachename variationslistname optionsname {build_needed yes}} {
     upvar $portinfoname portinfo $depscachename depscache \
           $variationslistname variationslist \
           $optionsname options
@@ -2925,8 +2956,13 @@
     unset -nocomplain options(ports_do_dependents)
 
     set status 0
-    # each dep type is upgraded
-    foreach dtype {depends_fetch depends_extract depends_build depends_lib depends_run} {
+    # each required dep type is upgraded
+    if {$build_needed} {
+        set dtypes {depends_fetch depends_extract depends_build depends_lib depends_run}
+    } else {
+        set dtypes {depends_lib depends_run}
+    }
+    foreach dtype $dtypes {
         if {[info exists portinfo($dtype)]} {
             foreach i $portinfo($dtype) {
                 set d [_get_dep_port $parentworker $i]

Modified: branches/images-and-archives/base/src/pextlib1.0/Pextlib.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/Pextlib.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/Pextlib.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -36,48 +36,23 @@
 #include <config.h>
 #endif
 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
 #include <ctype.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <grp.h>
+#include <limits.h>
+#include <pwd.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#if HAVE_STRINGS_H
 #include <strings.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include <pwd.h>
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#if HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
 #include <tcl.h>
 
 #include "Pextlib.h"
@@ -109,12 +84,6 @@
 extern char **environ;
 #endif
 
-#if !HAVE_BZERO
-#if HAVE_MEMSET
-#define bzero(b, len) (void)memset(b, 0x00, len)
-#endif
-#endif
-
 #if !HAVE_FGETLN
 char *fgetln(FILE *stream, size_t *len);
 #endif

Modified: branches/images-and-archives/base/src/pextlib1.0/curl.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/curl.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/curl.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -135,16 +135,16 @@
 		long theFileTime = 0;
 		CURLcode theCurlCode;
 		struct curl_slist *headers = NULL;
-		
+
 		/* we might have options and then the url and the file */
 		/* let's process the options first */
-		
+
 		optioncrsr = 2;
 		lastoption = objc - 3;
 		while (optioncrsr <= lastoption) {
 			/* get the option */
 			const char* theOption = Tcl_GetString(objv[optioncrsr]);
-			
+
 			if (strcmp(theOption, "-v") == 0) {
 				noprogress = 0;
 			} else if (strcmp(theOption, "--disable-epsv") == 0) {
@@ -163,7 +163,7 @@
 						"curl fetch: -u option requires a parameter",
 						TCL_STATIC);
 					theResult = TCL_ERROR;
-					break;					
+					break;
 				}
 			} else if (strcmp(theOption, "--effective-url") == 0) {
 				/* check we also have the parameter */
@@ -175,7 +175,7 @@
 						"curl fetch: --effective-url option requires a parameter",
 						TCL_STATIC);
 					theResult = TCL_ERROR;
-					break;					
+					break;
 				}
 			} else if (strcmp(theOption, "--user-agent") == 0) {
 				/* check we also have the parameter */
@@ -187,7 +187,7 @@
 						"curl fetch: --user-agent option requires a parameter",
 						TCL_STATIC);
 					theResult = TCL_ERROR;
-					break;					
+					break;
 				}
 			} else {
 				char theErrorString[512];
@@ -197,10 +197,10 @@
 				theResult = TCL_ERROR;
 				break;
 			}
-			
+
 			optioncrsr++;
 		}
-		
+
 		if (optioncrsr <= lastoption) {
 			/* something went wrong */
 			break;
@@ -212,7 +212,7 @@
 		if (objc >= 4) {
 			/* Retrieve the url */
 			theURL = Tcl_GetString(objv[objc - 2]);
-	
+
 			/* Retrieve the file path */
 			theFilePath = Tcl_GetString(objv[objc - 1]);
 		} else {
@@ -220,25 +220,25 @@
 			theResult = TCL_ERROR;
 			break;
 		}
-		
+
 		/* Open the file */
 		theFile = fopen( theFilePath, "w" );
 		if (theFile == NULL) {
 			Tcl_SetResult(interp, strerror(errno), TCL_VOLATILE);
 			theResult = TCL_ERROR;
-                        break;
+			break;
 		}
 
 		/* Create the CURL handle */
 		theHandle = curl_easy_init();
-		
+
 		/* Setup the handle */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_URL, theURL);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* -L option */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FOLLOWLOCATION, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -260,12 +260,12 @@
 			break;
 		}
 
-        /* -A option */
-        theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERAGENT, userAgent);
-        if (theCurlCode != CURLE_OK) {
-            theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
-            break;
-        }
+		/* -A option */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERAGENT, userAgent);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
 
 		/* skip the header data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_HEADER, 0);
@@ -273,14 +273,14 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* write to the file */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_WRITEDATA, theFile);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* we want/don't want progress */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_NOPROGRESS, noprogress);
 		if (theCurlCode != CURLE_OK) {
@@ -294,7 +294,7 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* we may want to ignore ssl errors */
 		if (ignoresslcert) {
 			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYPEER, (long) 0);
@@ -349,14 +349,14 @@
 		/* close the file */
 		(void) fclose( theFile );
 		theFile = NULL;
-		
+
 #if LIBCURL_VERSION_NUM == 0x070d01 /* work around broken Tiger version of cURL */
 		if (remotetime) {
 			FILE *fp;
 			char *tmp, *p;
 			char buf[BUFSIZ];
 			size_t size;
-			
+
 			tmp = tmpnam(NULL);
 			fp = fopen(tmp, "w");
 			if (fp == NULL) {
@@ -398,7 +398,7 @@
 				utime(theFilePath, &times); /* set the time we got */
 			}
 		}
-		
+
 		/* free header memory */
 		curl_slist_free_all(headers);
 
@@ -409,7 +409,7 @@
 				(effectiveURL == NULL || theCurlCode != CURLE_OK) ? "" : effectiveURL,
 				0);
 		}
-		
+
 		/* clean up */
 		curl_easy_cleanup( theHandle );
 		theHandle = NULL;
@@ -450,9 +450,8 @@
 		CURLcode theCurlCode;
 		long theModDate;
 		long userModDate;
-				
-		/*	first (second) parameter is the url,
-			second (third) parameter is the date */
+
+		/* first (second) parameter is the url, second (third) parameter is the date */
 		if (objc != 4) {
 			Tcl_WrongNumArgs(interp, 1, objv, "isnewer url date");
 			theResult = TCL_ERROR;
@@ -467,25 +466,25 @@
 		if (theResult != TCL_OK) {
 			break;
 		}
-		
+
 		/* Open the file (dev/null) */
 		theFile = fopen( "/dev/null", "a" );
 		if (theFile == NULL) {
 			Tcl_SetResult(interp, strerror(errno), TCL_VOLATILE);
 			theResult = TCL_ERROR;
-                        break;
+			break;
 		}
 
 		/* Create the CURL handle */
 		theHandle = curl_easy_init();
-		
+
 		/* Setup the handle */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_URL, theURL);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* -L option */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FOLLOWLOCATION, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -534,7 +533,7 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* save the modification date */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FILETIME, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -560,18 +559,18 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* actually fetch the resource */
 		theCurlCode = curl_easy_perform(theHandle);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* close the file */
 		(void) fclose( theFile );
 		theFile = NULL;
-		
+
 		/* check everything went fine */
 		theCurlCode = curl_easy_getinfo(theHandle, CURLINFO_HTTP_CODE, &theResponseCode);
 		if (theCurlCode != CURLE_OK) {
@@ -588,11 +587,11 @@
 				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 				break;
 			}
-	
+
 			/* clean up */
 			curl_easy_cleanup( theHandle );
 			theHandle = NULL;
-	
+
 			/* compare this with the date provided by user */
 			if (theModDate < -1) {
 				Tcl_SetResult(interp, "Couldn't get resource modification date", TCL_STATIC);
@@ -605,16 +604,17 @@
 			Tcl_SetResult(interp, "1", TCL_STATIC);
 		} else {
 			Tcl_SetResult(interp, "0", TCL_STATIC);
-		}		
-    } while (0);
-    
-    if (theHandle != NULL) {
-    	curl_easy_cleanup( theHandle );
-    }
-    if (theFile != NULL) {
-    	fclose( theFile );
-    }
-    
+		}
+	} while (0);
+
+	if (theHandle != NULL) {
+		curl_easy_cleanup(theHandle);
+	}
+
+	if (theFile != NULL) {
+		fclose(theFile);
+	}
+
 	return theResult;
 }
 
@@ -637,8 +637,8 @@
 		const char* theURL;
 		CURLcode theCurlCode;
 		double theFileSize;
-				
-		/*	first (second) parameter is the url */
+
+		/* first (second) parameter is the url */
 		if (objc != 3) {
 			Tcl_WrongNumArgs(interp, 1, objv, "getsize url");
 			theResult = TCL_ERROR;
@@ -653,19 +653,19 @@
 		if (theFile == NULL) {
 			Tcl_SetResult(interp, strerror(errno), TCL_VOLATILE);
 			theResult = TCL_ERROR;
-                        break;
+			break;
 		}
 
 		/* Create the CURL handle */
 		theHandle = curl_easy_init();
-		
+
 		/* Setup the handle */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_URL, theURL);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* -L option */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FOLLOWLOCATION, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -721,7 +721,7 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* skip the body data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_NOBODY, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -735,14 +735,14 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* actually fetch the resource */
 		theCurlCode = curl_easy_perform(theHandle);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-		
+
 		/* close the file */
 		(void) fclose( theFile );
 		theFile = NULL;
@@ -755,7 +755,7 @@
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
 		}
-	
+
 		/* clean up */
 		curl_easy_cleanup( theHandle );
 		theHandle = NULL;
@@ -763,15 +763,16 @@
 		(void) snprintf(theSizeString, sizeof(theSizeString),
 			"%.0f", theFileSize);
 		Tcl_SetResult(interp, theSizeString, TCL_VOLATILE);
-    } while (0);
-    
-    if (theHandle != NULL) {
-    	curl_easy_cleanup( theHandle );
-    }
-    if (theFile != NULL) {
-    	fclose( theFile );
-    }
-    
+	} while (0);
+
+	if (theHandle != NULL) {
+		curl_easy_cleanup(theHandle);
+	}
+
+	if (theFile != NULL) {
+		fclose(theFile);
+	}
+
 	return theResult;
 }
 
@@ -787,20 +788,20 @@
 CurlCmd(
 		ClientData clientData UNUSED,
 		Tcl_Interp* interp,
-		int objc, 
+		int objc,
 		Tcl_Obj* CONST objv[])
 {
-    typedef enum {
-    	kCurlFetch,
-    	kCurlIsNewer,
-    	kCurlGetSize
-    } EOption;
-    
+	typedef enum {
+		kCurlFetch,
+		kCurlIsNewer,
+		kCurlGetSize
+	} EOption;
+
 	static const char *options[] = {
 		"fetch", "isnewer", "getsize", NULL
 	};
 	int theResult = TCL_OK;
-    EOption theOptionIndex;
+	EOption theOptionIndex;
 	static pthread_once_t once = PTHREAD_ONCE_INIT;
 
 	/* TODO: use dispatch_once when we drop Leopard support */

Modified: branches/images-and-archives/base/src/pextlib1.0/filemap.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/filemap.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/filemap.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -210,7 +210,7 @@
 		ssize_t theFileSize;
 
 		/* Open the file for reading, creating it if necessary. */
-		int theFD = open(inDatabasePath, O_RDONLY | O_CREAT, 0664);
+		theFD = open(inDatabasePath, O_RDONLY | O_CREAT, 0664);
 		if (theFD < 0)
 		{
 			theErr = errno;

Modified: branches/images-and-archives/base/src/pextlib1.0/fs-traverse.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/fs-traverse.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/fs-traverse.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -37,24 +37,14 @@
 #include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if HAVE_SYS_TYPES_H
 #include <sys/types.h>
-#endif
-
-#if HAVE_SYS_STAT_H
 #include <sys/stat.h>
-#endif
-
-#include <fts.h>
 #include <errno.h>
-
-#if HAVE_LIMITS_H
+#include <fts.h>
 #include <limits.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <tcl.h>
 

Modified: branches/images-and-archives/base/src/pextlib1.0/readline.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/readline.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/readline.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -13,12 +13,9 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
 #if HAVE_READLINE_READLINE_H
 #include <readline/readline.h>
 #endif

Modified: branches/images-and-archives/base/src/pextlib1.0/system.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/system.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/system.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -153,7 +153,7 @@
 	/* read from simulated popen() pipe */
 	read_failed = 0;
 	pos = 0;
-	bzero(circbuf, sizeof(circbuf));
+	memset(circbuf, 0, sizeof(circbuf));
 	pdes = fdopen(fdset[0], "r");
 	while ((buf = fgetln(pdes, &linelen)) != NULL) {
 		char *sbuf;

Modified: branches/images-and-archives/base/src/pextlib1.0/tty.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/tty.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/tty.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -37,12 +37,9 @@
 #include <config.h>
 #endif
 
-#if HAVE_UNISTD_H
+#include <sys/ioctl.h>
 #include <unistd.h>
-#endif
 
-#include <sys/ioctl.h>
-
 #include <tcl.h>
 
 #include "tty.h"

Modified: branches/images-and-archives/base/src/pextlib1.0/uid.c
===================================================================
--- branches/images-and-archives/base/src/pextlib1.0/uid.c	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/pextlib1.0/uid.c	2009-12-28 04:21:39 UTC (rev 62023)
@@ -12,29 +12,14 @@
 #include <config.h>
 #endif
 
+#include <sys/types.h>
 #include <grp.h>
-#include <string.h>
-
-#if HAVE_STDLIB_H
+#include <pwd.h>
+#include <stdio.h>
 #include <stdlib.h>
-#endif
-
-#if HAVE_UNISTD_H
+#include <string.h>
 #include <unistd.h>
-#endif
 
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-
-#if HAVE_PWD_H
-#include <pwd.h>
-#endif
-
 #include <tcl.h>
 
 #include "uid.h"

Modified: branches/images-and-archives/base/src/registry1.0/registry.tcl
===================================================================
--- branches/images-and-archives/base/src/registry1.0/registry.tcl	2009-12-28 03:54:28 UTC (rev 62022)
+++ branches/images-and-archives/base/src/registry1.0/registry.tcl	2009-12-28 04:21:39 UTC (rev 62023)
@@ -639,26 +639,36 @@
 
 		set port [registry::file_registered $file] 
 
-		if { $port != 0  && $force != 1 && $port != $name } {
-			return -code error "Image error: $file is being used by the active $port port.  Please deactivate this port first, or use 'port -f activate $name' to force the activation."
-		} elseif { [file exists $file] && $force != 1 } {
-			return -code error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port $name."
-		} elseif { $force == 1 && [file exists $file] || $port != 0 } {
-			set bakfile ${file}.mp_${timestamp}
+        if { $port != 0  && $force != 1 && $port != $name } {
+            if {[catch {mportlookup $port} result]} {
+                global errorInfo
+                ui_debug "$errorInfo"
+                return -code error "port lookup failed: $result"
+            }
+            array set portinfo [lindex $result 1]
+            if {[info exists portinfo(replaced_by)] && [lsearch -exact -nocase $portinfo(replaced_by) $name] != -1} {
+                deactivate $port "" ""
+            } else {
+                return -code error "Image error: $file is being used by the active $port port.  Please deactivate this port first, or use 'port -f activate $name' to force the activation."
+            }
+        } elseif { [file exists $file] && $force != 1 } {
+            return -code error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port $name."
+        } elseif { $force == 1 && [file exists $file] || $port != 0 } {
+            set bakfile ${file}.mp_${timestamp}
 
-			if {[file exists $file]} {
-				ui_warn "File $file already exists.  Moving to: $bakfile."
-				file rename -force $file $bakfile
-			}
-			
-			if { $port != 0 } {
-				set bakport [registry::file_registered $file]
-				registry::unregister_file $file
-				if {[file exists $file]} {
-					registry::register_file $bakfile $bakport
-				}
-			}
-		}
+            if {[file exists $file]} {
+                ui_warn "File $file already exists.  Moving to: $bakfile."
+                file rename -force $file $bakfile
+            }
+
+            if { $port != 0 } {
+                set bakport [registry::file_registered $file]
+                registry::unregister_file $file
+                if {[file exists $file]} {
+                    registry::register_file $bakfile $bakport
+                }
+            }
+        }
 		
 		# Split out the filename's subpaths and add them to the imagefile list.
 		# We need directories first to make sure they will be there before
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20091227/523483f6/attachment-0001.html>


More information about the macports-changes mailing list