Ignore:
Timestamp:
Feb 26, 2003, 12:08:23 PM (18 years ago)
Author:
kevin
Message:

Re-use the Port API dependency engine for handling portfile dependencies.
Allow multiple Portfiles to be opened simultaneously.
Bug#: 333, 354

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/darwinports1.0/darwinports_dlist.tcl

    r2083 r2084  
    6969}
    7070
     71# dlist_delete
     72# Deletes the specified ditem from the dlist.
     73#       dlist - the list to search
     74#       ditem - the item to delete
     75proc dlist_delete {dlist ditem} {
     76    upvar $dlist uplist
     77    set ix [lsearch -exact $uplist $ditem]
     78    if {$ix >= 0} {
     79                set uplist [lreplace $uplist $ix $ix]
     80    }
     81}
     82
    7183# dlist_has_pending
    7284# Returns true if the dlist contains ditems
     
    225237# or {} if all ditems were evaluated.
    226238#       dlist    - the dependency list to evaluate
     239#       testcond - test condition to populate the status dictionary
     240#                  should return {-1, 0, 1}
    227241#       handler  - the handler to invoke on each ditem
     242#       canfail  - If 1, then progress will not stop when a failure
     243#                  occures; if 0, then dlist_eval will return on the
     244#                  first failure
    228245#       selector - the selector for determining eligibility
    229246
    230 proc dlist_eval {dlist handler {selector "dlist_get_next"}} {
     247proc dlist_eval {dlist testcond handler {canfail "0"} {selector "dlist_get_next"}} {
    231248        array set statusdict [list]
    232249       
    233250        # Do a pre-run seeing if any items automagically
    234251        # can evaluate to true.
    235         foreach ditem $dlist {
    236                 #if test ditem
    237                 if {0} {
    238                         foreach token [dlist_key $ditem provides] {
    239                                 set statusdict($name) 1
     252        if {$testcond != ""} {
     253                foreach ditem $dlist {
     254                        if {[eval "expr \[\$testcond \$ditem\] == 1"]} {
     255                                foreach token [ditem_key $ditem provides] {
     256                                        set statusdict($token) 1
     257                                }
     258                                dlist_delete dlist $ditem
    240259                        }
    241                         ldelete dlist $ditem
    242260                }
    243261        }
     
    252270                        # $handler should return a unix status code, 0 for success.
    253271                        # statusdict notation is 1 for success
    254                         if {[catch {$handler $ditem} result]} {
     272                        if {[catch {eval "$handler $ditem"} result]} {
    255273                                puts $result
    256274                                return $dlist
     
    263281                        }
    264282                       
     283                        # Abort if we're not allowed to fail
     284                        if {$canfail == 0 && $result != 0} {
     285                                return $dlist
     286                        }
     287                       
    265288                        # Delete the ditem from the waiting list.
    266                         darwinports_dlist::ldelete dlist $ditem
     289                        dlist_delete dlist $ditem
    267290                }
    268291        }
     
    331354}
    332355
    333 proc ldelete {list value} {
    334     upvar $list uplist
    335     set ix [lsearch -exact $uplist $value]
    336     if {$ix >= 0} {
    337         set uplist [lreplace $uplist $ix $ix]
    338     }
    339 }
    340 
    341356# End of darwinports_dlist namespace
    342357}
Note: See TracChangeset for help on using the changeset viewer.