[138758] contrib/mpab/chroot-scripts

jmr at macports.org jmr at macports.org
Fri Jul 17 23:08:11 PDT 2015


Revision: 138758
          https://trac.macports.org/changeset/138758
Author:   jmr at macports.org
Date:     2015-07-17 23:08:11 -0700 (Fri, 17 Jul 2015)
Log Message:
-----------
mpab: always build ports in dependency order

Modified Paths:
--------------
    contrib/mpab/chroot-scripts/buildports
    contrib/mpab/chroot-scripts/genportlist.tcl

Modified: contrib/mpab/chroot-scripts/buildports
===================================================================
--- contrib/mpab/chroot-scripts/buildports	2015-07-18 04:54:17 UTC (rev 138757)
+++ contrib/mpab/chroot-scripts/buildports	2015-07-18 06:08:11 UTC (rev 138758)
@@ -72,7 +72,7 @@
 
 useFailCache=""
 if [[ -f /var/tmp/portlist && `head -n1 /var/tmp/portlist` != "all" ]]; then
-   portList=`/bin/cat /var/tmp/portlist`
+   portList=`< /var/tmp/portlist $TCLSH /var/tmp/genportlist.tcl -`
 else
    portList=`$TCLSH /var/tmp/genportlist.tcl`
    useFailCache=1

Modified: contrib/mpab/chroot-scripts/genportlist.tcl
===================================================================
--- contrib/mpab/chroot-scripts/genportlist.tcl	2015-07-18 04:54:17 UTC (rev 138757)
+++ contrib/mpab/chroot-scripts/genportlist.tcl	2015-07-18 06:08:11 UTC (rev 138758)
@@ -87,25 +87,72 @@
    error "Failed to initialize ports sytem: $result"
 }
 
-if {[catch {set search_result [mportlistall]} result]} {
-   puts stderr "$errorInfo"
-   error "Failed to find any ports: $result"
-}
+set depstypes [list depends_fetch depends_extract depends_build depends_lib depends_run]
+array set portdepinfo {}
 
-array set portdepinfo {}
-foreach {name infoarray} $search_result {
-   array set portinfo $infoarray
-   set depstypes {depends_fetch depends_extract depends_build depends_lib depends_run}
-   set deplist [list]
-   foreach depstype $depstypes {
-      if {[info exists portinfo($depstype)] && $portinfo($depstype) != ""} {
-         foreach onedep $portinfo($depstype) {
-            lappend deplist [lindex [split [lindex $onedep 0] :] end]
-         }
-      }
-   }
-   set portdepinfo($portinfo(name)) $deplist
-   array unset portinfo
+if {[llength $argv] == 0} {
+    # do all ports
+    if {[catch {set search_result [mportlistall]} result]} {
+       puts stderr "$errorInfo"
+       error "Failed to find any ports: $result"
+    }
+
+    foreach {name infoarray} $search_result {
+       array set portinfo $infoarray
+       set deplist [list]
+       foreach depstype $depstypes {
+          if {[info exists portinfo($depstype)] && $portinfo($depstype) != ""} {
+             foreach onedep $portinfo($depstype) {
+                lappend deplist [lindex [split [lindex $onedep 0] :] end]
+             }
+          }
+       }
+       set portdepinfo($portinfo(name)) $deplist
+       array unset portinfo
+    }
+} else {
+    # do a specified list of ports
+    if {[lindex $argv 0] eq "-"} {
+        set todo [list]
+        while {[gets stdin line] >= 0} {
+            lappend todo [string trim $line]
+        }
+    } else {
+        set todo $argv
+    }
+    # save the ones that the caller actually wants to know about
+    foreach p $todo {
+        set inputports($p) 1
+    }
+    # process all recursive deps
+    while {$todo ne {}} {
+        set p [lindex $todo 0]
+        set todo [lrange $todo 1 end]
+        if {[catch {set lookup_result [mportlookup $p]} result]} {
+            puts stderr "$errorInfo"
+            error "Failed to find port '$p': $result"
+        }
+        if {[llength $lookup_result] < 2} {
+            puts stderr "port $p not found in the index"
+            continue
+        }
+
+        array set portinfo [lindex $lookup_result 1]
+        if {![info exists portdepinfo($portinfo(name))]} {
+            set deplist [list]
+            foreach depstype $depstypes {
+                if {[info exists portinfo($depstype)] && $portinfo($depstype) != ""} {
+                    foreach onedep $portinfo($depstype) {
+                        set depname [lindex [split [lindex $onedep 0] :] end]
+                        lappend deplist $depname
+                        lappend todo $depname
+                    }
+                }
+            }
+            set portdepinfo($portinfo(name)) $deplist
+        }
+        array unset portinfo
+    }
 }
 
 set portlist [list]
@@ -113,5 +160,13 @@
    process_port_deps $portname portdepinfo portlist
 }
 
-puts [join $portlist "\n"]
+if {[info exists inputports]} {
+    foreach portname $portlist {
+        if {[info exists inputports($portname)]} {
+            puts $portname
+        }
+    }
+} else {
+    puts [join $portlist "\n"]
+}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150717/25dd2d4c/attachment.html>


More information about the macports-changes mailing list