<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch release-2.7
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/38204920fc35240030aa6a720934c4bb36ffcf5d">https://github.com/macports/macports-base/commit/38204920fc35240030aa6a720934c4bb36ffcf5d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 38204920fc35240030aa6a720934c4bb36ffcf5d
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Wed Feb 23 17:26:26 2022 +1100
<span style='display:block; white-space:pre;color:#404040;'> port reclaim: only keep current versions' distfiles
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The idea of keeping some distfiles is that they may be needed in
</span><span style='display:block; white-space:pre;color:#404040;'> future when upgrading the ports, since distfiles stay the same across
</span><span style='display:block; white-space:pre;color:#404040;'> revision bumps and sometimes even when the version increases. So the
</span><span style='display:block; white-space:pre;color:#404040;'> files that should be kept are those that are needed by the version of
</span><span style='display:block; white-space:pre;color:#404040;'> each installed port that is currently available in the ports tree, not
</span><span style='display:block; white-space:pre;color:#404040;'> those that were needed to build the installed version(s).
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> (cherry picked from commit cd38df962d844f5adbdbfcf8cd434a50ecfb6eb4)
</span>---
src/macports1.0/reclaim.tcl | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 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 f06566cc..68aa50d1 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;'>@@ -218,6 +218,26 @@ namespace eval reclaim {
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ # return the variations that would be used when upgrading a port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # installed with the given requested variants
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc get_variations {installed_variants} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set vararray {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach v [array names macports::global_variations] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set vararray($v) $macports::global_variations($v)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set splitvariant [split $installed_variants -]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set minusvariant [lrange $splitvariant 1 end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set splitvariant [split [lindex $splitvariant 0] +]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set plusvariant [lrange $splitvariant 1 end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach v $plusvariant {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set vararray($v) +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach v $minusvariant {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set vararray($v) -
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [array get varray]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc remove_distfiles {} {
# Check for distfiles in both the root, and home directories. If found, delete them.
# Args:
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -252,16 +272,27 @@ namespace eval reclaim {
</span> $progress start
foreach port $installed_ports {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ # skip additional versions installed with the same variants
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists seen([$port name],[$port requested_variants])]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen([$port name],[$port requested_variants]) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset portinfo
</span> # Get mport reference
try -pass_signal {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] {}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {mportlookup [$port name]} lookup_result] || [llength $lookup_result] < 2} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn [msgcat::mc "Port %s not found: %s" [$port name] $lookup_result]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set portinfo [lindex $lookup_result 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set mport [mportopen $portinfo(porturl) [list subport $portinfo(name)] [get_variations [$port requested_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" [$port name] $eMessage]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn [msgcat::mc "Failed to open port %s %s: %s" [$port name] [$port requested_variants] $eMessage]
</span> continue
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Setup sub-Tcl-interpreter that executed the installed port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Get sub-Tcl-interpreter that executed the installed port
</span> set workername [ditem_key $mport workername]
# Append that port's distfiles to the list
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -293,6 +324,8 @@ namespace eval reclaim {
</span> $progress update $i $port_count
incr i
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset seen
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset portinfo
</span>
$progress finish
</pre><pre style='margin:0'>
</pre>