<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/687ec18a280a27464132d21a255c6bb7a5bba7dc">https://github.com/macports/macports-base/commit/687ec18a280a27464132d21a255c6bb7a5bba7dc</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 687ec18a280a27464132d21a255c6bb7a5bba7dc
</span>Author: Clemens Lang <cal@macports.org>
AuthorDate: Sat Dec 2 00:24:19 2023 +0100
<span style='display:block; white-space:pre;color:#404040;'> macports/restore: Add progress f/dep calculation
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Dependency calculation for large installations can take a few minutes.
</span><span style='display:block; white-space:pre;color:#404040;'> In my personal test sample of 88 requested ports, it took about
</span><span style='display:block; white-space:pre;color:#404040;'> 3 minutes. Since we insert dependencies at the beginning of the
</span><span style='display:block; white-space:pre;color:#404040;'> worklist, we can use processing of a requested port and the total number
</span><span style='display:block; white-space:pre;color:#404040;'> of requested ports as a progress indicator.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This commit draws a progress bar based on the number of requested ports
</span><span style='display:block; white-space:pre;color:#404040;'> whose dependencies have been successfully computed. This isn't perfect,
</span><span style='display:block; white-space:pre;color:#404040;'> because the various steps will not take the same amount of time, and the
</span><span style='display:block; white-space:pre;color:#404040;'> last port will be reported as 100 % while its dependencies are being
</span><span style='display:block; white-space:pre;color:#404040;'> processed, but it's better then just printing no progress or one that
</span><span style='display:block; white-space:pre;color:#404040;'> does not really allow estimating how long the process will take.
</span>---
src/macports1.0/restore.tcl | 50 +++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 13 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/restore.tcl b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 990364116..c8eaeb4bd 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -212,12 +212,25 @@ namespace eval restore {
</span> array set dep_ports {}
set dependencies [::struct::graph]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg -nonewline "$macports::ui_prefix Computing dependency order. This will take a while, please be patient"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- flush stdout
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[macports::ui_isset ports_debug]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set requested_counter 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set requested_total 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fancy_output [expr {![macports::ui_isset ports_debug] && [info exists macports::ui_options(progress_generic)]}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$fancy_output} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set progress $macports::ui_options(progress_generic)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc noop {args} {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set progress noop
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$fancy_output} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "$macports::ui_prefix Computing dependency order"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "$macports::ui_prefix Computing dependency order. This will take a while, please be patient"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ flush stdout
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress start
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Populate $ports so that we can look up requested variants given the
# port name.
foreach port $portlist {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -226,8 +239,14 @@ namespace eval restore {
</span> # bool-ify active
set active [expr {$active eq "installed"}]
set ports($name) [list $requested $active $variants]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$requested} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr requested_total
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress update $requested_counter $requested_total
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Iterate over the requested ports to calculate the dependency tree.
# Use a worklist so that we can push items to the front to do
# depth-first dependency resolution.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -258,7 +277,9 @@ namespace eval restore {
</span> # Find the port
set port [mportlookup $portname]
if {[llength $port] < 2} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress intermission
</span> ui_warn "Port $portname not found, skipping"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress update $requested_counter $requested_total
</span> continue
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -271,17 +292,12 @@ namespace eval restore {
</span> set variants ""
set requested 0
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {($requested || [macports::ui_isset ports_verbose]) && ![macports::ui_isset ports_debug]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # Print a progress indicator if this is a requested port (or
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # for every port if in verbose mode).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg -nonewline "."
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- flush stdout
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span>
# Open the port with the requested variants from the snapshot
set variations [variants_to_variations_arr $variants]
array set portinfo [lindex $port 1]
if {[catch {set mport [mportopen $portinfo(porturl) [list subport $portinfo(name)] $variations]} result]} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress intermission
</span> error "Unable to open port '$portname': $result"
}
array unset portinfo
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -294,6 +310,7 @@ namespace eval restore {
</span> # (such as for example when a port depends on curl-ca-bundle, but the snapshot contains certsync, which
# conflicts with curl-ca-bundle).
if {[mportdepends $mport install 0] != 0} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress intermission
</span> error "Unable to determine dependencies for port '$portname'"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -321,7 +338,9 @@ namespace eval restore {
</span> if {![info exists seen_conflicts($portinfo(name),$conflict)]} {
set seen_conflicts($portinfo(name),$conflict) 1
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress intermission
</span> ui_warn "Snapshot contains $conflict, which conflicts with dependency $portinfo(name); assuming $conflict provides the functionality of $portinfo(name)"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress update $requested_counter $requested_total
</span> }
if {![$dependencies node exists $conflict]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -351,11 +370,16 @@ namespace eval restore {
</span> set worklist [linsert $worklist 0 $dependency]
}
mportclose $mport
<span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![macports::ui_isset ports_debug]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$requested} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Print a progress indicator if this is a requested port (or for every port if in verbose mode).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr requested_counter
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress update $requested_counter $requested_total
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $progress finish
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> ui_msg "$macports::ui_prefix Sorting dependency tree"
# Compute a list of stronly connected components using Tarjan's
</pre><pre style='margin:0'>
</pre>