<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/e997b876fc86b0a079e98e3cc9895401531f05b3">https://github.com/macports/macports-base/commit/e997b876fc86b0a079e98e3cc9895401531f05b3</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit e997b876fc86b0a079e98e3cc9895401531f05b3
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Wed Jul 19 19:32:04 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> WIP: Sort ports before installing
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Largely taken from restore_ports.tcl, TODO is to have only one
</span><span style='display:block; white-space:pre;color:#404040;'> sorting function for both uninstalling and installing.
</span>---
src/macports1.0/migrate.tcl | 84 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/migrate.tcl b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 28ca528..d227304 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -49,6 +49,7 @@ namespace eval migrate {
</span> # ASSUMING I GET THE FINAL PORTLIST FOR NOW
# $portlist
uninstall_installed portlist
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ sort_ports portlist
</span> recover_ports_state portlist
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -64,6 +65,89 @@ namespace eval migrate {
</span>
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc dependenciesForPort {portName variantInfo} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependencyList [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portSearchResult [mportlookup $portName]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # TODO: error handling, if any?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set portInfo [lindex $portSearchResult 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependencyTypes { depends_fetch depends_extract depends_build depends_lib depends_run }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependencyType $dependencyTypes {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists portInfo($dependencyType)] && [string length $portInfo($dependencyType)] > 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependency $portInfo($dependencyType) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend dependencyList [lindex [split $dependency:] end]
</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 $dependencyList
</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;'>+ proc sort_ports {portlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set port_installed {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set port_deps {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set port_in_list {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set newList [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set version [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variants [lindex $port 2]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set active [lindex $port 3]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists port_in_list($name)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set port_in_list($name) 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set port_installed($name) 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr port_in_list($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;'>+ if {![info exists port_deps(${name},${variants})]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set port_deps(${name},${variants}) [dependenciesForPort $name $variants]
</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;'>+ lappend newList [list $active $name $variants]
</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;'>+ set operationList [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while {[llength $newList] > 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set oldLen [llength $newList]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $newList {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {active name variants} $port break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$active && $port_installed($name) < ($port_in_list($name) - 1)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installable 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dep $port_deps(${name},${variants}) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists port_installed($dep)] && $port_installed($dep) == 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set installable 0
</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;'>+ if {$installable} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend operationList [list $name $variants $active]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ incr port_installed($name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set index [lsearch $newList [list $name $variants $active]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set newList [lreplace $newList $index $index]
</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 {[llength $newList] == $oldLen} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "stuck in loop"
</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 $operationList
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> proc sort_portlist_by_dependendents { portlist } {
# Sorts a list of port references such that dependents appear before
</pre><pre style='margin:0'>
</pre>