[53371] trunk/base/src

jmr at macports.org jmr at macports.org
Sat Jul 4 00:52:39 PDT 2009


Revision: 53371
          http://trac.macports.org/changeset/53371
Author:   jmr at macports.org
Date:     2009-07-04 00:52:37 -0700 (Sat, 04 Jul 2009)
Log Message:
-----------
Revamp unsetting of implicit variants. They now stay set for informational targets, and for mirror. A warning is printed for each one that is removed, but not for ones that come from the currently installed version in upgrade. Closes #12563.

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2009-07-04 06:53:05 UTC (rev 53370)
+++ trunk/base/src/macports1.0/macports.tcl	2009-07-04 07:52:37 UTC (rev 53371)
@@ -1033,6 +1033,38 @@
     return $proposedpath
 }
 
+
+# mport_filtervariants
+# returns the given list of variants with implicitly-set ones removed
+proc mport_filtervariants {variations {warn yes}} {
+    # Iterate through the variants, filtering out
+    # implicit ones. At the moment, the only implicit variants are
+    # platform variants.
+    set filteredvariations {}
+
+    foreach {variation value} $variations {
+        switch -regexp $variation {
+            ^(pure)?darwin         -
+            ^(free|net|open){1}bsd -
+            ^i386                  -
+            ^linux                 -
+            ^macosx                -
+            ^powerpc               -
+            ^solaris               -
+            ^sunos {
+                if {$warn} {
+                    ui_warn "Implicit variants should not be explicitly set or unset. $variation will be ignored."
+                }
+            }
+            default {
+                lappend filteredvariations $variation $value
+            }
+        }
+    }
+    return $filteredvariations
+}
+
+
 # mportopen
 # Opens a MacPorts portfile specified by a URL.  The Portfile is
 # opened with the given list of options and variations.  The result
@@ -1071,29 +1103,6 @@
         return -code error "Could not find Portfile in $portpath"
     }
 
-    # Iterate through the explicitly set/unset variants, filtering out
-    # implicit variants. At the moment, the only implicit variants are
-    # platform variants.
-    set filteredvariations {}
-
-    foreach {variation value} $variations {
-        switch -regexp $variation {
-            ^(pure)?darwin         -
-            ^(free|net|open){1}bsd -
-            ^i386                  -
-            ^linux                 -
-            ^macosx                -
-            ^powerpc               -
-            ^solaris               -
-            ^sunos {
-                ui_debug "Implicit variants should not be explicitly set or unset. $variation will be ignored."
-            }
-            default {
-                lappend filteredvariations $variation $value
-            }
-        }
-    }
-
     set workername [interp create]
 
     set mport [ditem_create]
@@ -1102,10 +1111,10 @@
     ditem_key $mport portpath $portpath
     ditem_key $mport workername $workername
     ditem_key $mport options $options
-    ditem_key $mport variations $filteredvariations
+    ditem_key $mport variations $variations
     ditem_key $mport refcnt 1
 
-    macports::worker_init $workername $portpath $porturl [macports::getportbuildpath $portpath] $options $filteredvariations
+    macports::worker_init $workername $portpath $porturl [macports::getportbuildpath $portpath] $options $variations
 
     $workername eval source Portfile
 
@@ -2395,21 +2404,28 @@
         set porturl file://./
     }
 
-    # check if the variants is present in $version_in_tree
-    set variant [split $oldvariant +]
+    # will break if we start recording negative variants (#2377)
+    set variant [lrange [split $oldvariant +] 1 end]
     ui_debug "Merging existing variants $variant into variants"
+    set oldvariantlist [list]
+    foreach v $variant {
+        lappend oldvariantlist $v "+"
+    }
+    # remove implicit variants, without printing warnings
+    set oldvariantlist [mport_filtervariants $oldvariantlist no]
+
+    # check if the variants are present in $version_in_tree
     if {[info exists portinfo(variants)]} {
         set avariants $portinfo(variants)
     } else {
         set avariants {}
     }
     ui_debug "available variants are : $avariants"
-    foreach v $variant {
-        if {[lsearch $avariants $v] == -1} {
-        } else {
-            ui_debug "variant $v is present in $portname $version_in_tree"
-            if { ![info exists variations($v)]} {
-                set variations($v) "+"
+    foreach {variation value} $oldvariantlist {
+        if {[lsearch $avariants $variation] != -1} {
+            ui_debug "variant $variation is present in $portname $version_in_tree"
+            if { ![info exists variations($variation)]} {
+                set variations($variation) $value
             }
         }
     }

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2009-07-04 06:53:05 UTC (rev 53370)
+++ trunk/base/src/port/port.tcl	2009-07-04 07:52:37 UTC (rev 53371)
@@ -1991,8 +1991,13 @@
         if {![info exists depscache(port:$portname)]} {
             # Global variations will have to be merged into the specified
             # variations, but perhaps after the installed variations are
-            # merged. So we pass them into upgrade:
-            macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache
+            # merged. So we pass them into upgrade.
+            
+            # First filter out implicit variants from the explicitly set/unset variants.
+            set global_variations_list [mport_filtervariants [array get global_variations] yes]
+            set variations_list [mport_filtervariants [array get variations] yes]
+            
+            macports::upgrade $portname "port:$portname" $global_variations_list $variations_list [array get options] depscache
         }
     }
 
@@ -2863,6 +2868,17 @@
                 set variations($variation) $value
             }
         }
+        # Filter out implicit variants from the explicitly set/unset variants.
+        # Except we need to keep them for some targets to work right...
+        switch -exact $target {
+            distfiles -
+            mirror {}
+            default {
+                set variationslist [mport_filtervariants [array get variations] yes]
+                array unset variations
+                array set variations $variationslist
+            }
+        }
 
         # If version was specified, save it as a version glob for use
         # in port actions (e.g. clean).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090704/f2b320d0/attachment.html>


More information about the macports-changes mailing list