Index: trunk/base/src/port1.0/portbuild.tcl
===================================================================
--- trunk/base/src/port1.0/portbuild.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portbuild.tcl	(revision 4453)
@@ -71,9 +71,9 @@
 	    set pbxbuild "pbxbuild"
 	    set xcodebuild "xcodebuild"
-
+	    
 	    if {[option os.platform] != "darwin"} {
 		return -code error "[format [msgcat::mc "This port requires 'pbxbuild/xcodebuild', which is not available on %s."] [option os.platform]]"
 	    }
-	
+	    
 	    if {[catch {set xcodebuild [binaryInPath $xcodebuild]}] == 0} {
 		return $xcodebuild
@@ -93,5 +93,5 @@
 proc build_start {args} {
     global UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] [option portname] [option build.target]]"
 }
Index: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portchecksum.tcl	(revision 4453)
@@ -54,5 +54,5 @@
 proc checksum_start {args} {
     global UI_PREFIX portname
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Verifying checksum for %s"] $portname]"
 }
@@ -60,10 +60,10 @@
 proc checksum_main {args} {
     global distpath all_dist_files UI_PREFIX
-
+    
     # If no files have been downloaded there is nothing to checksum
     if {![info exists all_dist_files]} {
 	return 0
     }
-
+    
     if {![exists checksums]} {
 	ui_error "[msgcat::mc "No checksums statement in Portfile.  File checksums are:"]"
@@ -73,10 +73,10 @@
 	return -code error "[msgcat::mc "No checksums statement in Portfile."]"
     }
-
+    
     # Optimization for the 2 argument case for checksums
     if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} {
 	option checksums [linsert [option checksums] 0 $all_dist_files]
     }
-
+    
     foreach distfile $all_dist_files {
 	set checksum [md5 file $distpath/$distfile]
Index: trunk/base/src/port1.0/portclean.tcl
===================================================================
--- trunk/base/src/port1.0/portclean.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portclean.tcl	(revision 4453)
@@ -45,5 +45,5 @@
 proc clean_start {args} {
     global UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option portname]]"
 }
Index: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portconfigure.tcl	(revision 4453)
@@ -54,5 +54,5 @@
 proc configure_start {args} {
     global UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]"
 }
@@ -61,5 +61,5 @@
     global [info globals]
     global configure configure.args configure.dir automake automake.env automake.args automake.dir autoconf autoconf.env autoconf.args autoconf.dir xmkmf libtool portname worksrcpath prefix workpath UI_PREFIX use_configure use_autoconf use_automake use_xmkmf
-
+    
     if {[tbool use_automake]} {
 	# XXX depend on automake
@@ -68,5 +68,5 @@
 	}
     }
-
+    
     if {[tbool use_autoconf]} {
 	# XXX depend on autoconf
@@ -75,5 +75,5 @@
 	}
     }
-
+    
     if {[tbool use_xmkmf]} {
 	# XXX depend on xmkmf
Index: trunk/base/src/port1.0/portdepends.tcl
===================================================================
--- trunk/base/src/port1.0/portdepends.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portdepends.tcl	(revision 4453)
@@ -50,14 +50,14 @@
 	set|append|delete {
 	    foreach depspec $args {
-			if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname]} {
-				switch $deppath {
-					lib {}
-					bin {}
-					path {}
-					default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]}
-				}
-			} else {
-				return -code error [format [msgcat::mc "invalid depspec: %s"] $depspec]
-			}
+		if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname]} {
+		    switch $deppath {
+			lib {}
+			bin {}
+			path {}
+			default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]}
+		    }
+		} else {
+		    return -code error [format [msgcat::mc "invalid depspec: %s"] $depspec]
+		}
 	    }
 	}
Index: trunk/base/src/port1.0/portdestroot.tcl
===================================================================
--- trunk/base/src/port1.0/portdestroot.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portdestroot.tcl	(revision 4453)
@@ -56,11 +56,11 @@
 proc destroot_start {args} {
     global UI_PREFIX prefix portname destroot portresourcepath os.platform destroot.clean
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Staging %s into destroot"] ${portname}]"
-
+    
     if { ${destroot.clean} == "yes" } {
 	system "rm -Rf \"${destroot}\""
     }
-
+    
     file mkdir "${destroot}"
     if { ${os.platform} == "darwin" } {
@@ -78,5 +78,5 @@
 proc destroot_finish {args} {
     global destroot
-
+    
     # Prune empty directories in ${destroot}
     catch {system "find \"${destroot}\" -depth -type d -print | xargs rmdir 2>/dev/null"}
Index: trunk/base/src/port1.0/portdmg.tcl
===================================================================
--- trunk/base/src/port1.0/portdmg.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portdmg.tcl	(revision 4453)
@@ -42,7 +42,7 @@
 proc dmg_main {args} {
     global portname portversion portrevision package.destpath UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${portname} ${portversion}]"
-
+    
     return [package_dmg $portname $portversion $portrevision]
 }
@@ -50,5 +50,5 @@
 proc package_dmg {portname portversion portrevision} {
     global UI_PREFIX package.destpath portpath
-
+    
     if {[expr (${portrevision} > 0)]} {
         set imagename "${portname}-${portversion}-${portrevision}"
@@ -56,14 +56,14 @@
 	set imagename "${portname}-${portversion}"
     }
-
+    
     set tmp_image ${package.destpath}/${imagename}.tmp.dmg
     set final_image ${package.destpath}/${imagename}.dmg
     set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
-
+    
     if {[file readable $final_image] && ([file mtime ${final_image}] >= [file mtime ${portpath}/Portfile])} {
         ui_msg "$UI_PREFIX [format [msgcat::mc "Disk Image for %s-%s is up-to-date"] ${portname} ${portversion}]"
 	return 0
     }
-
+    
     # size for .dmg
     set size [dirSize ${pkgpath}]
@@ -75,5 +75,5 @@
         set blocks [expr ($size/512) + ((($size/512)*3)/100)]
     }
-
+    
     if {[system "hdiutil create -fs HFS+ -volname ${imagename} -size ${blocks}b ${tmp_image}"] != ""} {
         return -code error [format [msgcat::mc "Failed to create temporary image: %s"] ${imagename}]
@@ -93,5 +93,5 @@
     }
     system "rm -f ${tmp_image}"
-
+    
     return 0
 }
Index: trunk/base/src/port1.0/portextract.tcl
===================================================================
--- trunk/base/src/port1.0/portextract.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portextract.tcl	(revision 4453)
@@ -57,5 +57,5 @@
 proc extract_init {args} {
     global extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath
-
+    
     if {[tbool use_bzip2]} {
 	option extract.cmd [binaryInPath "bzip2"]
@@ -69,5 +69,5 @@
 proc extract_start {args} {
     global UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option portname]]"
 }
@@ -75,10 +75,10 @@
 proc extract_main {args} {
     global UI_PREFIX
-
+    
     if {![exists distfiles] && ![exists extract.only]} {
 	# nothing to do
 	return 0
     }
-
+    
     foreach distfile [option extract.only] {
 	ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]"
Index: trunk/base/src/port1.0/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/portfetch.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portfetch.tcl	(revision 4453)
@@ -156,5 +156,5 @@
         return {}
     }
-
+    
     set ret [list]
     foreach element $portfetch::mirror_sites::sites($mirrors) {
@@ -164,12 +164,12 @@
 	set splitlist [split $element :]
 	if {[llength $splitlist] > 1} {
-		set element "[lindex $splitlist 0]:[lindex $splitlist 1]" 
-		set mirror_tag "[lindex $splitlist 2]"
-	}
-
+	    set element "[lindex $splitlist 0]:[lindex $splitlist 1]" 
+	    set mirror_tag "[lindex $splitlist 2]"
+	}
+	
 	if {$subdir == "" && $mirror_tag != "nosubdir"} {
 	    set subdir ${portname}
 	}
-
+	
 	if {"$tag" != ""} {
 	    eval append element "${subdir}:${tag}"
@@ -179,5 +179,5 @@
         eval lappend ret $element
     }
-
+    
     return $ret
 }
@@ -192,7 +192,7 @@
 	master_sites filespath master_sites.mirror_subdir \
         patch_sites.mirror_subdir fallback_mirror_site
-
+    
     append master_sites " ${fallback_mirror_site}"
-
+    
     foreach list {master_sites patch_sites} {
         upvar #0 $list uplist
@@ -228,5 +228,5 @@
         }
     }
-   
+    
     if {[info exists patchfiles]} {
 	foreach file $patchfiles {
@@ -286,5 +286,5 @@
     global distpath all_dist_files UI_PREFIX fetch_urls fetch.cmd os.platform fetch.pre_args
     global distfile site
-
+    
     if {![file isdirectory $distpath]} {
         if {[catch {file mkdir $distpath} result]} {
@@ -328,5 +328,5 @@
 proc fetch_init {args} {
     global distfiles distname distpath all_dist_files dist_subdir fetch.type
-
+    
     if {[info exist distpath] && [info exists dist_subdir]} {
 	set distpath ${distpath}/${dist_subdir}
@@ -339,5 +339,5 @@
 proc fetch_start {args} {
     global UI_PREFIX portname
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching %s"] $portname]"
 }
@@ -349,5 +349,5 @@
 proc fetch_main {args} {
     global distname distpath all_dist_files fetch.type
-
+    
     # Check for files, download if neccesary
     if {![info exists all_dist_files] && "${fetch.type}" == "standard"} {
Index: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portinstall.tcl	(revision 4453)
@@ -43,22 +43,22 @@
 proc install_start {args} {
     global UI_PREFIX portname portversion
-
-	# Check to make sure this port is not already installed.  This is a 
-	# general check of the portname only, so previous versions will fail 
-	# as well.
-	if {[string length [registry_exists $portname]]} {
-		# Also check to see if it's this version or another
-		if {[string length [registry_exists $portname $portversion]]} {
-			return -code error [format [msgcat::mc "Port %s already registered as installed."] $portname]
-		} else {
-			return -code error [format [msgcat::mc "Another version of Port %s is already registered as installed.  Please uninstall the port first."] $portname]
-		}
+    
+    # Check to make sure this port is not already installed.  This is a 
+    # general check of the portname only, so previous versions will fail 
+    # as well.
+    if {[string length [registry_exists $portname]]} {
+	# Also check to see if it's this version or another
+	if {[string length [registry_exists $portname $portversion]]} {
+	    return -code error [format [msgcat::mc "Port %s already registered as installed."] $portname]
 	} else {
+	    return -code error [format [msgcat::mc "Another version of Port %s is already registered as installed.  Please uninstall the port first."] $portname]
+	}
+    } else {
     	ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s"] ${portname}]"
-	}
+    }
 }
 
 proc install_element {src_element dst_element} {
-# don't recursively copy directories
+    # don't recursively copy directories
     if {[file isdirectory $src_element] && [file type $src_element] != "link"} {
 	file mkdir $dst_element
@@ -66,5 +66,5 @@
 	file copy -force $src_element $dst_element
     }
-
+    
     # if the file is a symlink, do not try to set file attributes
     # if the destination file is an existing directory,
@@ -90,5 +90,5 @@
 	return
     }
-
+    
     foreach name [readdir .] {
 	if {[string match $name "."] || [string match $name ".."]} {
@@ -96,5 +96,5 @@
 	}
 	set element [file join $cwd $name]
-
+	
 	# XXX jpm's cross-platform code to find file separator
 	# replace with [file seperator] with tcl 8.4
@@ -108,5 +108,5 @@
 	    }
 	}
-
+	
 	set dst_element [file join $root $element]
 	set src_element [file join $rootdir $element]
@@ -126,11 +126,11 @@
 proc install_main {args} {
     global portname portversion portpath categories description long_description homepage depends_run installPlist package-install uninstall workdir worksrcdir prefix UI_PREFIX destroot
-
+    
     # Install ${destroot} contents into /
     directory_dig ${destroot} ${destroot}
-
+    
     # Package installed successfully, so now we must register it
     set rhandle [registry_new $portname $portversion]
-
+    
     registry_store $rhandle [list prefix $prefix]
     registry_store $rhandle [list categories $categories]
Index: trunk/base/src/port1.0/portpatch.tcl
===================================================================
--- trunk/base/src/port1.0/portpatch.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portpatch.tcl	(revision 4453)
@@ -48,10 +48,10 @@
 proc patch_main {args} {
     global UI_PREFIX
-
+    
     # First make sure that patchfiles exists and isn't stubbed out.
     if {![exists patchfiles]} {
 	return 0
     }
-
+    
     foreach patch [option patchfiles] {
 	if {[file exists [option filespath]/$patch]} {
Index: trunk/base/src/port1.0/portrpmpackage.tcl
===================================================================
--- trunk/base/src/port1.0/portrpmpackage.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portrpmpackage.tcl	(revision 4453)
@@ -44,7 +44,7 @@
 proc rpmpackage_main {args} {
     global portname portversion portrevision UI_PREFIX
-
+    
     ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${portname} ${portversion}]"
-
+    
     return [rpmpackage_pkg $portname $portversion $portrevision]
 }
@@ -52,5 +52,5 @@
 proc rpmpackage_pkg {portname portversion portrevision} {
     global UI_PREFIX package.destpath portdbpath destpath workpath prefix portresourcepath categories maintainers description long_description homepage epoch portpath
-
+    
     set rpmdestpath ""
     if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} {
@@ -63,5 +63,5 @@
         set rpmdestpath "--define '_topdir ${pkgpath}'"
     }
-
+    
     foreach dir { "${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
         foreach arch {"ppc" "i386" "fat"} {
@@ -73,5 +73,5 @@
         }
     }
-
+    
     set specpath ${workpath}/${portname}.spec
     # long_description, description, or homepage may not exist
@@ -85,5 +85,5 @@
     set category   [lindex [split $categories " "] 0]
     set maintainer $maintainers
-
+    
     set dependencies {}
     # get deplist
@@ -98,5 +98,5 @@
         }
     }
-
+    
     system "rm -f '${workpath}/${portname}.filelist' && touch '${workpath}/${portname}.filelist'"
     #system "cd '${destpath}' && find . -type d | grep -v -E '^.$' | sed -e 's/\"/\\\"/g' -e 's/^./%dir \"/' -e 's/$/\"/' > '${workpath}/${portname}.filelist'"
@@ -105,5 +105,5 @@
     write_spec ${specpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $category $maintainer $destpath $dependencies $epoch
     system "DP_USERECEIPTS='${portdbpath}/receipts' rpm -bb -v ${rpmdestpath} ${specpath}"
-
+    
     return 0
 }
@@ -117,5 +117,5 @@
     foreach {name array} $res {
         array set portinfo $array
-
+	
         if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
             # get the union of depends_run and depends_lib
@@ -124,8 +124,8 @@
             if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
             if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
-
+	    
             foreach depspec $depends {
                 set dep [lindex [split $depspec :] 2]
-        
+		
                 # xxx: nasty hack
                 if {$dep != "XFree86"} {
@@ -144,9 +144,9 @@
     set specfd [open ${specfile} w+]
     if {[llength ${dependencies}] != 0} {
-       set requires [join ${dependencies} ", "]
-       regsub -all -- "\-" $requires "_" requires
-       set requires "Requires: ${requires}"
+	set requires [join ${dependencies} ", "]
+	regsub -all -- "\-" $requires "_" requires
+	set requires "Requires: ${requires}"
     } else {
-       set requires ""
+	set requires ""
     }
     regsub -all -- "\-" $portversion "_" portversion
Index: trunk/base/src/port1.0/portuninstall.tcl
===================================================================
--- trunk/base/src/port1.0/portuninstall.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portuninstall.tcl	(revision 4453)
@@ -46,5 +46,5 @@
 proc uninstall_start {args} {
     global portname portversion UI_PREFIX
-
+    
     if {[string length [registry_exists $portname]]} {
 	ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s"] $portname]"
@@ -54,10 +54,10 @@
 proc uninstall_main {args} {
     global portname portversion uninstall.force uninstall.nochecksum ports_force UI_PREFIX
-
+    
     # If global forcing is on, make it the same as a local force flag.
     if {[tbool ports_force]} {
 	set uninstall.force "yes"
     }
-
+    
     set rfile [registry_exists $portname]
     if {[string length $rfile]} {
@@ -69,5 +69,5 @@
 	set entry [read $fd]
 	close $fd
-
+	
 	# First look to see if the port has registered an uninstall procedure
 	set ix [lsearch $entry pkg_uninstall]
@@ -80,5 +80,5 @@
 	    }
 	}
-
+	
 	# Now look for a contents list
 	set ix [lsearch $entry contents]
@@ -90,10 +90,10 @@
 		set md5index [lsearch -regex [lrange $f 1 end] MD5]
 		if {$md5index != -1} {
-			set sumx [lindex $f [expr $md5index + 1]]
+		    set sumx [lindex $f [expr $md5index + 1]]
 		} else {
-			# XXX There is no MD5 listed, set sumx to an empty
-			# list, causing the next conditional to return a
-			# checksum error
-			set sumx {}
+		    # XXX There is no MD5 listed, set sumx to an empty
+		    # list, causing the next conditional to return a
+		    # checksum error
+		    set sumx {}
 		}
 		set sum1 [lindex $sumx [expr [llength $sumx] - 1]]
@@ -127,6 +127,6 @@
 	    }
 	    if {!$uninst_err || [tbool uninstall.force]} {
-			registry_delete $portname
-			return 0
+		registry_delete $portname
+		return 0
 	    }
 	} else {
Index: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	(revision 4422)
+++ trunk/base/src/port1.0/portutil.tcl	(revision 4453)
@@ -65,13 +65,13 @@
 
 proc option {name args} {
-	# XXX: right now we just transparently use globals
-	# eventually this will need to bridge the options between
-	# the Portfile's interpreter and the target's interpreters.
-	global $name
-	if {[llength $args] > 0} {
-		ui_debug "setting option $name to $args"
-		set $name [lindex $args 0]
-	}
-	return [set $name]
+    # XXX: right now we just transparently use globals
+    # eventually this will need to bridge the options between
+    # the Portfile's interpreter and the target's interpreters.
+    global $name
+    if {[llength $args] > 0} {
+	ui_debug "setting option $name to $args"
+	set $name [lindex $args 0]
+    }
+    return [set $name]
 }
 
@@ -82,9 +82,9 @@
 
 proc exists {name} {
-	# XXX: right now we just transparently use globals
-	# eventually this will need to bridge the options between
-	# the Portfile's interpreter and the target's interpreters.
-	global $name
-	return [info exists $name]
+    # XXX: right now we just transparently use globals
+    # eventually this will need to bridge the options between
+    # the Portfile's interpreter and the target's interpreters.
+    global $name
+    return [info exists $name]
 }
 
@@ -178,5 +178,5 @@
 proc option_proc_trace {optionName index op} {
     global option_procs
-	upvar $optionName optionValue
+    upvar $optionName optionValue
     switch $op {
 	w {
@@ -303,18 +303,18 @@
     
     # mode indicates what the arg is interpreted as.
-	# possible mode keywords are: requires, conflicts, provides
-	# The default mode is provides.  Arguments are added to the
-	# most recently specified mode (left to right).
+    # possible mode keywords are: requires, conflicts, provides
+    # The default mode is provides.  Arguments are added to the
+    # most recently specified mode (left to right).
     set mode "provides"
     foreach arg $args {
-		switch -exact $arg {
-			provides { set mode "provides" }
-			requires { set mode "requires" }
-			conflicts { set mode "conflicts" }
-			default { ditem_append $ditem $mode $arg }		
+	switch -exact $arg {
+	    provides { set mode "provides" }
+	    requires { set mode "requires" }
+	    conflicts { set mode "conflicts" }
+	    default { ditem_append $ditem $mode $arg }		
         }
     }
     ditem_key $ditem name "[join [ditem_key $ditem provides] -]"
-
+    
     # make a user procedure named variant-blah-blah
     # we will call this procedure during variant-run
@@ -349,5 +349,5 @@
 proc variant_unset {name} {
     global variations
-
+    
     set variations($name) -
 }
@@ -358,44 +358,44 @@
 # be more readable, and support arch and version specifics
 proc platform {args} {
-	global all_variants PortInfo os.platform os.arch os.version
-	upvar $args upargs
-
-	set len [llength $args]
-	set code [lindex $args end]
-	set os [lindex $args 0]
-	set args [lrange $args 1 [expr $len - 2]]
-	
-	set ditem [variant_new "temp-variant"]
-
-	foreach arg $args {
-		if {[regexp {(^[0-9]$)} $arg match result]} {
-			set release $result
-		} elseif {[regexp {([a-zA-Z0-9]*)} $arg match result]} {
-			set arch $result
-		}
-	}
-
-	# Add the variant for this platform
-	set platform $os
-	if {[info exists release]} { set platform ${platform}_${release} }
-	if {[info exists arch]} { set platform ${platform}_${arch} }
-
-	variant $platform $code
-
-	# Set the variant if this platform matches the platform we're on
-	if {[info exists os.platform] && ${os.platform} == $os} { 
-		set sel_platform $os
-		if {[info exists os.version] && [info exists release]} {
-			regexp {([0-9]*)[0-9\.]?} ${os.version} match major
-			if {$major == $release } { 
-				set sel_platform ${sel_platform}_${release} 
-			}
-		}
-		if {[info exists os.arch] && [info exists arch] && ${os.arch} == $arch} {
-			set sel_platform $arch
-		}
-		variant_set $sel_platform
-	}
-	
+    global all_variants PortInfo os.platform os.arch os.version
+    upvar $args upargs
+    
+    set len [llength $args]
+    set code [lindex $args end]
+    set os [lindex $args 0]
+    set args [lrange $args 1 [expr $len - 2]]
+    
+    set ditem [variant_new "temp-variant"]
+    
+    foreach arg $args {
+	if {[regexp {(^[0-9]$)} $arg match result]} {
+	    set release $result
+	} elseif {[regexp {([a-zA-Z0-9]*)} $arg match result]} {
+	    set arch $result
+	}
+    }
+    
+    # Add the variant for this platform
+    set platform $os
+    if {[info exists release]} { set platform ${platform}_${release} }
+    if {[info exists arch]} { set platform ${platform}_${arch} }
+    
+    variant $platform $code
+    
+    # Set the variant if this platform matches the platform we're on
+    if {[info exists os.platform] && ${os.platform} == $os} { 
+	set sel_platform $os
+	if {[info exists os.version] && [info exists release]} {
+	    regexp {([0-9]*)[0-9\.]?} ${os.version} match major
+	    if {$major == $release } { 
+		set sel_platform ${sel_platform}_${release} 
+	    }
+	}
+	if {[info exists os.arch] && [info exists arch] && ${os.arch} == $arch} {
+	    set sel_platform $arch
+	}
+	variant_set $sel_platform
+    }
+    
 }
 
@@ -432,5 +432,5 @@
 	return -code error "no value given for parameter \"file\" to \"reinplace\"" 
     }
-
+    
     foreach file $args {
 	if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
@@ -443,5 +443,5 @@
 	    set tmpfile [lindex $tmpfile 1]
 	}
-
+	
 	if {[catch {exec sed $pattern < $file >@ $tmpfd} error]} {
 	    ui_error "reinplace: $error"
@@ -449,7 +449,7 @@
 	    return -code error "reinplace failed"
 	}
-
+	
 	close $tmpfd
-
+	
 	set attributes [file attributes $file]
 	# We need to overwrite this file
@@ -459,5 +459,5 @@
 	    return -code error "reinplace failed"
 	}
-
+	
 	if {[catch {exec cp $tmpfile $file} error]} {
 	    ui_error "reinplace: $error"
@@ -482,5 +482,5 @@
 proc filefindbypath {fname} {
     global distpath filesdir workdir worksrcdir portpath
-
+    
     if {[file readable $portpath/$fname]} {
 	return $portpath/$fname
@@ -582,35 +582,35 @@
     global targets target_state_fd portname
     set dlist $targets
-	    
-	# Select the subset of targets under $target
+    
+    # Select the subset of targets under $target
     if {$target != ""} {
         set matches [dlist_search $dlist provides $target]
-
+	
         if {[llength $matches] > 0} {
-			set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
-			# Special-case 'all'
-		} elseif {$target != "all"} {
-			ui_error "unknown target: $target"
+	    set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
+	    # Special-case 'all'
+	} elseif {$target != "all"} {
+	    ui_error "unknown target: $target"
             return 1
         }
     }
-	
+    
     # Restore the state from a previous run.
     set target_state_fd [open_statefile]
     
     set dlist [dlist_eval $dlist "" target_run]
-
+    
     if {[llength $dlist] > 0} {
-		# somebody broke!
-		set errstring "Warning: the following items did not execute (for $portname):"
-		foreach ditem $dlist {
-			append errstring " [ditem_key $ditem name]"
-		}
-		ui_info $errstring
-		set result 1
+	# somebody broke!
+	set errstring "Warning: the following items did not execute (for $portname):"
+	foreach ditem $dlist {
+	    append errstring " [ditem_key $ditem name]"
+	}
+	ui_info $errstring
+	set result 1
     } else {
-		set result 0
-    }
-	
+	set result 0
+    }
+    
     close $target_state_fd
     return $result
@@ -628,15 +628,15 @@
     set statefile [file join $workpath .darwinports.${portname}.state]
     if {[file exists $statefile]} {
-		if {![file writable $statefile]} {
-			return -code error "$statefile is not writable - check permission on port directory"
-		}
-		if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
-			ui_msg "Portfile changed since last build; discarding previous state."
-			#file delete $statefile
-			exec rm -rf [file join $workpath]
-			exec mkdir [file join $workpath]
-		}
-	}
-	
+	if {![file writable $statefile]} {
+	    return -code error "$statefile is not writable - check permission on port directory"
+	}
+	if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
+	    ui_msg "Portfile changed since last build; discarding previous state."
+	    #file delete $statefile
+	    exec rm -rf [file join $workpath]
+	    exec mkdir [file join $workpath]
+	}
+    }
+    
     set fd [open $statefile a+]
     if {[catch {flock $fd -exclusive -noblock} result]} {
@@ -658,10 +658,10 @@
 proc check_statefile {class name fd} {
     global portpath workdir
-    	
+    
     seek $fd 0
     while {[gets $fd line] >= 0} {
-		if {$line == "$class: $name"} {
-			return 1
-		}
+	if {$line == "$class: $name"} {
+	    return 1
+	}
     }
     return 0
@@ -672,5 +672,5 @@
 proc write_statefile {class name fd} {
     if {[check_statefile $class $name $fd]} {
-		return 0
+	return 0
     }
     seek $fd 0 end
@@ -682,28 +682,28 @@
 # Check that recorded selection of variants match the current selection
 proc check_statefile_variants {variations fd} {
-	upvar $variations upvariations
-	
+    upvar $variations upvariations
+    
     seek $fd 0
     while {[gets $fd line] >= 0} {
-		if {[regexp "variant: (.*)" $line match name]} {
-			set oldvariations([string range $name 1 end]) [string range $name 0 0]
+	if {[regexp "variant: (.*)" $line match name]} {
+	    set oldvariations([string range $name 1 end]) [string range $name 0 0]
+	}
+    }
+    
+    set mismatch 0
+    if {[array size oldvariations] > 0} {
+	if {[array size oldvariations] != [array size upvariations]} {
+	    set mismatch 1
+	} else {
+	    foreach key [array names upvariations *] {
+		if {![info exists oldvariations($key)] || $upvariations($key) != $oldvariations($key)} {
+		    set mismatch 1
+		    break
 		}
-    }
-
-	set mismatch 0
-	if {[array size oldvariations] > 0} {
-		if {[array size oldvariations] != [array size upvariations]} {
-			set mismatch 1
-		} else {
-			foreach key [array names upvariations *] {
-				if {![info exists oldvariations($key)] || $upvariations($key) != $oldvariations($key)} {
-					set mismatch 1
-					break
-				}
-			}
-		}
-	}
-
-	return $mismatch
+	    }
+	}
+    }
+    
+    return $mismatch
 }
 
@@ -770,13 +770,13 @@
     set name [ditem_key $ditem name]
     ui_debug "Executing $name provides [ditem_key $ditem provides]"
-
-	# test for conflicting variants
-	foreach v [ditem_key $ditem conflicts] {
-		if {[variant_isset $v]} {
-			ui_error "Variant $name conflicts with $v"
-			return 1
-		}
-	}
-
+    
+    # test for conflicting variants
+    foreach v [ditem_key $ditem conflicts] {
+	if {[variant_isset $v]} {
+	    ui_error "Variant $name conflicts with $v"
+	    return 1
+	}
+    }
+    
     # execute proc with same name as variant.
     if {[catch "variant-${name}" result]} {
@@ -790,5 +790,5 @@
     global all_variants ports_force
     set dlist $all_variants
-	set result 0
+    set result 0
     upvar $variations upvariations
     set chosen [choose_variants $dlist upvariations]
@@ -806,30 +806,30 @@
     
     dlist_eval $newlist "" variant_run
-	
-	# Make sure the variations match those stored in the statefile.
-	# If they don't match, print an error indicating a 'port clean' 
-	# should be performed.  
-	# - Skip this test if the statefile is empty.
-	# - Skip this test if performing a clean.
-	# - Skip this test if ports_force was specified.
-
-	if {$target != "clean" && 
-		!([info exists ports_force] && $ports_force == "yes")} {
-		set state_fd [open_statefile]
-	
-		if {[check_statefile_variants upvariations $state_fd]} {
-			ui_error "Requested variants do not match original selection.\nPlease perform 'port clean' or specify the force option."
-			set result 1
-		} else {
-			# Write variations out to the statefile
-			foreach key [array names upvariations *] {
-				write_statefile variant $upvariations($key)$key $state_fd
-			}
-		}
-		
-		close $state_fd
-	}
-	
-	return $result
+    
+    # Make sure the variations match those stored in the statefile.
+    # If they don't match, print an error indicating a 'port clean' 
+    # should be performed.  
+    # - Skip this test if the statefile is empty.
+    # - Skip this test if performing a clean.
+    # - Skip this test if ports_force was specified.
+    
+    if {$target != "clean" && 
+	!([info exists ports_force] && $ports_force == "yes")} {
+	set state_fd [open_statefile]
+	
+	if {[check_statefile_variants upvariations $state_fd]} {
+	    ui_error "Requested variants do not match original selection.\nPlease perform 'port clean' or specify the force option."
+	    set result 1
+	} else {
+	    # Write variations out to the statefile
+	    foreach key [array names upvariations *] {
+		write_statefile variant $upvariations($key)$key $state_fd
+	    }
+	}
+	
+	close $state_fd
+    }
+    
+    return $result
 }
 
@@ -840,7 +840,7 @@
     global targets
     set ditem [ditem_create]
-	
-	ditem_key $ditem name $name
-	ditem_key $ditem procedure $procedure
+    
+    ditem_key $ditem name $name
+    ditem_key $ditem procedure $procedure
     
     lappend targets $ditem
@@ -861,5 +861,5 @@
 	    ui_debug "$ident registered provides \'$target\', a pre-existing procedure. Target override will not be provided"
 	} else {
-		eval "proc $target {args} \{ \n\
+	    eval "proc $target {args} \{ \n\
 			variable proc_index \n\
 			set proc_index \[llength \[ditem_key $ditem proc\]\] \n\
@@ -927,5 +927,5 @@
 
 proc target_runtype {ditem args} {
-	eval "ditem_append $ditem runtype $args"
+    eval "ditem_append $ditem runtype $args"
 }
 
@@ -974,7 +974,7 @@
         set options(workpath) ${newworkpath}
     }
-	# Escape regex special characters
-	regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" search_string 
-
+    # Escape regex special characters
+    regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" search_string 
+    
     set res [dportsearch ^$search_string\$]
     if {[llength $res] < 2} {
@@ -982,5 +982,5 @@
         return -1
     }
-
+    
     array set portinfo [lindex $res 1]
     set porturl $portinfo(porturl)
@@ -1013,5 +1013,5 @@
     set home /dev/null
     set shell /dev/null
-
+    
     foreach arg $args {
 	if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
@@ -1020,9 +1020,9 @@
 	}
     }
-
+    
     if {[existsuser ${name}] != 0 || [existsuser ${uid}] != 0} {
 	return
     }
-
+    
     if {${os.platform} == "darwin"} {
 	system "niutil -create . /users/${name}"
@@ -1046,5 +1046,5 @@
     set passwd {\*}
     set users ""
-
+    
     foreach arg $args {
 	if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
@@ -1053,9 +1053,9 @@
 	}
     }
-
+    
     if {[existsgroup ${name}] != 0 || [existsgroup ${gid}] != 0} {
 	return
     }
-
+    
     if {${os.platform} == "darwin"} {
 	system "niutil -create . /groups/${name}"
@@ -1097,5 +1097,5 @@
 	}
     }
-   
+    
     return -code error [format [msgcat::mc "Failed to locate '%s' in path: '%s'"] $binary $env(PATH)];
 }
