<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/47ac2b39a3973d5a220cf076653dcf9e16a6512c">https://github.com/macports/macports-base/commit/47ac2b39a3973d5a220cf076653dcf9e16a6512c</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 47ac2b39a3973d5a220cf076653dcf9e16a6512c
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Thu Dec 8 00:02:24 2016 +1100
<span style='display:block; white-space:pre;color:#404040;'> Use registry2 API in reclaim
</span>---
src/macports1.0/reclaim.tcl | 68 +++++++++------------------------------------
1 file changed, 13 insertions(+), 55 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 1026375..3d08c83 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;'>@@ -146,7 +146,6 @@ namespace eval reclaim {
</span> set root_dist [file join ${macports::portdbpath} distfiles]
set home_dist ${macports::user_home}/.macports$root_dist
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set port_info [get_info]
</span> set files_in_use [list]
set fancyOutput [expr { ![macports::ui_isset ports_debug] \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -161,22 +160,18 @@ namespace eval reclaim {
</span> }
ui_msg "$macports::ui_prefix Building list of files still in use"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set port_count [llength $port_info]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installed_ports [registry::entry imaged]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set port_count [llength $installed_ports]
</span> set i 1
$progress start
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach port $port_info {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set version [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set revision [lindex $port 2]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set variants [lindex $port 3]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $installed_ports {
</span> # Get mport reference
try -pass_signal {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set mport [mportopen_installed $name $version $revision $variants {}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] {}]
</span> } catch {{*} eCode eMessage} {
$progress intermission
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn [msgcat::mc "Failed to open port %s from registry: %s" $name $eMessage]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn [msgcat::mc "Failed to open port %s from registry: %s" [$port name] $eMessage]
</span> continue
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -296,41 +291,6 @@ namespace eval reclaim {
</span> return 0
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc is_inactive {port} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Determines whether a port is inactive or not.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Args:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # port - An array where the fourth item in it is the activity of the port.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Returns:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # 1 if inactive, 0 if active.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[lindex $port 4] == 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Port [lindex $port 0] is inactive."
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Port [lindex $port 0] is not inactive."
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- proc get_info {} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Gets the information of all installed ports (those returned by registry::installed), and returns it in a
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # multidimensional list.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Args:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # None
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Returns:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # A multidimensional list where each port is a sublist, i.e., [{first port info} {second port info} {...}]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Indexes of each sublist are: 0 = name, 1 = version, 2 = revision, 3 = variants, 4 = activity, and 5 = epoch.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- try -pass_signal {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return [registry::installed]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } catch {*} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_error "no installed ports found."
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return {}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> proc read_last_run_file {} {
set path [file join ${macports::portdbpath} last_reclaim]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -417,23 +377,21 @@ namespace eval reclaim {
</span>
# Attempts to uninstall all inactive ports. (Performance is now O(N)!)
#
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Args:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Args:
</span> # None
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Returns:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # 0 if execution was successful. Errors (for now) if execution wasn't.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # 0 if execution was successful. Errors (for now) if execution wasn't.
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set ports [get_info]
</span> set inactive_ports [list]
set inactive_names [list]
set inactive_count 0
ui_debug "Iterating through all inactive ports."
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach port $ports {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if { [is_inactive $port] } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port [registry::entry imaged] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[$port state] eq "imaged"} {
</span> lappend inactive_ports $port
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend inactive_names [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend inactive_names [$port name]
</span> incr inactive_count
}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -450,13 +408,13 @@ namespace eval reclaim {
</span> if {[llength $retstring] > 0} {
foreach i $retstring {
set port [lindex $inactive_ports $i]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [$port name]
</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 [lindex $port 1] [lindex $port 2] [lindex $port 3] {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ registry_uninstall::uninstall $name [$port version] [$port revision] [$port variants] {}
</span> } catch {{*} eCode eMessage} {
ui_error "Error uninstalling $name: $eMessage"
}
</pre><pre style='margin:0'>
</pre>