<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/08a5760be39cf3f3eb9460f14a39e0c36883c0a7">https://github.com/macports/macports-base/commit/08a5760be39cf3f3eb9460f14a39e0c36883c0a7</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 08a5760be39cf3f3eb9460f14a39e0c36883c0a7
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Wed Dec 7 23:02:40 2016 +1100
<span style='display:block; white-space:pre;color:#404040;'> Allow reclaim nag to be turned off.
</span>---
doc/port-reclaim.1.txt | 11 ++++
src/macports1.0/macports.tcl | 13 +++--
src/macports1.0/reclaim.tcl | 130 +++++++++++++++++++++++++++++--------------
src/port/port.tcl | 3 +-
4 files changed, 108 insertions(+), 49 deletions(-)
<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 e5d2000..eec6748 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;'>@@ -10,12 +10,23 @@ SYNOPSIS
</span> --------
[cmdsynopsis]
*port* [*-vd*] *reclaim*
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ [--enable-reminders] [--disable-reminders]
</span>
DESCRIPTION
-----------
*port reclaim* will reclaim disk space by uninstalling inactive ports on your
system, and removing unneeded or unused installation files.
<span style='display:block; white-space:pre;background:#e0ffe0;'>+OPTIONS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-------
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+*--enable-reminders*::
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Enable regular reminders to run *port reclaim*. Using this option will only
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+update the configuration; the reclaim process will not be run.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+*--disable-reminders*::
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Disable reminders to run *port reclaim*. Using this option will only
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+update the configuration; the reclaim process will not be run.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> include::global-flags.txt[]
SEE ALSO
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index a46ea70..ac2ba11 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1248,6 +1248,11 @@ proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
</span>
# call this just before you exit
proc mportshutdown {} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Check the last time 'reclaim' was run and run it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![macports::ui_isset ports_quiet]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reclaim::check_last_run
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # save ping times
global macports::ping_cache macports::portdbpath
if {[file writable $macports::portdbpath]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1263,10 +1268,6 @@ proc mportshutdown {} {
</span> close $pingfile
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Check the last time 'reclaim' was run and run it
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![macports::ui_isset ports_quiet]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- reclaim::check_last_run
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span>
# close it down so the cleanup stuff is called, e.g. vacuuming the db
registry::close
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4372,7 +4373,7 @@ proc macports::diagnose_main {opts} {
</span> return 0
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc macports::reclaim_main {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc macports::reclaim_main {opts} {
</span> # Calls the main function for the 'port reclaim' command.
#
# Args:
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4381,7 +4382,7 @@ proc macports::reclaim_main {} {
</span> # None
try {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- reclaim::main
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reclaim::main $opts
</span> } catch {{POSIX SIG SIGINT} eCode eMessage} {
ui_error [msgcat::mc "reclaim aborted: SIGINT received."]
return 2
<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 99d5fa7..1026375 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;'>@@ -58,16 +58,51 @@ package require macports
</span>
namespace eval reclaim {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc main {args} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc main {opts} {
</span> # The main function. Calls each individual function that needs to be run.
# Args:
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # None
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # opts - options array
</span> # Returns:
# None
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set options $opts
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists options(ports_reclaim_enable-reminders)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_info "Enabling port reclaim reminders."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ update_last_run
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists options(ports_reclaim_disable-reminders)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_info "Disabling port reclaim reminders."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ write_last_run_file disabled
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> uninstall_inactive
remove_distfiles
<span style='display:block; white-space:pre;background:#ffe0e0;'>- update_last_run
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set last_run_contents [read_last_run_file]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$last_run_contents eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set msg "This appears to be the first time you have run 'port reclaim'."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists macports::ui_options(questions_yesno)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set retval [$macports::ui_options(questions_yesno) $msg "ReclaimPrompt" "" {y} 0 "Would you like to be reminded to run it every two weeks?"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$retval != 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # User said no, store disabled flag
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set last_run_contents disabled
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ write_last_run_file $last_run_contents
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Reminders disabled. Run 'port reclaim --enable-reminders' to enable."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # the last run file will be updated below
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Reminders enabled. Run 'port reclaim --disable-reminders' to disable."
</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;'>+ # couldn't ask the question, leave disabled for now
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set last_run_contents disabled
</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 {$last_run_contents ne "disabled"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ update_last_run
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
proc walk_files {dir files_in_use unused_name} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -296,22 +331,30 @@ namespace eval reclaim {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc update_last_run {} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Updates the last_reclaim textfile with the newest time the code has been ran.
</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;'>- # None
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc read_last_run_file {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set path [file join ${macports::portdbpath} last_reclaim]
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Updating last run information."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd -1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set contents ""
</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 $path r]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set contents [gets $fd]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } catch {*} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Ignore error silently; the file might not have been created yet
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } finally {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$fd != -1} {
</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;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $contents
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc write_last_run_file {contents} {
</span> set path [file join ${macports::portdbpath} last_reclaim]
set fd -1
try -pass_signal {
set fd [open $path w]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts $fd [clock seconds]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $fd $contents
</span> } catch {*} {
# Ignore error silently
} finally {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -321,6 +364,20 @@ namespace eval reclaim {
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc update_last_run {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Updates the last_reclaim textfile with the newest time the code has been run.
</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;'>+ # None
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Updating last run information."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ write_last_run_file [clock seconds]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc check_last_run {} {
# Periodically warns the user that they haven't run 'port reclaim' in two weeks, and that they should consider doing so.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -330,39 +387,28 @@ namespace eval reclaim {
</span> # Returns:
# None
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Checking time since last reclaim run"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set path [file join ${macports::portdbpath} last_reclaim]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set time [read_last_run_file]
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set fd -1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set time ""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- try -pass_signal {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set fd [open $path r]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set time [gets $fd]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } catch {*} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Ignore error silently; the file might not have been created yet
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } finally {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$fd != -1} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- close $fd
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![string is integer -strict $time]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$time ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[clock seconds] - $time > 1209600} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set msg "You haven't run 'sudo port reclaim' in two weeks. It's recommended you run this regularly to reclaim disk space."
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[file writable $macports::portdbpath] && [info exists macports::ui_options(questions_yesno)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set retval [$macports::ui_options(questions_yesno) $msg "ReclaimPrompt" "" {y} 0 "Would you like to run it now?"]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$retval == 0} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # User said yes, run port reclaim
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- macports::reclaim_main
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # User said no, ask again in two weeks
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Change this time frame if a consensus is agreed upon
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- update_last_run
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Checking time since last reclaim run"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[clock seconds] - $time > 1209600} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set msg "You haven't run 'sudo port reclaim' in two weeks. It's recommended you run this regularly to reclaim disk space."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file writable $macports::portdbpath] && [info exists macports::ui_options(questions_yesno)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set retval [$macports::ui_options(questions_yesno) $msg "ReclaimPrompt" "" {y} 0 "Would you like to run it now?"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$retval == 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # User said yes, run port reclaim
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ macports::reclaim_main
</span> } else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn $msg
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # User said no, ask again in two weeks
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Change this time frame if a consensus is agreed upon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ update_last_run
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn $msg
</span> }
}
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port/port.tcl b/src/port/port.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 993bf2b..3193239 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port/port.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2734,7 +2734,7 @@ proc action_reclaim { action portlist opts } {
</span> if {[prefix_unwritable]} {
return 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- macports::reclaim_main
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ macports::reclaim_main $opts
</span> return 0
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4393,6 +4393,7 @@ array set cmd_opts_array {
</span> upgrade {force enforce-variants no-replace no-rev-upgrade}
rev-upgrade {id-loadcmd-check}
diagnose {quiet}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ reclaim {enable-reminders disable-reminders}
</span> }
##
</pre><pre style='margin:0'>
</pre>