<pre style='margin:0'>
Dan Villiom Podlaski Christiansen (danchr) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/0e729c045a85e805f693c994f649ac9cc4a79458">https://github.com/macports/macports-base/commit/0e729c045a85e805f693c994f649ac9cc4a79458</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 0e729c045a85e805f693c994f649ac9cc4a79458
</span>Author: Dan Villiom Podlaski Christiansen <danchr@gmail.com>
AuthorDate: Fri Feb 17 22:26:47 2017 +0100
<span style='display:block; white-space:pre;color:#404040;'> Allow 'port reclaim' to uninstall unrequested ports
</span>---
doc/port-reclaim.1 | 4 +--
doc/port-reclaim.1.txt | 2 +-
src/macports1.0/reclaim.tcl | 72 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 3 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/doc/port-reclaim.1 b/doc/port-reclaim.1
</span><span style='display:block; white-space:pre;color:#808080;'>index 9114d26..5290af2 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/doc/port-reclaim.1
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/doc/port-reclaim.1
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,5 +1,5 @@
</span> '\" t
<span style='display:block; white-space:pre;background:#ffe0e0;'>-.TH "PORT\-RECLAIM" "1" "2017\-01\-28" "MacPorts 2\&.4\&.99" "MacPorts Manual"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+.TH "PORT\-RECLAIM" "1" "2017\-01\-27" "MacPorts 2\&.4\&.99" "MacPorts Manual"
</span> .\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -29,7 +29,7 @@ port-reclaim \- Reclaims disk space\&.
</span> .fi
.SH "DESCRIPTION"
.sp
<span style='display:block; white-space:pre;background:#ffe0e0;'>-\fBport reclaim\fR will find files that can be removed to reclaim disk space by uninstalling inactive ports on your system, and removing unneeded or unused installation files\&. The user is then provided interactive options for files to remove\&. No files are removed initially, until the user selects them from the provided list\&.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+\fBport reclaim\fR will find files that can be removed to reclaim disk space by uninstalling inactive ports on your system as well as unnecessary unrequested ports, and removing unneeded or unused installation files\&. The user is then provided interactive options for files to remove\&. No files are removed initially, until the user selects them from the provided list\&.
</span> .SH "OPTIONS"
.PP
\fB\-\-enable\-reminders\fR
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/doc/port-reclaim.1.txt b/doc/port-reclaim.1.txt
</span><span style='display:block; white-space:pre;color:#808080;'>index 26322c2..2916d73 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/doc/port-reclaim.1.txt
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/doc/port-reclaim.1.txt
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -15,7 +15,7 @@ SYNOPSIS
</span> DESCRIPTION
-----------
*port reclaim* will find files that can be removed to reclaim disk space by uninstalling inactive ports on your
<span style='display:block; white-space:pre;background:#ffe0e0;'>-system, and removing unneeded or unused installation files. The user is then provided interactive options for files to remove. No files are removed initially, until the user selects them from the provided list.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+system as well as unnecessary unrequested ports, and removing unneeded or unused installation files. The user is then provided interactive options for files to remove. No files are removed initially, until the user selects them from the provided list.
</span>
OPTIONS
-------
<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 33c19dd..5747eab 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;'>@@ -76,6 +76,7 @@ namespace eval reclaim {
</span> return
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ uninstall_unrequested
</span> uninstall_inactive
remove_distfiles
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -477,4 +478,75 @@ namespace eval reclaim {
</span> }
return 0
}
<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 uninstall_unrequested {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Attempts to uninstall unrequested ports no requested ports 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;'>+ # None
</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:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set unnecessary_ports [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set unnecessary_names [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set unnecessary_count 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set isrequested {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "$macports::ui_prefix Checking for unnecessary unrequested ports"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set ports {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port [sort_portlist_by_dependendents [registry::entry imaged]] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set isrequested([$port name]) [registry::property_retrieve $port requested]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ports([$port name]) $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$isrequested([$port name]) == 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependent [$port dependents] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$isrequested([$dependent name]) != 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "[$port name] is requested by [$dependent name]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set isrequested([$port name]) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</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;'>+ if {$isrequested([$port name]) == 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend unnecessary_ports $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend unnecessary_names [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr unnecessary_count
</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;'>+ if { $unnecessary_count == 0 } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Found no unrequested ports without requested dependents."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Found unrequested ports without requested dependents: [join $unnecessary_names {, }]."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists macports::ui_options(questions_multichoice)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set retstring [$macports::ui_options(questions_multichoice) "Would you like to uninstall these ports?" "" $unnecessary_names]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $retstring] > 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach i $retstring {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [lindex $unnecessary_names $i]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set port $ports($name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Uninstalling: $name"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Note: 'uninstall' takes a name, version, revision, variants and an options list.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ try -pass_signal {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ registry_uninstall::uninstall [$port name] [$port version] [$port revision] [$port variants] {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } catch {{*} eCode eMessage} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_error "Error uninstalling $name: $eMessage"
</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;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Not uninstalling ports; use 'port setrequested' mark a port as explicitly requested."
</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;'>+ return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
</pre><pre style='margin:0'>
</pre>