Changeset 124476


Ignore:
Timestamp:
Aug 24, 2014, 8:22:58 PM (5 years ago)
Author:
jmr@…
Message:

fix uninstall --follow-dependencies brokenness

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/registry2.0/portuninstall.tcl

    r124243 r124476  
    4444# generate list of all dependencies of the port
    4545proc generate_deplist {port {optslist ""}} {
    46     array set options $optslist
    47     # note deps before we uninstall if we're going to uninstall them too
    48     if {[info exists options(ports_uninstall_follow-dependencies)] && [string is true -strict $options(ports_uninstall_follow-dependencies)]} {
    49         set deptypes {depends_fetch depends_extract depends_build depends_lib depends_run}
    50         set all_dependencies {}
    51         # look up deps from the saved portfile if possible
    52         if {![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optslist]}]} {
    53             array set depportinfo [mportinfo $mport]
    54             mportclose $mport
     46
     47    set deptypes {depends_fetch depends_extract depends_build depends_lib depends_run}
     48    set all_dependencies {}
     49    # look up deps from the saved portfile if possible
     50    if {![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optslist]}]} {
     51        array set depportinfo [mportinfo $mport]
     52        mportclose $mport
     53        foreach type $deptypes {
     54            if {[info exists depportinfo($type)]} {
     55                foreach dep $depportinfo($type) {
     56                    lappend all_dependencies [lindex [split $dep :] end]
     57                }
     58            }
     59        }
     60        # append those from the registry (could be different because of path deps)
     61        foreach dep [$port dependencies] {
     62            lappend all_dependencies [$dep name]
     63        }
     64    } else {
     65        # grab the deps from the dep map
     66        set portname [$port name]
     67        set depmaplist [registry::list_depends $portname [$port version] [$port revision] [$port variants]]
     68        foreach dep $depmaplist {
     69            lappend all_dependencies [lindex $dep 0]
     70        }
     71        # and the ones from the current portfile
     72        if {![catch {mportlookup $portname} result] && [llength $result] >= 2} {
     73            array set depportinfo [lindex $result 1]
     74            set porturl $depportinfo(porturl)
     75            set variations {}
     76            set minusvariant [lrange [split [registry::property_retrieve $port negated_variants] -] 1 end]
     77            set plusvariant [lrange [split [$port variants] +] 1 end]
     78            foreach v $plusvariant {
     79                lappend variations $v "+"
     80            }
     81            foreach v $minusvariant {
     82                lappend variations $v "-"
     83            }
     84            if {![catch {set mport [mportopen $porturl [concat $optslist subport $portname] [array get variations]]} result]} {
     85                array unset depportinfo
     86                array set depportinfo [mportinfo $mport]
     87                mportclose $mport
     88            }
    5589            foreach type $deptypes {
    5690                if {[info exists depportinfo($type)]} {
     
    6094                }
    6195            }
    62             # append those from the registry (could be different because of path deps)
    63             foreach dep [$port dependencies] {
    64                 lappend all_dependencies [$dep name]
    65             }
    66         } else {
    67             # grab the deps from the dep map
    68             set portname [$port name]
    69             set depmaplist [registry::list_depends $portname [$port version] [$port revision] [$port variants]]
    70             foreach dep $depmaplist {
    71                 lappend all_dependencies [lindex $dep 0]
    72             }
    73             # and the ones from the current portfile
    74             if {![catch {mportlookup $portname} result] && [llength $result] >= 2} {
    75                 array set depportinfo [lindex $result 1]
    76                 set porturl $depportinfo(porturl)
    77                 set variations {}
    78                 set minusvariant [lrange [split [registry::property_retrieve $port negated_variants] -] 1 end]
    79                 set plusvariant [lrange [split [$port variants] +] 1 end]
    80                 foreach v $plusvariant {
    81                     lappend variations $v "+"
    82                 }
    83                 foreach v $minusvariant {
    84                     lappend variations $v "-"
    85                             }
    86                 if {![catch {set mport [mportopen $porturl [concat $optionslist subport $portname] [array get variations]]} result]} {
    87                     array unset depportinfo
    88                     array set depportinfo [mportinfo $mport]
    89                     mportclose $mport
    90                 }
    91                 foreach type $deptypes {
    92                     if {[info exists depportinfo($type)]} {
    93                         foreach dep $depportinfo($type) {
    94                             lappend all_dependencies [lindex [split $dep :] end]
    95                         }
    96                     }
    97                 }
    98             }
    99         }
    100         array unset depportinfo
    101         set all_dependencies [lsort -unique $all_dependencies]
    102         return $all_dependencies
    103     }
    104     return {}
     96        }
     97    }
     98    set all_dependencies [lsort -unique $all_dependencies]
     99    return $all_dependencies
    105100}
    106101
     
    246241    }
    247242
    248     set ref $port
    249     # save list of dependencies if --follow-dependencies specified
    250     if {[info exists options(ports_uninstall_follow-dependencies)]} {
     243    # note deps before we uninstall if we're going to uninstall them too (i.e. --follow-dependencies)
     244    if {[info exists options(ports_uninstall_follow-dependencies)] && [string is true -strict $options(ports_uninstall_follow-dependencies)]} {
    251245        set all_dependencies [registry_uninstall::generate_deplist $port $optionslist]
    252246    }
     
    258252
    259253        # Get the full path to the image file
     254        set ref $port
    260255        set imagefile [registry::property_retrieve $ref location]
    261256        file delete $imagefile
     
    341336                }
    342337            }
    343             set depref [registry::entry imaged $dep]
    344             set depdeps [registry_uninstall::generate_deplist $depref $optionslist]
    345             foreach d $depdeps {
    346                 set index [lsearch $alldeps $d]
    347                 if {$index == -1} {
    348                     lappend alldeps $d
     338            set deprefs [registry::entry imaged $dep]
     339            foreach depref $deprefs {
     340                set depdeps [registry_uninstall::generate_deplist $depref $optionslist]
     341                foreach d $depdeps {
     342                    set index [lsearch $alldeps $d]
     343                    if {$index == -1} {
     344                        lappend alldeps $d
     345                    }
    349346                }
    350347            }
Note: See TracChangeset for help on using the changeset viewer.