<pre style='margin:0'>
Ryan Schmidt (ryandesign) pushed a commit to branch master
in repository mpbb.
</pre>
<p><a href="https://github.com/macports/mpbb/commit/1392c2706a749a1dc73673c228039f7558e21e6d">https://github.com/macports/mpbb/commit/1392c2706a749a1dc73673c228039f7558e21e6d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 1392c2706a749a1dc73673c228039f7558e21e6d
</span>Author: Ryan Schmidt <git@ryandesign.com>
AuthorDate: Sat Jun 1 15:39:45 2019 -0500
<span style='display:block; white-space:pre;color:#404040;'> Uninstall ports without dependents
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> See: https://trac.macports.org/ticket/57464
</span>---
tools/uninstall-old-ports.tcl | 45 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/tools/uninstall-old-ports.tcl b/tools/uninstall-old-ports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 7dc0f21..eda239a 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/tools/uninstall-old-ports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/tools/uninstall-old-ports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -39,6 +39,42 @@ if {$showVersion} {
</span> exit 0
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# Create a lookup table for determining whether a port has dependents
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# (regardless of whether or not those dependents are currently installed)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+foreach source $macports::sources {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set source [lindex $source 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ try -pass_signal {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd [open [macports::getindex $source] r]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ try -pass_signal {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while {[gets $fd line] >= 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset portinfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [lindex $line 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set len [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set line [read $fd $len]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set portinfo $line
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # depends_test is not included because mpbb doesn't run `port test'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach field {depends_build depends_extract depends_fetch depends_lib depends_patch depends_run} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if [info exists portinfo($field)] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependency $portinfo($field) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependency_name [lindex [split $dependency {:}] end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr dependents([string tolower $dependency_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;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } catch {*} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn "It looks like your PortIndex file for $source may be corrupt."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ throw
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } finally {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close $fd
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } catch {*} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn "Can't open index file for source: $source"
</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> foreach port [registry::entry imaged] {
# Set to yes if a port should be uninstalled
set uninstall no
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -61,6 +97,15 @@ foreach port [registry::entry imaged] {
</span> # The version in the index is different than the installed one
ui_msg "Removing ${installed_name} @${installed_version}_${installed_revision}${installed_variants} because there is a newer version in the PortIndex"
set uninstall yes
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set lowercase_name [string tolower $installed_name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists dependents($lowercase_name)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Nothing depends on it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Removing ${installed_name} @${installed_version}_${installed_revision}${installed_variants} because no port in the PortIndex depends on it"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set uninstall yes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {no} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Not removing ${installed_name} @${installed_version}_${installed_revision}${installed_variants} because it has $dependents($lowercase_name) dependents"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
}
if {$uninstall} {
</pre><pre style='margin:0'>
</pre>