<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository mpbb.
</pre>
<p><a href="https://github.com/macports/mpbb/commit/a1e518e839283ff270c782355073c3b6c56630ed">https://github.com/macports/mpbb/commit/a1e518e839283ff270c782355073c3b6c56630ed</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit a1e518e839283ff270c782355073c3b6c56630ed
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sun Feb 12 20:42:33 2017 +1100
<span style='display:block; white-space:pre;color:#404040;'> uninstall-old-ports.tcl improvements
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> - Use registry2 API.
</span><span style='display:block; white-space:pre;color:#404040;'> - Use the same format for printing full port specs as MacPorts does.
</span><span style='display:block; white-space:pre;color:#404040;'> - Simplify check for current version.
</span>---
tools/uninstall-old-ports.tcl | 56 +++++++++----------------------------------
1 file changed, 11 insertions(+), 45 deletions(-)
<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 1b376d3..fbe8033 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,64 +39,30 @@ if {$showVersion} {
</span> exit 0
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-##
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# Compare two versions in the form of (epoch, version, revision).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# @param versionA Tcl array of the first version with the keys epoch, version, and revision.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# @param versionB Tcl array of the second version in the same format as versionA.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# @return An integer < 0 if the first version is smaller than the second. 0, if
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# both versions are equal. An integer > 0 if the second version is
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# larger than the first.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-proc compare_version_tuple {versionA versionB} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- upvar $versionA vA
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- upvar $versionB vB
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set epochCompare [vercmp $vA(epoch) $vB(epoch)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set versionCompare [vercmp $vA(version) $vB(version)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set revisionCompare [vercmp $vA(revision) $vB(revision)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$epochCompare != 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return $epochCompare
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$versionCompare != 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return $versionCompare
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return $revisionCompare
</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;'>-foreach port [registry::installed] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Set to yes if a port is obsolete
</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;'>+ # Set to yes if a port is not current
</span> set old no
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_version [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_revision [lindex $port 2]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_variants [lindex $port 3]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_epoch [lindex $port 5]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- array set installed_version_tuple {}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_version_tuple(epoch) $installed_epoch
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_version_tuple(version) $installed_version
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set installed_version_tuple(revision) $installed_revision
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installed_name [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installed_version [$port version]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installed_revision [$port revision]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installed_variants [$port variants]
</span>
set portindex_match [mportlookup $installed_name]
if {[llength $portindex_match] < 2} {
# Not found in index, classify as old
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg "Removing $installed_name$installed_variants $installed_epoch@$installed_version-$installed_revision because it is no longer in the PortIndex"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Removing ${installed_name} @${installed_version}_${installed_revision}${installed_variants} because it is no longer in the PortIndex"
</span> set old yes
} else {
array unset portinfo
array set portinfo [lindex $portindex_match 1]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set result [compare_version_tuple portinfo installed_version_tuple]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$result > 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Port is outdated because the version in the index is newer than
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # the installed one
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg "Removing $installed_name$installed_variants $installed_epoch@$installed_version-$installed_revision because there is a newer version in the PortIndex"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$portinfo(version) ne $installed_version || $portinfo(revision) != $installed_revision} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Port is not current because the version in the index is
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # different than the installed one
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Removing ${installed_name} @${installed_version}_${installed_revision}${installed_variants} because there is a newer version in the PortIndex"
</span> set old yes
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # If the version we have is newer than the one in the PortIndex, we are
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # probably building agaist an old version of the ports tree.
</span> }
if {$old} {
registry_uninstall::uninstall $installed_name $installed_version $installed_revision $installed_variants [list ports_force 1]
</pre><pre style='margin:0'>
</pre>