[81668] branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl

cal at macports.org cal at macports.org
Wed Aug 3 13:33:19 PDT 2011


Revision: 81668
          http://trac.macports.org/changeset/81668
Author:   cal at macports.org
Date:     2011-08-03 13:33:17 -0700 (Wed, 03 Aug 2011)
Log Message:
-----------
rev-upgrade: Rebuild ports using own options rather than specifying force and nodepends

Modified Paths:
--------------
    branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl

Modified: branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl	2011-08-03 20:22:35 UTC (rev 81667)
+++ branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl	2011-08-03 20:33:17 UTC (rev 81668)
@@ -3113,6 +3113,16 @@
         set is_dryrun yes
     }
 
+    # Is this a rev-upgrade-called run?
+    set is_revupgrade no
+    if {[macports::global_option_isset ports_revupgrade]} {
+        set is_revupgrade yes
+    }
+    set is_revupgrade_second_run no
+    if {[macports::global_option_isset ports_revupgrade_second_run]} {
+        set is_revupgrade_second_run yes
+    }
+
     # check if the port is in tree
     if {[catch {mportlookup $portname} result]} {
         global errorInfo
@@ -3378,18 +3388,26 @@
                 ui_debug "No need to upgrade! $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}"
             }
             set will_install no
+            if {$is_revupgrade} {
+                set will_install yes
+            }
+            if {$is_revupgrade_second_run} {
+                set build_override 1
+            }
         }
     }
 
     set will_build no
     # avoid building again unnecessarily
-    if {$will_install && ([info exists options(ports_upgrade_force)] || $build_override == 1
-        || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)])} {
+    if {$will_install &&
+        ([info exists options(ports_upgrade_force)]
+            || $build_override == 1
+            || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)])} {
         set will_build yes
     }
 
     # first upgrade dependencies
-    if {![info exists options(ports_nodeps)]} {
+    if {![info exists options(ports_nodeps)] && !$is_revupgrade} {
         set status [_upgrade_dependencies portinfo depscache variationslist options $will_build]
         if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
             catch {mportclose $workername}
@@ -3932,40 +3950,31 @@
         set status 0
         foreach port $topsort_ports {
             if {![info exists depscache(port:[$port name])]} {
-                array set variations {}
-                
-                set strindex 0
-                set variantsstr "[$port variants][$port negated_variants]"
-                while {$strindex != [string length $variantsstr]} {
-                        set type [string index $variantsstr $strindex]
-                        if {$type != "+" && $type != "-"} {
-                            # ignore char not starting a variant definition
-                            incr $strindex
-                            continue
-                        }
 
-                        set endpidx [string first "+" $variantsstr $strindex+1]
-                        set endmidx [string first "-" $variantsstr $strindex+1]
-                        set endidx [expr $endpidx < $endmidx ? $endpidx : $endmidx]
+                # convert variations into the format macports::upgrade needs
+                set minusvariant [lrange [split [$port negated_variants] "-"] 1 end]
+                set plusvariant  [lrange [split [$port variants]         "+"] 1 end]
+                set variants     [list]
+                foreach v $minusvariant {
+                    lappend variants $v "-"
+                }
+                foreach v $plusvariant {
+                    lappend variants $v "+"
+                }
+                array set variations $variants
 
-                        if {$endidx != -1} {
-                            set variantname [string trim [string range $variantsstr $strindex+1 $endidx]]
-                            set strindex $endidx
-                        } else {
-                            # end of string
-                            set variantname [string trim [string range $variantsstr $strindex+1 end]]
-                            set strindex [string length $variantsstr]
-                        }
-
-                        set variations($variantname) $type
+                set macports::global_options(ports_revupgrade) "yes"
+                unset -nocomplain macports::global_options(ports_revupgrade_second_run)
+                if {$broken_port_counts([$port name]) > 1} {
+                    set macports::global_options(ports_revupgrade_second_run) yes
                 }
 
-                # make macports::upgrade behave like calling port -f -n upgrade [$port name]
-                set status [macports::upgrade [$port name] "port:[$port name]" [array get variations] {ports_upgrade_force yes ports_nodeps yes} depscache]
-                if {$status != 0 && ![macports::ui_isset ports_processall]} {
+                # call macports::upgrade with ports_revupgrade option to rebuild the port
+                set status [macports::upgrade [$port name] "port:[$port name]" \
+                    [array get variations] [array get macports::global_options] depscache]
+                if {$status != 0} {
                     error "Error rebuilding [$port name]"
                 }
-
             }
         }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110803/e48e45c5/attachment-0001.html>


More information about the macports-changes mailing list