Ticket #8221: upgrade-variants.diff

File upgrade-variants.diff, 10.5 KB (added by jmroot (Joshua Root), 16 years ago)

updated patch against current base

  • src/port/port.tcl

     
    14941494        return 1
    14951495    }
    14961496    foreachport $portlist {
    1497         # Merge global variations into the variations specified for this port
    1498         foreach { variation value } [array get global_variations] {
    1499             if { ![info exists variations($variation)] } {
    1500                 set variations($variation) $value
     1497                # Global variations will have to be merged into the specified
     1498                # variations, but perhaps after the installed variations are
     1499                # merged. So we pass them into upgrade:
     1500                macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options]
    15011501            }
    1502         }
    15031502
    1504         macports::upgrade $portname "port:$portname" [array get variations] [array get options]
    1505     }
    1506 
    15071503    return 0
    15081504}
    15091505
  • src/macports1.0/macports.tcl

     
    18501850}
    18511851
    18521852# upgrade procedure
    1853 proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {
     1853proc macports::upgrade {portname dspec globalvarlist variationslist optionslist {depscachename ""}} {
    18541854    global macports::registry.installtype
    18551855    global macports::portarchivemode
    18561856    array set options $optionslist
     1857        # Note $variationslist is left alone and so retains the original
     1858        # requested variations, which should be passed to recursive calls to
     1859        # upgrade; while variations gets existing variants and global variations
     1860        # merged in later on, so it applies only to this port's upgrafe
    18571861    array set variations $variationslist
    18581862    if {![string match "" $depscachename]} {
    18591863        upvar $depscachename depscache
     
    18901894    # if this is set (not 0) we dont follow the deps
    18911895    set depflag 0
    18921896
     1897        # Sooner or later we may have to open this port to update the portinfo
     1898        # by evaluating the variants. Keep track of whether this has happened
     1899        set portwasopened 0
     1900
    18931901    # set version_installed and revision_installed
    18941902    set ilist {}
    18951903    if { [catch {set ilist [registry::installed $portname ""]} result] } {
     
    19001908            if {![info exists porturl]} {
    19011909                set porturl file://./   
    19021910            }   
    1903             if {[catch {set workername [mportopen $porturl [array get options] ]} result]} {
     1911                        # Merge the global variations into the specified
     1912                        foreach { variation value } $globalvarlist {
     1913                                if { ![info exists variations($variation)] } {
     1914                                        set variations($variation) $value
     1915                                }
     1916                        }
     1917               
     1918                        if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
    19041919                    global errorInfo
    19051920                    ui_debug "$errorInfo"
    19061921                    ui_error "Unable to open port: $result"       
    19071922                    return 1
    19081923            }
     1924                        # While we're at it, update the portinfo
     1925                        array unset portinfo
     1926                        array set portinfo [mportinfo $workername]
     1927                        set portwasopened 1
    19091928
    19101929            if {![_mportispresent $workername $dspec ] } {
    19111930                # port in not installed - install it!
     
    19151934                    ui_error "Unable to exec port: $result"
    19161935                    return 1
    19171936                }
     1937                                if {$result > 0} {
     1938                                        ui_error "Problem while installing $portname"
     1939                                        return $result
     1940                                }
    19181941            } else {
    19191942                # port installed outside MacPorts
    19201943                ui_debug "$portname installed outside the MacPorts system"
    19211944                set depflag 1
    19221945            }
    19231946
     1947                        # update ilist since we just did an installation
     1948                        set ilist [registry::installed $portname ""]
    19241949        } else {
    19251950            ui_error "Checking installed version failed: $result"
    19261951            exit 1
     
    19721997                }
    19731998            }
    19741999        }
     2000                # record the variant of the latest version
     2001                set variant [lindex $num 3]
    19752002        if { [lindex $num 4] == 0 && 0 == [string compare "image" ${macports::registry.installtype}] } {
    19762003            # activate the latest installed version
    19772004            if {[catch {portimage::activate $portname ${version_installed}_${revision_installed}$variant $optionslist} result]} {
     
    19862013    # output version numbers
    19872014    ui_debug "epoch: in tree: $epoch_in_tree installed: $epoch_installed"
    19882015    ui_debug "$portname ${version_in_tree}_$revision_in_tree exists in the ports tree"
    1989     ui_debug "$portname ${version_installed}_$revision_installed is installed"
     2016    ui_debug "$portname ${version_installed}_$revision_installed $variant is installed"
    19902017
    19912018    # set the nodeps option 
    19922019    if {![info exists options(ports_nodeps)]} {
     
    19952022        set nodeps yes
    19962023    }
    19972024
     2025        # save existing variant for later use
     2026        set oldvariant $variant
     2027        if {$portwasopened == 0} {
     2028                # If the port has not been opened, then before we do
     2029                # dependencies, we need to figure out the final variants,
     2030                # open the port, and update the portinfo. (If it was opened,
     2031                # then the variants must still be the ones we opened it with,
     2032                # and the portinfo is correct.)
     2033
     2034                set porturl $portinfo(porturl)
     2035                if {![info exists porturl]} {
     2036                        set porturl file://./
     2037                }
     2038
     2039                # check if the variants is present in $version_in_tree
     2040                set variant [split $variant +]
     2041                ui_debug "Merging existing variants $variant into variants"
     2042                if {[info exists portinfo(variants)]} {
     2043                        set avariants $portinfo(variants)
     2044                } else {
     2045                        set avariants {}
     2046                }
     2047                ui_debug "available variants are : $avariants"
     2048                foreach v $variant {
     2049                        if {[lsearch $avariants $v] == -1} {
     2050                        } else {
     2051                                ui_debug "variant $v is present in $portname $version_in_tree"
     2052                                if { ![info exists variations($v)]} {
     2053                                        set variations($v) "+"
     2054                                }
     2055                        }
     2056                }
     2057               
     2058                # Now merge in the global (i.e. variants.conf) variations.
     2059                # We wait until now so that existing variants for this port
     2060                # override global variations
     2061                foreach { variation value } $globalvarlist {
     2062                        if { ![info exists variations($variation)] } {
     2063                                set variations($variation) $value
     2064                        }
     2065                }
     2066               
     2067                ui_debug "new fully merged portvariants: [array get variations]"
     2068       
     2069                if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
     2070                        global errorInfo
     2071                        ui_debug "$errorInfo"
     2072                        ui_error "Unable to open port: $result"
     2073                        return 1
     2074                }
     2075
     2076                array unset portinfo
     2077                array set portinfo [mportinfo $workername]
     2078                set portwasopened 1
     2079        }
     2080               
     2081
    19982082    if {$nodeps == "yes" || $depflag == 1} {
    19992083        ui_debug "Not following dependencies"
    20002084        set depflag 0
     
    20052089                if {![llength [array get depscache $i]]} {
    20062090                set d [lindex [split $i :] end]
    20072091                    set depscache($i) 1
    2008                     upgrade $d $i $variationslist $optionslist depscache
     2092                                        upgrade $d $i $globalvarlist $variationslist $optionslist depscache
    20092093                }
    20102094            }
    20112095        }
     
    20152099                if {![llength [array get depscache $i]]} {
    20162100                set d [lindex [split $i :] end]
    20172101                    set depscache($i) 1
    2018                     upgrade $d $i $variationslist $optionslist depscache
     2102                                        upgrade $d $i $globalvarlist $variationslist $optionslist depscache
    20192103                }
    20202104            }
    20212105        }
     
    20252109                if {![llength [array get depscache $i]]} {
    20262110                set d [lindex [split $i :] end]
    20272111                    set depscache($i) 1
    2028                     upgrade $d $i $variationslist $optionslist depscache
     2112                                        upgrade $d $i $globalvarlist $variationslist $optionslist depscache
    20292113                }
    20302114            }
    20312115        }
     
    20372121                && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 ))
    20382122        && ![info exists options(ports_force)] } {
    20392123        ui_debug "No need to upgrade! $portname ${version_installed}_$revision_installed >= $portname ${version_in_tree}_$revision_in_tree"
     2124                if {[info exists portinfo(portvariants)]
     2125                    && $portinfo(portvariants) != $oldvariant} {
     2126                        ui_warn "Skipping upgrdae since $portname $version_installed >= $portname $version_in_tree, even though installed variant $oldvariant differs from $portinfo(portvariants). Specify -f to force upgrade."
     2127                }
    20402128        if { $epoch_installed >= $epoch_in_tree } {
    20412129            # Check if we have to do dependents
    20422130            if {[info exists options(ports_do_dependents)]} {
     
    20492137                if { [llength deplist] > 0 } {
    20502138                    foreach dep $deplist {
    20512139                        set mpname [lindex $dep 2]
    2052                         macports::upgrade $mpname "port:$mpname" [array get variations] [array get options]
     2140                                                macports::upgrade $mpname "port:$mpname" $globalvarlist $variationslist [array get options]
    20532141                    }
    20542142                }
    20552143            }
     
    20612149        }
    20622150    }
    20632151
    2064     # open porthandle
    2065     set porturl $portinfo(porturl)
    2066     if {![info exists porturl]} {
    2067         set porturl file://./
    2068     }
    20692152
    2070     # check if the variants is present in $version_in_tree
    2071     set oldvariant $variant
    2072     set variant [split $variant +]
    2073     ui_debug "variants to install $variant"
    2074     if {[info exists portinfo(variants)]} {
    2075         set avariants $portinfo(variants)
    2076     } else {
    2077         set avariants {}
    2078     }
    2079     ui_debug "available variants are : $avariants"
    2080     foreach v $variant {
    2081         if {[lsearch $avariants $v] == -1} {
    2082         } else {
    2083             ui_debug "variant $v is present in $portname ${version_in_tree}_$revision_in_tree"
    2084             set variations($v) "+"
    2085         }
    2086     }
    2087     ui_debug "new portvariants: [array get variations]"
    2088    
    2089     if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
    2090         global errorInfo
    2091         ui_debug "$errorInfo"
    2092         ui_error "Unable to open port: $result"
    2093         return 1
    2094     }
    2095 
    20962153    # install version_in_tree
    20972154    if {0 == [string compare "yes" ${macports::portarchivemode}]} {
    20982155        set upgrade_action "archive"
     
    21452202        if { [llength deplist] > 0 } {
    21462203            foreach dep $deplist {
    21472204                set mpname [lindex $dep 2]
    2148                 macports::upgrade $mpname "port:$mpname" [array get variations] [array get options]
     2205                                macports::upgrade $mpname "port:$mpname" $globalvarlist $variationslist [array get options]
    21492206            }
    21502207        }
    21512208    }