<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/ea850b224bf886c7d3e29dc05bc84b4336b08767">https://github.com/macports/macports-base/commit/ea850b224bf886c7d3e29dc05bc84b4336b08767</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit ea850b224bf886c7d3e29dc05bc84b4336b08767
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Thu Dec 8 01:04:55 2016 +1100
<span style='display:block; white-space:pre;color:#404040;'> Uninstall in correct order in reclaim
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Sort inactive ports into dependency order before uninstalling, since
</span><span style='display:block; white-space:pre;color:#404040;'> some of them may depend on others. Also display version information
</span><span style='display:block; white-space:pre;color:#404040;'> as well as port names, as there may be more than one inactive version
</span><span style='display:block; white-space:pre;color:#404040;'> of any given port.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Fixes: https://trac.macports.org/ticket/52791
</span>---
src/macports1.0/reclaim.tcl | 55 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 4 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/reclaim.tcl b/src/macports1.0/reclaim.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 3d08c83..14ae244 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/reclaim.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/reclaim.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -373,6 +373,49 @@ namespace eval reclaim {
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc sort_portlist_by_dependendents {portlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Sorts a list of port references such that dependents appear before
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # the ports they depend on.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Args:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # portlist - the list of port references
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # the list in dependency-sorted order
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portname [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend ports_for_name($portname) $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists dependents($portname)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependents($portname) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach result [$port dependents] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend dependents($portname) [$result name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ret {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sortdependents_helper $port ports_for_name dependents seen ret
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $ret
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc sortdependents_helper {port up_ports_for_name up_dependents up_seen up_retlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upvar 1 $up_seen seen
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists seen($port)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen($port) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upvar 1 $up_ports_for_name ports_for_name $up_dependents dependents $up_retlist retlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependent $dependents([$port name]) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists ports_for_name($dependent)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach entry $ports_for_name($dependent) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sortdependents_helper $entry ports_for_name dependents seen retlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend retlist $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc uninstall_inactive {} {
# Attempts to uninstall all inactive ports. (Performance is now O(N)!)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -391,30 +434,34 @@ namespace eval reclaim {
</span> foreach port [registry::entry imaged] {
if {[$port state] eq "imaged"} {
lappend inactive_ports $port
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend inactive_names [$port name]
</span> incr inactive_count
}
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set inactive_ports [sort_portlist_by_dependendents $inactive_ports]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $inactive_ports {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend inactive_names "[$port name] @[$port version]_[$port revision][$port variants]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if { $inactive_count == 0 } {
ui_msg "Found no inactive ports."
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg "Found inactive ports: $inactive_names."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Found inactive ports: [join $inactive_names {, }]."
</span> if {[info exists macports::ui_options(questions_multichoice)]} {
set retstring [$macports::ui_options(questions_multichoice) "Would you like to uninstall these ports?" "" $inactive_names]
if {[llength $retstring] > 0} {
foreach i $retstring {
set port [lindex $inactive_ports $i]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [lindex $inactive_names $i]
</span>
ui_msg "Uninstalling: $name"
# Note: 'uninstall' takes a name, version, revision, variants and an options list.
try -pass_signal {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- registry_uninstall::uninstall $name [$port version] [$port revision] [$port variants] {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ registry_uninstall::uninstall [$port name] [$port version] [$port revision] [$port variants] {}
</span> } catch {{*} eCode eMessage} {
ui_error "Error uninstalling $name: $eMessage"
}
</pre><pre style='margin:0'>
</pre>