Ticket #8221: upgrade-variants.diff
File upgrade-variants.diff, 10.5 KB (added by jmroot (Joshua Root), 17 years ago) |
---|
-
src/port/port.tcl
1494 1494 return 1 1495 1495 } 1496 1496 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] 1501 1501 } 1502 }1503 1502 1504 macports::upgrade $portname "port:$portname" [array get variations] [array get options]1505 }1506 1507 1503 return 0 1508 1504 } 1509 1505 -
src/macports1.0/macports.tcl
1850 1850 } 1851 1851 1852 1852 # upgrade procedure 1853 proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {1853 proc macports::upgrade {portname dspec globalvarlist variationslist optionslist {depscachename ""}} { 1854 1854 global macports::registry.installtype 1855 1855 global macports::portarchivemode 1856 1856 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 1857 1861 array set variations $variationslist 1858 1862 if {![string match "" $depscachename]} { 1859 1863 upvar $depscachename depscache … … 1890 1894 # if this is set (not 0) we dont follow the deps 1891 1895 set depflag 0 1892 1896 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 1893 1901 # set version_installed and revision_installed 1894 1902 set ilist {} 1895 1903 if { [catch {set ilist [registry::installed $portname ""]} result] } { … … 1900 1908 if {![info exists porturl]} { 1901 1909 set porturl file://./ 1902 1910 } 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]} { 1904 1919 global errorInfo 1905 1920 ui_debug "$errorInfo" 1906 1921 ui_error "Unable to open port: $result" 1907 1922 return 1 1908 1923 } 1924 # While we're at it, update the portinfo 1925 array unset portinfo 1926 array set portinfo [mportinfo $workername] 1927 set portwasopened 1 1909 1928 1910 1929 if {![_mportispresent $workername $dspec ] } { 1911 1930 # port in not installed - install it! … … 1915 1934 ui_error "Unable to exec port: $result" 1916 1935 return 1 1917 1936 } 1937 if {$result > 0} { 1938 ui_error "Problem while installing $portname" 1939 return $result 1940 } 1918 1941 } else { 1919 1942 # port installed outside MacPorts 1920 1943 ui_debug "$portname installed outside the MacPorts system" 1921 1944 set depflag 1 1922 1945 } 1923 1946 1947 # update ilist since we just did an installation 1948 set ilist [registry::installed $portname ""] 1924 1949 } else { 1925 1950 ui_error "Checking installed version failed: $result" 1926 1951 exit 1 … … 1972 1997 } 1973 1998 } 1974 1999 } 2000 # record the variant of the latest version 2001 set variant [lindex $num 3] 1975 2002 if { [lindex $num 4] == 0 && 0 == [string compare "image" ${macports::registry.installtype}] } { 1976 2003 # activate the latest installed version 1977 2004 if {[catch {portimage::activate $portname ${version_installed}_${revision_installed}$variant $optionslist} result]} { … … 1986 2013 # output version numbers 1987 2014 ui_debug "epoch: in tree: $epoch_in_tree installed: $epoch_installed" 1988 2015 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" 1990 2017 1991 2018 # set the nodeps option 1992 2019 if {![info exists options(ports_nodeps)]} { … … 1995 2022 set nodeps yes 1996 2023 } 1997 2024 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 1998 2082 if {$nodeps == "yes" || $depflag == 1} { 1999 2083 ui_debug "Not following dependencies" 2000 2084 set depflag 0 … … 2005 2089 if {![llength [array get depscache $i]]} { 2006 2090 set d [lindex [split $i :] end] 2007 2091 set depscache($i) 1 2008 upgrade $d $i$variationslist $optionslist depscache2092 upgrade $d $i $globalvarlist $variationslist $optionslist depscache 2009 2093 } 2010 2094 } 2011 2095 } … … 2015 2099 if {![llength [array get depscache $i]]} { 2016 2100 set d [lindex [split $i :] end] 2017 2101 set depscache($i) 1 2018 upgrade $d $i$variationslist $optionslist depscache2102 upgrade $d $i $globalvarlist $variationslist $optionslist depscache 2019 2103 } 2020 2104 } 2021 2105 } … … 2025 2109 if {![llength [array get depscache $i]]} { 2026 2110 set d [lindex [split $i :] end] 2027 2111 set depscache($i) 1 2028 upgrade $d $i$variationslist $optionslist depscache2112 upgrade $d $i $globalvarlist $variationslist $optionslist depscache 2029 2113 } 2030 2114 } 2031 2115 } … … 2037 2121 && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 )) 2038 2122 && ![info exists options(ports_force)] } { 2039 2123 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 } 2040 2128 if { $epoch_installed >= $epoch_in_tree } { 2041 2129 # Check if we have to do dependents 2042 2130 if {[info exists options(ports_do_dependents)]} { … … 2049 2137 if { [llength deplist] > 0 } { 2050 2138 foreach dep $deplist { 2051 2139 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] 2053 2141 } 2054 2142 } 2055 2143 } … … 2061 2149 } 2062 2150 } 2063 2151 2064 # open porthandle2065 set porturl $portinfo(porturl)2066 if {![info exists porturl]} {2067 set porturl file://./2068 }2069 2152 2070 # check if the variants is present in $version_in_tree2071 set oldvariant $variant2072 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 errorInfo2091 ui_debug "$errorInfo"2092 ui_error "Unable to open port: $result"2093 return 12094 }2095 2096 2153 # install version_in_tree 2097 2154 if {0 == [string compare "yes" ${macports::portarchivemode}]} { 2098 2155 set upgrade_action "archive" … … 2145 2202 if { [llength deplist] > 0 } { 2146 2203 foreach dep $deplist { 2147 2204 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] 2149 2206 } 2150 2207 } 2151 2208 }